Browse Source

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

tags/1.0.0
Zuul 2 weeks ago
parent
commit
e6ee13d191
3 changed files with 28 additions and 4 deletions
  1. +14
    -1
      tripleo_ansible/ansible_plugins/filter/helpers.py
  2. +13
    -1
      tripleo_ansible/roles/tripleo-container-manage/tasks/podman/create.yml
  3. +1
    -2
      tripleo_ansible/roles/tripleo-container-manage/tasks/podman/systemd.yml

+ 14
- 1
tripleo_ansible/ansible_plugins/filter/helpers.py View File

@@ -26,7 +26,8 @@ class FilterModule(object):
'singledict': self.singledict,
'subsort': self.subsort,
'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):
@@ -169,3 +170,15 @@ class FilterModule(object):
if attribute not in v and reverse:
return_list.append({k: v})
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

+ 13
- 1
tripleo_ansible/roles/tripleo-container-manage/tasks/podman/create.yml View File

@@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.

# TODO(emilien) Re-add podman_container.changed from async
- name: "Async container create/run"
async: 300
poll: 0
@@ -74,3 +73,16 @@
until: create_async_poll_results.finished
retries: 30
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

+ 1
- 2
tripleo_ansible/roles/tripleo-container-manage/tasks/podman/systemd.yml View File

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

Loading…
Cancel
Save