Improve reuse of tasks
This commit is contained in:
parent
13cf7a05ee
commit
3b5e27be2f
7 changed files with 8 additions and 7 deletions
|
|
@ -2,8 +2,8 @@
|
||||||
- name: Deploy acme-dns
|
- name: Deploy acme-dns
|
||||||
tags: acme-dns
|
tags: acme-dns
|
||||||
block:
|
block:
|
||||||
- import_tasks: create-service-directory.yml
|
- import_tasks: steps/create-service-directory.yml
|
||||||
- import_tasks: template-docker-compose.yml
|
- import_tasks: steps/template-docker-compose.yml
|
||||||
|
|
||||||
- name: Setting the service config path
|
- name: Setting the service config path
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
|
|
@ -21,4 +21,4 @@
|
||||||
dest: "{{ (config_path, 'config.cfg') | path_join }}"
|
dest: "{{ (config_path, 'config.cfg') | path_join }}"
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
|
|
||||||
- import_tasks: template-site-config.yml
|
- import_tasks: steps/template-site-config.yml
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,4 @@
|
||||||
- analytics
|
- analytics
|
||||||
- umami
|
- umami
|
||||||
block:
|
block:
|
||||||
- import_tasks: create-service-directory.yml
|
- import_tasks: deploy-common-service.yml
|
||||||
- import_tasks: template-docker-compose.yml
|
|
||||||
- import_tasks: template-service-env.yml
|
|
||||||
- import_tasks: template-site-config.yml
|
|
||||||
|
|
|
||||||
4
_ansible/tasks/deploy-common-service.yml
Normal file
4
_ansible/tasks/deploy-common-service.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
- import_tasks: steps/create-service-directory.yml
|
||||||
|
- import_tasks: steps/template-docker-compose.yml
|
||||||
|
- import_tasks: steps/template-service-env.yml
|
||||||
|
- import_tasks: steps/template-site-config.yml
|
||||||
9
_ansible/tasks/steps/create-service-directory.yml
Normal file
9
_ansible/tasks/steps/create-service-directory.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
- name: Setting the service path
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
service_path: "{{ (services_path, svc.name) | path_join }}"
|
||||||
|
|
||||||
|
- name: Create a service directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ service_path }}"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
5
_ansible/tasks/steps/template-docker-compose.yml
Normal file
5
_ansible/tasks/steps/template-docker-compose.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Template docker-compose
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: docker-compose.yml.j2
|
||||||
|
dest: "{{ (service_path, 'docker-compose.yml') | path_join }}"
|
||||||
|
mode: "0644"
|
||||||
5
_ansible/tasks/steps/template-service-env.yml
Normal file
5
_ansible/tasks/steps/template-service-env.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Template service.env file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: service.env.j2
|
||||||
|
dest: "{{ (service_path, 'service.env') | path_join }}"
|
||||||
|
mode: "0600"
|
||||||
5
_ansible/tasks/steps/template-site-config.yml
Normal file
5
_ansible/tasks/steps/template-site-config.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Template caddy config
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: caddy_site.conf.j2
|
||||||
|
dest: "{{ (caddy_config_path, svc.domain + '.conf') | path_join }}"
|
||||||
|
mode: "0644"
|
||||||
Reference in a new issue