containerRestart1

This commit is contained in:
Cory Hawkless 2021-06-17 01:53:42 +09:30
parent eb0372ded4
commit 24d69d8d66
1 changed files with 31 additions and 3 deletions

View File

@ -81,6 +81,10 @@
when: templates_Defined ==1 and outer_item.value.generic is not defined when: templates_Defined ==1 and outer_item.value.generic is not defined
register: fileChanged register: fileChanged
tags: always tags: always
- name: Set the flag to restart the container if file was changed
set_fact: containerRestart='yes'
when: fileChanged is defined and fileChanged.changed
tags: always
#Copy templates form a generic dir, allow ansible to search #Copy templates form a generic dir, allow ansible to search
- name: "Generic template mappings for {{ container_Name }}" - name: "Generic template mappings for {{ container_Name }}"
@ -93,6 +97,10 @@
when: templates_Defined ==1 and outer_item.value.generic is defined when: templates_Defined ==1 and outer_item.value.generic is defined
register: fileChanged register: fileChanged
tags: always tags: always
- name: Set the flag to restart the container if file was changed
set_fact: containerRestart='yes'
when: fileChanged is defined and fileChanged.changed
tags: always
- name: Append templated files to the mapping list - name: Append templated files to the mapping list
set_fact: set_fact:
@ -135,6 +143,10 @@
when: files_Defined == 1 and outer_item.value.generic is not defined and outer_item.value.src_text is not defined when: files_Defined == 1 and outer_item.value.generic is not defined and outer_item.value.src_text is not defined
register: fileChanged register: fileChanged
tags: always tags: always
- name: Set the flag to restart the container if file was changed
set_fact: containerRestart='yes'
when: fileChanged is defined and fileChanged.changed
tags: always
#Copy files from a generic dir, allow ansible to search #Copy files from a generic dir, allow ansible to search
- name: "Generic File mappings for {{ container_Name }}" - name: "Generic File mappings for {{ container_Name }}"
#Files will be copied to the 'config' dir as defined by container_configDir, they will be stored using their file name #Files will be copied to the 'config' dir as defined by container_configDir, they will be stored using their file name
@ -146,6 +158,11 @@
when: files_Defined == 1 and outer_item.value.generic is defined and outer_item.value.src_text is not defined when: files_Defined == 1 and outer_item.value.generic is defined and outer_item.value.src_text is not defined
register: fileChanged register: fileChanged
tags: always tags: always
- name: Set the flag to restart the container if file was changed
set_fact: containerRestart='yes'
when: fileChanged is defined and fileChanged.changed
tags: always
#Create files based on the suplied src_text param #Create files based on the suplied src_text param
- name: "Text based file creation for {{ container_Name }}" - name: "Text based file creation for {{ container_Name }}"
#Files will be copied to the 'config' dir as defined by container_configDir, they will be stored using their file name #Files will be copied to the 'config' dir as defined by container_configDir, they will be stored using their file name
@ -157,6 +174,10 @@
when: files_Defined == 1 and outer_item.value.src_text is defined when: files_Defined == 1 and outer_item.value.src_text is defined
register: fileChanged register: fileChanged
tags: always tags: always
- name: Set the flag to restart the container if file was changed
set_fact: containerRestart='yes'
when: fileChanged is defined and fileChanged.changed
tags: always
- name: Append static remote files to the mapping list - name: Append static remote files to the mapping list
set_fact: set_fact:
@ -199,6 +220,12 @@
when: local_Defined == 1 when: local_Defined == 1
register: fileChanged register: fileChanged
tags: always tags: always
- name: Set the flag to restart the container if file was changed
set_fact: containerRestart='yes'
when: fileChanged is defined and fileChanged.changed
tags: always
#----------------------------------/LOCAL---------------------------------- #----------------------------------/LOCAL----------------------------------
@ -215,8 +242,9 @@
#----------------------------------/Check ENV---------------------------------- #----------------------------------/Check ENV----------------------------------
- name: Restart the container if fileChanged is defined - name: Restart the container if fileChanged is defined
set_fact: item.value.restart='yes' set_fact: containerRestart1='yes'
when: fileChanged is defined when: (containerRestart is defined and containerRestart=='yes') or (item.value.restart is defined and item.value.restart =='yes')
- name: "Container {{ container_Name }}" - name: "Container {{ container_Name }}"
@ -229,7 +257,7 @@
recreate: "{{ item.value.recreate | default('false') }}" recreate: "{{ item.value.recreate | default('false') }}"
image: "{{ item.value.image }}" image: "{{ item.value.image }}"
state: "{{ item.value.start | default ('started') }}" state: "{{ item.value.start | default ('started') }}"
restart: "{{ item.value.restart | default ('no') }}" restart: "{{ containerRestart1 | default ('no') }}"
restart_policy: "{{ item.value.restart_policy | default ('always') }}" restart_policy: "{{ item.value.restart_policy | default ('always') }}"
purge_networks: "{{ item.value.purge_networks | default ('yes') }}" purge_networks: "{{ item.value.purge_networks | default ('yes') }}"
networks: "{{ net_checked }}" networks: "{{ net_checked }}"