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
This commit is contained in:
Emilien Macchi 2020-01-07 15:31:38 -05:00
parent aca83763d7
commit ad818d540b
3 changed files with 44 additions and 8 deletions

View File

@ -92,3 +92,8 @@
include_tasks: delete.yml include_tasks: delete.yml
- name: "Create containers from {{ tripleo_container_manage_config }}" - name: "Create containers from {{ tripleo_container_manage_config }}"
include_tasks: create.yml 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. # under the License.
- name: "Async container create/run" - name: "Async container create/run"
async: 300 async: "{{ (not ansible_check_mode | bool) | ternary('300', omit) }}"
poll: 0 poll: "{{ (not ansible_check_mode | bool) | ternary('0', omit) }}"
register: create_async_results 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: "{{ batched_container_data | haskey(attribute='action', reverse=True) }}"
loop_control: loop_control:
loop_var: container_data loop_var: container_data
@ -75,7 +72,6 @@
register: create_async_poll_results register: create_async_poll_results
until: create_async_poll_results.finished until: create_async_poll_results.finished
retries: 30 retries: 30
# async and check mode don't work together
when: when:
- not ansible_check_mode|bool - not ansible_check_mode|bool
@ -87,6 +83,22 @@
{{ create_async_results.results | selectattr('changed', 'equalto', true) | {{ create_async_results.results | selectattr('changed', 'equalto', true) |
map(attribute='container_data') | list | list_of_keys }} 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" - name: "Print the list of containers which changed"
debug: debug:
var: containers_changed var: containers_changed

View File

@ -24,8 +24,8 @@
- name: "Async container exec" - name: "Async container exec"
command: command:
argv: "{{ lookup('dict', container_exec_data).value | container_exec_cmd(cli=tripleo_container_manage_cli) }}" argv: "{{ lookup('dict', container_exec_data).value | container_exec_cmd(cli=tripleo_container_manage_cli) }}"
async: 60 async: "{{ (not ansible_check_mode | bool) | ternary('60', omit) }}"
poll: 0 poll: "{{ (not ansible_check_mode | bool) | ternary('0', omit) }}"
register: exec_async_results register: exec_async_results
loop: "{{ batched_container_data | haskey(attribute='action', value='exec') }}" loop: "{{ batched_container_data | haskey(attribute='action', value='exec') }}"
loop_control: loop_control:
@ -42,3 +42,22 @@
until: exec_async_poll_results.finished until: exec_async_poll_results.finished
retries: 30 retries: 30
when: not ansible_check_mode|bool 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) }}"