From 709466ef5186af5138a15d740cc32c5293cb9ed5 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sat, 20 May 2023 16:06:45 +0200 Subject: [PATCH] [WHOAMI] Migrate configs --- playbook.yml | 1 + roles/whoami/tasks/base.yml | 32 +++++++++++++++++++ roles/whoami/tasks/main.yml | 4 +++ .../whoami/templates/docker-compose.yml.j2 | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 roles/whoami/tasks/base.yml create mode 100644 roles/whoami/tasks/main.yml rename confs/whoami/docker-compose.yml => roles/whoami/templates/docker-compose.yml.j2 (87%) diff --git a/playbook.yml b/playbook.yml index 470da79..0b1f9a6 100644 --- a/playbook.yml +++ b/playbook.yml @@ -5,3 +5,4 @@ roles: - { role: docker, tags: ["docker"] } - { role: traefik, tags: ["traefik"] } + - { role: whoami, tags: ["whoami"] } diff --git a/roles/whoami/tasks/base.yml b/roles/whoami/tasks/base.yml new file mode 100644 index 0000000..468e461 --- /dev/null +++ b/roles/whoami/tasks/base.yml @@ -0,0 +1,32 @@ +--- + +- name: Check whoami directory exist + ansible.builtin.file: + path: whoami + state: directory + +- name: Copy template conf + ansible.builtin.template: + backup: true + src: "{{ item.src }}" + dest: "whoami/{{ item.dest }}" + loop: + - { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' } + register: whoami_copy_templates_results + +- name: Force update and restart container + community.docker.docker_compose: + project_src: whoami + state: present + pull: true + restarted: true + when: whoami_copy_templates_results.changed + become: true + +- name: Update or start container + community.docker.docker_compose: + project_src: whoami + state: present + pull: true + when: not whoami_copy_templates_results.changed + become: true \ No newline at end of file diff --git a/roles/whoami/tasks/main.yml b/roles/whoami/tasks/main.yml new file mode 100644 index 0000000..3f670ac --- /dev/null +++ b/roles/whoami/tasks/main.yml @@ -0,0 +1,4 @@ +--- + +- ansible.builtin.import_tasks: base.yml + name: base \ No newline at end of file diff --git a/confs/whoami/docker-compose.yml b/roles/whoami/templates/docker-compose.yml.j2 similarity index 87% rename from confs/whoami/docker-compose.yml rename to roles/whoami/templates/docker-compose.yml.j2 index 304c518..691e1bb 100644 --- a/confs/whoami/docker-compose.yml +++ b/roles/whoami/templates/docker-compose.yml.j2 @@ -10,7 +10,7 @@ services: labels: - "traefik.enable=true" - "traefik.http.routers.whoami-secure.entrypoints=https" - - "traefik.http.routers.whoami-secure.rule=Host(`whoami.mrdev023.fr`)" + - "traefik.http.routers.whoami-secure.rule=Host(`whoami.{{ server.domain }}`)" - "traefik.http.routers.whoami-secure.tls=true" - "traefik.http.routers.whoami-secure.tls.certresolver=sslResolver" # - "traefik.http.routers.whoami-secure.service=whoami"