Add option to force-recreate containers on config change
This commit is contained in:
parent
570864c00f
commit
c32e305eb3
3 changed files with 10 additions and 2 deletions
|
@ -12,5 +12,12 @@
|
||||||
src: telegraf.conf.j2
|
src: telegraf.conf.j2
|
||||||
dest: "{{ (service_path, 'telegraf.conf') | path_join }}"
|
dest: "{{ (service_path, 'telegraf.conf') | path_join }}"
|
||||||
mode: "0664"
|
mode: "0664"
|
||||||
|
register: cmd_result
|
||||||
|
|
||||||
|
|
||||||
|
- name: Set the docker force-recreate flag
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
docker_force_recreate: "--force-recreate"
|
||||||
|
when: cmd_result.changed
|
||||||
|
|
||||||
- import_tasks: steps/start-service.yml
|
- import_tasks: steps/start-service.yml
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
- name: Setting the service path
|
- name: Set common facts
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
service_path: "{{ (services_path, svc.name) | path_join }}"
|
service_path: "{{ (services_path, svc.name) | path_join }}"
|
||||||
|
docker_force_recreate: ""
|
||||||
|
|
||||||
- name: Create a service directory
|
- name: Create a service directory
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
- name: Start service
|
- name: Start service
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: docker compose up -d
|
cmd: docker compose up -d {{ docker_force_recreate }}
|
||||||
chdir: "{{ service_path }}"
|
chdir: "{{ service_path }}"
|
||||||
when: "'local-dev' != inventory_hostname"
|
when: "'local-dev' != inventory_hostname"
|
||||||
register: cmd_result
|
register: cmd_result
|
||||||
|
|
Reference in a new issue