From eff76229188a2c388cc43796b5089e0f6232afd4 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 5 Oct 2022 23:32:32 +0200 Subject: [PATCH] docker-compose server postgresql et redis --- inventory/group_vars/db | 1 + inventory/group_vars/db_vault | 16 +++++++------ server/files/docker-compose-server.yml | 30 +++++++++++++++++++++++++ server/tasks/main.yml | 31 ++++++++++++++++++++++++-- server/templates/env.j2 | 3 +++ 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 server/files/docker-compose-server.yml create mode 100644 server/templates/env.j2 diff --git a/inventory/group_vars/db b/inventory/group_vars/db index e69de29..a744227 100644 --- a/inventory/group_vars/db +++ b/inventory/group_vars/db @@ -0,0 +1 @@ +postgres_db: toto \ No newline at end of file diff --git a/inventory/group_vars/db_vault b/inventory/group_vars/db_vault index 6504299..db089f3 100644 --- a/inventory/group_vars/db_vault +++ b/inventory/group_vars/db_vault @@ -1,8 +1,10 @@ $ANSIBLE_VAULT;1.1;AES256 -34626434323630303038366133623235343836353338666532653864656533623937643239313261 -3036333938613861313833303537343637386135643939640a636638363934326133386538306163 -63616464303165396338366465336335613761316261666535633730653433333465303761323837 -6261323137663035390a616438393138663039643233306233653361663435623239323639623335 -65383038306462363263623162343363613633633432333364363236633065633437623339396239 -35633137613933323635306234633262306536393536316464326431646361366438346661333234 -383930316166353338313935353133316666 +35323139356565316333376432336436666566666631363635366235316435313536373765383234 +6664623264396635643636663865626130616135326230610a373064656264323233663563623930 +38373762363331663632343036336139663833616638653361363535643239643166363435613764 +3864363664303836380a363739653638623639663262356532656262393862323164656531393531 +35663166376632663734356666306433383363386236613330663536326432306561653665356533 +64396538376432336532343366393938363963656432353638346165313836373136343433623435 +65626138633637653631386663386462623633656434363761623366626565396362663864613166 +33346136386532636132613532626133376534326339646161356461346434626335376661656534 +32343936616335376563363131643938333833376231663862333961383566666137 diff --git a/server/files/docker-compose-server.yml b/server/files/docker-compose-server.yml new file mode 100644 index 0000000..a45804c --- /dev/null +++ b/server/files/docker-compose-server.yml @@ -0,0 +1,30 @@ +version: "3.3" +services: + + db: + image: postgres + volumes: + - app-db-data:/var/lib/postgresql/data/pgdata + env_file: + - .env + environment: + - PGDATA=/var/lib/postgresql/data/pgdata + ports: + - "54321:5432" + + redis: + image: redis/redis-stack-server:latest + ports: + - "63791:6379" + + liquibase: + build: + context: ./covas-liquibase + dockerfile: Dockerfile + depends_on: + - db + command: + - "update" + +volumes: + app-db-data: diff --git a/server/tasks/main.yml b/server/tasks/main.yml index 5e9e87c..0be5464 100644 --- a/server/tasks/main.yml +++ b/server/tasks/main.yml @@ -13,10 +13,37 @@ - name: Create directory file: - path: "/home/valentin/covas-liquibase" + path: "/home/valentin/{{ item }}" state: directory + with_items: + - db + - db/covas-liquibase - name: Extract repo isr unarchive: src: "/tmp/covas-liquibase.tar.gz" - dest: "/home/valentin/covas-liquibase" \ No newline at end of file + dest: "/home/valentin/db/covas-liquibase" + +- name: Template env file + template: + src: env.j2 + dest: /home/valentin/db/.env + +- name: Copy docker compose server file + copy: + src: docker-compose-server.yml + dest: /home/valentin/db/docker-compose.yml + + +- name: Stopping existing service + community.docker.docker_compose: + project_src: /home/valentin/db + +- name: Starting service + community.docker.docker_compose: + project_src: /home/valentin/db + register: output + +- name: debug output + debug: + var: output \ No newline at end of file diff --git a/server/templates/env.j2 b/server/templates/env.j2 new file mode 100644 index 0000000..f90d46b --- /dev/null +++ b/server/templates/env.j2 @@ -0,0 +1,3 @@ +POSTGRES_PASSWORD={{ postgres_password }} +POSTGRES_USER={{ postgres_user }} +POSTGRES_DB={{ postgres_db }} \ No newline at end of file