From 89ba23719c360cbfd787ef206916f6b2bb18184d Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 23 Apr 2020 20:49:43 +0100 Subject: [PATCH] Move traefik into its own role --- .../docker/vars => group_vars/all}/docker.yml | 4 ++++ ansible/main.yml | 1 + ansible/roles/docker-cleanup/tasks/main.yml | 3 --- ansible/roles/docker-cleanup/vars/docker.yml | 3 --- ansible/roles/docker/tasks/main.yml | 8 -------- .../files}/docker-compose.yml | 0 .../files}/file-provider.yml | 0 .../traefik => traefik/files}/traefik.yml | 0 .../traefik.yml => traefik/tasks/main.yml} | 18 +++++++++--------- 9 files changed, 14 insertions(+), 23 deletions(-) rename ansible/{roles/docker/vars => group_vars/all}/docker.yml (60%) delete mode 100644 ansible/roles/docker-cleanup/vars/docker.yml rename ansible/roles/{docker/files/traefik => traefik/files}/docker-compose.yml (100%) rename ansible/roles/{docker/files/traefik => traefik/files}/file-provider.yml (100%) rename ansible/roles/{docker/files/traefik => traefik/files}/traefik.yml (100%) rename ansible/roles/{docker/tasks/traefik.yml => traefik/tasks/main.yml} (77%) diff --git a/ansible/roles/docker/vars/docker.yml b/ansible/group_vars/all/docker.yml similarity index 60% rename from ansible/roles/docker/vars/docker.yml rename to ansible/group_vars/all/docker.yml index 497d574..61c562d 100644 --- a/ansible/roles/docker/vars/docker.yml +++ b/ansible/group_vars/all/docker.yml @@ -1,2 +1,6 @@ +docker_user: + id: 3000 + name: dockeruser + docker_compose_file_mask: 0664 docker_compose_directory_mask: 0775 diff --git a/ansible/main.yml b/ansible/main.yml index 11d31db..e96bc95 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -21,4 +21,5 @@ docker_users: - "{{ user }}" - docker-cleanup + - traefik - docker diff --git a/ansible/roles/docker-cleanup/tasks/main.yml b/ansible/roles/docker-cleanup/tasks/main.yml index 35ffbdf..fa6991a 100644 --- a/ansible/roles/docker-cleanup/tasks/main.yml +++ b/ansible/roles/docker-cleanup/tasks/main.yml @@ -1,6 +1,3 @@ -- name: Include docker variables - include_vars: docker.yml - - name: Install docker-compose apt: name: docker-compose diff --git a/ansible/roles/docker-cleanup/vars/docker.yml b/ansible/roles/docker-cleanup/vars/docker.yml deleted file mode 100644 index 1d68f11..0000000 --- a/ansible/roles/docker-cleanup/vars/docker.yml +++ /dev/null @@ -1,3 +0,0 @@ -docker_user: - id: 3000 - name: dockeruser diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml index 89e7277..0429bb8 100644 --- a/ansible/roles/docker/tasks/main.yml +++ b/ansible/roles/docker/tasks/main.yml @@ -1,8 +1,3 @@ -- name: Include docker variables - include_vars: docker.yml - -# Applications - - name: Install calibre include: calibre.yml @@ -51,9 +46,6 @@ - name: Install theorangeone.net include: theorangeone.net.yml -- name: Install traefik - include: traefik.yml - - name: Install tt-rss include: tt-rss.yml diff --git a/ansible/roles/docker/files/traefik/docker-compose.yml b/ansible/roles/traefik/files/docker-compose.yml similarity index 100% rename from ansible/roles/docker/files/traefik/docker-compose.yml rename to ansible/roles/traefik/files/docker-compose.yml diff --git a/ansible/roles/docker/files/traefik/file-provider.yml b/ansible/roles/traefik/files/file-provider.yml similarity index 100% rename from ansible/roles/docker/files/traefik/file-provider.yml rename to ansible/roles/traefik/files/file-provider.yml diff --git a/ansible/roles/docker/files/traefik/traefik.yml b/ansible/roles/traefik/files/traefik.yml similarity index 100% rename from ansible/roles/docker/files/traefik/traefik.yml rename to ansible/roles/traefik/files/traefik.yml diff --git a/ansible/roles/docker/tasks/traefik.yml b/ansible/roles/traefik/tasks/main.yml similarity index 77% rename from ansible/roles/docker/tasks/traefik.yml rename to ansible/roles/traefik/tasks/main.yml index e7a103e..cf2a472 100644 --- a/ansible/roles/docker/tasks/traefik.yml +++ b/ansible/roles/traefik/tasks/main.yml @@ -1,4 +1,4 @@ -- name: Create traefik directory +- name: Create install directory file: path: /opt/traefik state: directory @@ -6,16 +6,16 @@ mode: "{{ docker_compose_directory_mask }}" become: true -- name: Create traefik config directory +- name: Create config directory file: path: /opt/traefik/traefik state: directory mode: "{{ docker_compose_directory_mask }}" become: true -- name: Install traefik compose file +- name: Install compose file template: - src: files/traefik/docker-compose.yml + src: files/docker-compose.yml dest: /opt/traefik/docker-compose.yml mode: "{{ docker_compose_file_mask }}" owner: "{{ docker_user.name }}" @@ -23,25 +23,25 @@ register: compose_file become: true -- name: Install traefik config +- name: Install config template: - src: files/traefik/traefik.yml + src: files/traefik.yml dest: /opt/traefik/traefik/traefik.yml mode: "{{ docker_compose_file_mask }}" owner: "{{ docker_user.name }}" register: config_file become: true -- name: Install traefik file provider +- name: Install file provider template: - src: files/traefik/file-provider.yml + src: files/file-provider.yml dest: /opt/traefik/traefik/file-provider.yml mode: "{{ docker_compose_file_mask }}" owner: "{{ docker_user.name }}" register: file_provider become: true -- name: Cycle traefik container +- name: Cycle container docker_compose: project_src: /opt/traefik pull: true