tripleo-container-manage: few improvements

- Add and use variables to make the role more flexible:
  tripleo_container_manage_config,
  tripleo_container_manage_config_id
  tripleo_container_manage_debug
  tripleo_container_manage_config_pattern (and rename hashed_files var)

  With these vars, the role can pretty much be used outside of TripleO.

- Show logs of config data generation if debug is enabled

- Do not run the "podman exec" tasks in check mode

- Remove the dependency on the "step" variable

Change-Id: I28ee31b723f27c392f880676aaae9368906cf45f
This commit is contained in:
Emilien Macchi 2019-10-29 11:16:36 +01:00 committed by Kevin Carter
parent 52e43017bf
commit 9c69840640
3 changed files with 14 additions and 9 deletions

View File

@ -19,5 +19,9 @@
# All variables within this role should have a prefix of "tripleo_container_manage"
tripleo_container_manage_cli: podman
tripleo_container_manage_log_path: '/var/log/containers/stdouts'
tripleo_container_manage_config: "/var/lib/tripleo-config/"
tripleo_container_manage_config_id: tripleo
tripleo_container_manage_config_patterns: 'hashed-*.json'
tripleo_container_manage_debug: false
tripleo_container_manage_healthcheck_disabled: false
tripleo_container_manage_log_path: '/var/log/containers/stdouts'

View File

@ -41,14 +41,14 @@
become: true
- name: Generate containers configs data
no_log: true
no_log: "{{ false if tripleo_container_manage_debug else true }}"
block:
- name: "Find all hashed configs configs for step {{ step }}"
- name: "Find all matching configs configs for in {{ tripleo_container_manage_config }}"
find:
paths: "/var/lib/tripleo-config/container-startup-config/step_{{ step }}"
patterns: 'hashed-*.json'
register: hashed_files
- name: "Read config for each container at step {{ step }}"
paths: "{{ tripleo_container_manage_config }}"
patterns: "{{ tripleo_container_manage_config_patterns }}"
register: matched_files
- name: "Read config for each container in {{ tripleo_container_manage_config }}"
slurp:
src: "{{ item.path }}"
register: containers_data
@ -72,6 +72,6 @@
- tripleo_container_manage_cli == 'podman'
become: true
block:
- name: "Manage Podman containers at step {{ step }}"
- name: "Manage Podman containers in {{ tripleo_container_manage_config }}"
include_tasks: podman.yaml
loop: "{{ all_containers_hash | subsort(attribute='start_order', null_value=0) }}"

View File

@ -15,6 +15,7 @@
# under the License.
- name: "Execute a command within a running container for {{ item.0 }}"
check_mode: false
when:
- item.1.action is defined
- item.1.action == 'exec'
@ -61,7 +62,7 @@
interactive: "{{ item.1.interactive | default(false) }}"
ipc: "{{ item.1.ipc | default(omit) }}"
label:
config_id: "tripleo_step{{ step }}"
config_id: "{{ tripleo_container_manage_config_id }}"
container_name: "{{ item.0 }}"
managed_by: tripleo_ansible
config_data: "{{ item.1 | to_json }}"