Signed-off-by: Fam Zheng <famz@redhat.com>
---
scripts/deploy | 10 +++++++++-
scripts/dockerfiles/db.docker | 6 ++++++
scripts/playbooks/deploy-db.yml | 18 ++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
create mode 100644 scripts/dockerfiles/db.docker
create mode 100644 scripts/playbooks/deploy-db.yml
diff --git a/scripts/deploy b/scripts/deploy
index 0fc61ff..1953e9b 100755
--- a/scripts/deploy
+++ b/scripts/deploy
@@ -17,11 +17,13 @@ def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--server", "-s", dest="web_server",
help="Web server host address")
+ parser.add_argument("--db", "-d", dest="db_server",
+ help="Database host address")
parser.add_argument("--tester", "-t", nargs="*", dest="testers",
help="Tester host address")
parser.add_argument("--importer", "-i", nargs="?",
help="Importer host address")
- parser.add_argument("--debug", "-d", action="store_true",
+ parser.add_argument("--debug", "-D", action="store_true",
help="Enable debug output")
return parser.parse_known_args()
@@ -31,12 +33,16 @@ def generate_inventory_file(args):
[servers]
%s
+[db]
+%s
+
[importers]
%s
[testers]
%s""" \
% (args.web_server or "",
+ args.db_server or "",
args.importer or "",
"\n".join(args.testers or [])))
f.flush()
@@ -50,6 +56,8 @@ def main():
playbooks = []
if args.web_server:
playbooks.append("deploy-servers.yml")
+ if args.db_server:
+ playbooks.append("deploy-db.yml")
if args.testers:
playbooks.append("deploy-testers.yml")
if args.importer:
diff --git a/scripts/dockerfiles/db.docker b/scripts/dockerfiles/db.docker
new file mode 100644
index 0000000..80a34e5
--- /dev/null
+++ b/scripts/dockerfiles/db.docker
@@ -0,0 +1,6 @@
+FROM postgres:11
+EXPOSE 5432
+ENV POSTGRES_USER patchew
+ENV POSTGRES_PASSWORD patchew
+ENV POSTGRES_DB patchew
+ENV PGDATA /data/patchew/db
diff --git a/scripts/playbooks/deploy-db.yml b/scripts/playbooks/deploy-db.yml
new file mode 100644
index 0000000..2b69995
--- /dev/null
+++ b/scripts/playbooks/deploy-db.yml
@@ -0,0 +1,18 @@
+- hosts: db
+ vars_prompt:
+ - name: instance_name
+ prompt: "Instance name of the patchew postgres db"
+ default: patchew-server-db
+ private: no
+ vars:
+ base_dir: "/data/{{ instance_name }}"
+ src_dir: "{{ base_dir }}/src"
+ data_dir: "{{ base_dir }}/data"
+ tasks:
+ - name: Create data dir
+ file:
+ path: "{{ data_dir }}"
+ state: directory
+ - import_tasks: tasks/docker-deploy.yml
+ vars:
+ instance_role: db
--
2.17.2
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel