From 9c69840640261783cf7940c3e66a96608ba0ff77 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 29 Oct 2019 11:16:36 +0100 Subject: [PATCH] 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 --- .../tripleo-container-manage/defaults/main.yml | 6 +++++- .../roles/tripleo-container-manage/tasks/main.yml | 14 +++++++------- .../tripleo-container-manage/tasks/podman.yaml | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tripleo_ansible/roles/tripleo-container-manage/defaults/main.yml b/tripleo_ansible/roles/tripleo-container-manage/defaults/main.yml index e43f236ae..902c7731c 100644 --- a/tripleo_ansible/roles/tripleo-container-manage/defaults/main.yml +++ b/tripleo_ansible/roles/tripleo-container-manage/defaults/main.yml @@ -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' diff --git a/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml b/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml index 5c8376a3d..d93047341 100644 --- a/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml @@ -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) }}" diff --git a/tripleo_ansible/roles/tripleo-container-manage/tasks/podman.yaml b/tripleo_ansible/roles/tripleo-container-manage/tasks/podman.yaml index e959092ee..26a6ce42b 100644 --- a/tripleo_ansible/roles/tripleo-container-manage/tasks/podman.yaml +++ b/tripleo_ansible/roles/tripleo-container-manage/tasks/podman.yaml @@ -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 }}"