tripleo_container_manage: continue to reduce tasks
1) shutdown: include tasks without a block. this should remove the stat
and include task; to only have one task that include the shutdown
playbook if needed.
2) Remove containers_changed tasks. This is not useful to restart a
container just because its podman_container resource changed.
when podman_container module applies a change to the container, this
one is already restarted.
3) Remove all_containers_commands tasks, there aren't needed. Ansible
output already provides the commands that are run via the
container_status module.
Change-Id: Ic625bc5dd7bbd964d36eab0a3f81eca31c533716
(cherry picked from commit ca8fae62e4
)
This commit is contained in:
parent
78c3a2ff9c
commit
df45398870
|
@ -57,11 +57,6 @@ options:
|
|||
description:
|
||||
- Whether or not we cleanup the old healthchecks with SystemD.
|
||||
type: boolean
|
||||
restart_containers:
|
||||
description:
|
||||
- List of container names to be restarted
|
||||
default: []
|
||||
type: list
|
||||
debug:
|
||||
default: false
|
||||
description:
|
||||
|
@ -356,25 +351,9 @@ class ActionModule(ActionBase):
|
|||
args = self._get_args()
|
||||
|
||||
container_config = args['container_config']
|
||||
restart_containers = args['restart_containers']
|
||||
self.systemd_healthchecks = args['systemd_healthchecks']
|
||||
self.debug = args['debug']
|
||||
|
||||
extra_restarts = []
|
||||
for c in restart_containers:
|
||||
s_path = os.path.join('/etc/systemd/system',
|
||||
'tripleo_{}.service'.format(c))
|
||||
service_stat = self._execute_module(
|
||||
module_name='stat',
|
||||
module_args=dict(path=s_path),
|
||||
task_vars=task_vars
|
||||
)
|
||||
if service_stat.get('stat', {}).get('exists', False):
|
||||
if self.debug:
|
||||
DISPLAY.display('Systemd unit file found for {}, the '
|
||||
'container will be restarted'.format(c))
|
||||
extra_restarts.append(c)
|
||||
|
||||
container_names = []
|
||||
for container in container_config:
|
||||
for name, config in container.items():
|
||||
|
@ -385,8 +364,7 @@ class ActionModule(ActionBase):
|
|||
changed_services = self._manage_units(container_config, task_vars)
|
||||
if len(changed_services) > 0:
|
||||
self._systemd_reload(task_vars)
|
||||
service_names = set(changed_services + extra_restarts)
|
||||
self._restart_services(service_names, task_vars)
|
||||
self._restart_services(changed_services, task_vars)
|
||||
|
||||
if self.systemd_healthchecks:
|
||||
healthchecks_to_restart = []
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
container_systemd:
|
||||
container_config: "{{ container_config }}"
|
||||
debug: "{{ tripleo_container_manage_debug | bool }}"
|
||||
restart_containers: "{{ containers_changed | default([]) }}"
|
||||
systemd_healthchecks: "{{ (not tripleo_container_manage_healthcheck_disabled | bool) }}"
|
||||
vars:
|
||||
container_config: "{{ all_containers_hash | dict_to_list | haskey(attribute='restart', value=['always','unless-stopped'], any=True) | default([]) }}"
|
||||
|
|
|
@ -63,18 +63,9 @@
|
|||
all_containers_hash: "{{ container_config_data.configs }}"
|
||||
|
||||
- name: "Manage systemd shutdown files"
|
||||
become: true
|
||||
include_tasks: shutdown.yml
|
||||
when:
|
||||
- tripleo_container_manage_systemd_order
|
||||
block:
|
||||
- name: Check if /usr/lib/systemd/system-preset/91-tripleo-container-shutdown.preset exists
|
||||
stat:
|
||||
path: /usr/lib/systemd/system-preset/91-tripleo-container-shutdown.preset
|
||||
register: tripleo_container_shutdown
|
||||
- name: Include tasks for systemd shutdown service
|
||||
include_tasks: shutdown.yml
|
||||
when:
|
||||
- not tripleo_container_shutdown.stat.exists
|
||||
- tripleo_container_manage_systemd_order|bool
|
||||
|
||||
- name: "Manage containers from {{ tripleo_container_manage_config }}"
|
||||
when:
|
||||
|
@ -90,8 +81,3 @@
|
|||
include_tasks: delete_orphan.yml
|
||||
- name: "Create containers from {{ tripleo_container_manage_config }}"
|
||||
include_tasks: create.yml
|
||||
- name: "Show all container commands for {{ tripleo_container_manage_config }}"
|
||||
debug:
|
||||
msg: "{{ all_containers_commands | default('No container action') }}"
|
||||
when:
|
||||
- ansible_check_mode|bool
|
||||
|
|
|
@ -102,15 +102,3 @@
|
|||
container_data: "{{ batched_container_data }}"
|
||||
valid_exit_codes: "{{ tripleo_container_manage_valid_exit_code }}"
|
||||
debug: "{{ tripleo_container_manage_debug | bool }}"
|
||||
register: container_status_results
|
||||
|
||||
- name: "Create fact for containers which changed"
|
||||
set_fact:
|
||||
# List of containers which have changed (created or updated)
|
||||
containers_changed: "{{ container_status_results.changed_containers | default([]) }}"
|
||||
|
||||
- name: "Append the list of all podman commands that are run for containers with changes"
|
||||
set_fact:
|
||||
all_containers_commands: "{{ container_status_results.commands | default([]) + (all_containers_commands | default([]) | list) }}"
|
||||
when:
|
||||
- ansible_check_mode|bool
|
||||
|
|
|
@ -54,10 +54,3 @@
|
|||
container_async_results: "{{ exec_async_poll_results.results }}"
|
||||
container_data: "{{ batched_container_data | haskey(attribute='action', value='exec') }}"
|
||||
debug: "{{ tripleo_container_manage_debug | bool }}"
|
||||
register: container_exec_status_results
|
||||
|
||||
- name: "Append the list of all podman commands with the containers execs"
|
||||
set_fact:
|
||||
all_containers_commands: "{{ container_status_results.commands | default([]) + (all_containers_commands | default([]) | list) }}"
|
||||
when:
|
||||
- ansible_check_mode|bool
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
- /usr/lib/systemd/system-preset/91-paunch-container-shutdown.preset
|
||||
|
||||
- name: Create TripleO Container systemd service
|
||||
become: true
|
||||
block:
|
||||
- name: "Deploy tripleo-container-shutdown and tripleo-start-podman-container"
|
||||
copy:
|
||||
|
|
Loading…
Reference in New Issue