Merge "tripleo-container-manage: restart systemd service if container changed"

This commit is contained in:
Zuul 2019-11-18 22:29:23 +00:00 committed by Gerrit Code Review
commit e6ee13d191
3 changed files with 28 additions and 4 deletions

View File

@ -26,7 +26,8 @@ class FilterModule(object):
'singledict': self.singledict, 'singledict': self.singledict,
'subsort': self.subsort, 'subsort': self.subsort,
'needs_delete': self.needs_delete, 'needs_delete': self.needs_delete,
'haskey': self.haskey 'haskey': self.haskey,
'list_of_keys': self.list_of_keys
} }
def subsort(self, dict_to_sort, attribute, null_value=None): def subsort(self, dict_to_sort, attribute, null_value=None):
@ -169,3 +170,15 @@ class FilterModule(object):
if attribute not in v and reverse: if attribute not in v and reverse:
return_list.append({k: v}) return_list.append({k: v})
return return_list return return_list
def list_of_keys(self, keys_to_list):
"""Return a list of keys from a list of dictionaries.
This filter takes in input a list of dictionaries and for each of them
it will add the key to list_of_keys and returns it.
"""
list_of_keys = []
for i in keys_to_list:
for k, v in i.items():
list_of_keys.append(k)
return list_of_keys

View File

@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
# TODO(emilien) Re-add podman_container.changed from async
- name: "Async container create/run" - name: "Async container create/run"
async: 300 async: 300
poll: 0 poll: 0
@ -74,3 +73,16 @@
until: create_async_poll_results.finished until: create_async_poll_results.finished
retries: 30 retries: 30
when: not ansible_check_mode|bool when: not ansible_check_mode|bool
# This fact will be used in systemd playbook to figure out if whether or not
# a container managed by systemd needs to be restarted
- name: "Create a list of containers which changed"
set_fact:
containers_changed: >-
{{ create_async_results.results | selectattr('changed', 'equalto', true) |
map(attribute='container_data') | list | list_of_keys }}
- name: "Print the list of containers which changed"
debug:
var: containers_changed
when: tripleo_container_manage_debug | bool

View File

@ -52,8 +52,7 @@
enabled: true enabled: true
daemon_reload: true daemon_reload: true
when: when:
# Re-add podman_container.changed from async - systemd_file is changed or container_sysd_name in containers_changed
- systemd_file.changed
- name: "Manage systemd healthcheck for {{ container_sysd_name }}" - name: "Manage systemd healthcheck for {{ container_sysd_name }}"
when: when:
- not tripleo_container_manage_healthcheck_disabled - not tripleo_container_manage_healthcheck_disabled