tripleo-container-manage: show podman commands that are executed

This patch will display the podman commands that are executed for debug
purpose, when check is enabled.
For each container, it'll show the command and also at the very end of
the playbook run, we display ALL commands that were run.

It's replacing the "paunch debug print-cmd" feature that we had with
paunch.

Note: it's disabling async on podman_container module because async +
check don't work together.

story: 2006732
task: 37310

Change-Id: Ic615dd45d8feec3806d5012685e4860d2361b95d
(cherry picked from commit ad818d540b)
This commit is contained in:
Emilien Macchi 2020-01-07 15:31:38 -05:00
parent bf6132bf5d
commit 7e99fe77e6
3 changed files with 44 additions and 8 deletions

View File

@ -93,3 +93,8 @@
include_tasks: delete.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 }}"
when:
- ansible_check_mode|bool

View File

@ -15,12 +15,9 @@
# under the License.
- name: "Async container create/run"
async: 300
poll: 0
async: "{{ (not ansible_check_mode | bool) | ternary('300', omit) }}"
poll: "{{ (not ansible_check_mode | bool) | ternary('0', omit) }}"
register: create_async_results
# async and check mode don't work together
when:
- not ansible_check_mode|bool
loop: "{{ batched_container_data | haskey(attribute='action', reverse=True) }}"
loop_control:
loop_var: container_data
@ -75,7 +72,6 @@
register: create_async_poll_results
until: create_async_poll_results.finished
retries: 30
# async and check mode don't work together
when:
- not ansible_check_mode|bool
@ -87,6 +83,22 @@
{{ create_async_results.results | selectattr('changed', 'equalto', true) |
map(attribute='container_data') | list | list_of_keys }}
- name: Block for container commands
when:
- ansible_check_mode|bool
block:
- name: "Create a list of podman commands that are run for containers with changes"
set_fact:
containers_commands: >-
{{ create_async_results.results | selectattr('changed', 'equalto', true) |
map(attribute='podman_actions') | default([]) | list }}
- name: "Print the list of commands that are run for containers with changes"
debug:
var: containers_commands
- name: "Append the list of all podman commands that are run for containers with changes"
set_fact:
all_containers_commands: "{{ containers_commands + (all_containers_commands | default([]) | list) }}"
- name: "Print the list of containers which changed"
debug:
var: containers_changed

View File

@ -24,8 +24,8 @@
- name: "Async container exec"
command:
argv: "{{ lookup('dict', container_exec_data).value | container_exec_cmd(cli=tripleo_container_manage_cli) }}"
async: 60
poll: 0
async: "{{ (not ansible_check_mode | bool) | ternary('60', omit) }}"
poll: "{{ (not ansible_check_mode | bool) | ternary('0', omit) }}"
register: exec_async_results
loop: "{{ batched_container_data | haskey(attribute='action', value='exec') }}"
loop_control:
@ -42,3 +42,22 @@
until: exec_async_poll_results.finished
retries: 30
when: not ansible_check_mode|bool
- name: Block for container commands
when:
- ansible_check_mode|bool
block:
- name: "Create a list of podman exec commands that are run"
set_fact:
containers_commands: >-
{{ (containers_commands | default([])) + ([lookup('dict', container_exec_data).value |
container_exec_cmd(cli=tripleo_container_manage_cli) | join(' ')]) }}
loop: "{{ batched_container_data | haskey(attribute='action', value='exec') }}"
loop_control:
loop_var: container_exec_data
- name: "Print the list of podman exec commands that are run"
debug:
var: containers_commands
- name: "Append the list of all podman commands that are run for containers with changes"
set_fact:
all_containers_commands: "{{ containers_commands + (all_containers_commands | default([]) | list) }}"