From 11e49eb76e5fe00a4ea0fe0900941e407de521cb Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 30 Jan 2020 13:20:31 +0000 Subject: [PATCH] Add whoami --- .../docker/files/whoami/docker-compose.yml | 12 +++++++ ansible/roles/docker/tasks/main.yml | 3 ++ ansible/roles/docker/tasks/whoami.yml | 31 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 ansible/roles/docker/files/whoami/docker-compose.yml create mode 100644 ansible/roles/docker/tasks/whoami.yml diff --git a/ansible/roles/docker/files/whoami/docker-compose.yml b/ansible/roles/docker/files/whoami/docker-compose.yml new file mode 100644 index 0000000..69936e4 --- /dev/null +++ b/ansible/roles/docker/files/whoami/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + whoami: + image: containous/whoami:latest + container_name: whoami + restart: unless-stopped + labels: + - "traefik.enable=true" + - "traefik.http.routers.whoami.rule=Host(`whoami.theorangeone.net`)" + - "traefik.http.routers.whoami.tls=true" + - "traefik.http.routers.whoami.tls.certresolver=le" diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml index 1a98af9..8fdc4e9 100644 --- a/ansible/roles/docker/tasks/main.yml +++ b/ansible/roles/docker/tasks/main.yml @@ -15,3 +15,6 @@ - name: Install dnsmasq include: dnsmasq.yml + +- name: Install whoami + include: whoami.yml diff --git a/ansible/roles/docker/tasks/whoami.yml b/ansible/roles/docker/tasks/whoami.yml new file mode 100644 index 0000000..f86cc99 --- /dev/null +++ b/ansible/roles/docker/tasks/whoami.yml @@ -0,0 +1,31 @@ +- name: Create whoami directory + file: + path: '/opt/whoami' + state: directory + owner: "{{ docker_user.name }}" + mode: "{{ docker_compose_directory_mask }}" + become: true + become_user: root + +- name: Install whoami compose file + template: + src: files/whoami/docker-compose.yml + dest: "/opt/whoami/docker-compose.yml" + mode: "{{ docker_compose_file_mask }}" + owner: "{{ docker_user.name }}" + validate: /usr/bin/docker-compose -f %s config + register: compose_file + become: true + become_user: root + +- name: Cycle whoami container + docker_compose: + project_src: /opt/whoami + pull: true + remove_orphans: true + remove_volumes: true + state: "{{ item }}" + when: compose_file.changed + loop: + - absent + - present