From 1fd3a3654df8d0ca09434a5dfd03a6da38fbc660 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Mon, 22 Jun 2020 13:38:40 -0400 Subject: [PATCH] Cleanup all container startup configs before generating the new ones Unlike the container puppet configs [1], we didn't have a mechanism that was purging the old configs previously generated by the container startup config tasks. It's problematic when some leftover configs are still on the host and not needed anymore. [1] https://opendev.org/openstack/tripleo-ansible/src/branch/master/tripleo_ansible/ansible_plugins/modules/container_puppet_config.py#L157-L159 Change-Id: I24dac79f2351a1ffd4e956584a80f623706cbd00 Closes-Bug: #1884537 (cherry picked from commit b1d3da8666880d70db9b588ed4b743b2aaaab914) --- common/container_startup_configs_tasks.yaml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/common/container_startup_configs_tasks.yaml b/common/container_startup_configs_tasks.yaml index 510e8c6a99..13f4376591 100644 --- a/common/container_startup_configs_tasks.yaml +++ b/common/container_startup_configs_tasks.yaml @@ -1,18 +1,23 @@ --- -- set_fact: - step_path: "{{ item.0 }}" -- name: "Create directory for {{ step_path }} container startup configs" +# TODO(emilien) convert this whole task in a module +# https://bugs.launchpad.net/tripleo/+bug/1884577 +- name: "Remove old {{ item.0 }} container startup configs" file: - path: "/var/lib/tripleo-config/container-startup-config/{{ step_path }}/" + path: "/var/lib/tripleo-config/container-startup-config/{{ item.0 }}" + state: absent + +- name: "Create directory for {{ item.0 }} container startup configs" + file: + path: "/var/lib/tripleo-config/container-startup-config/{{ item.0 }}/" mode: 0600 recurse: yes setype: svirt_sandbox_file_t -- name: "Creating container startup configs for {{ step_path }}" +- name: "Creating container startup configs for {{ item.0 }}" copy: content: "{{ startup_data.value | to_nice_json }}" - dest: "/var/lib/tripleo-config/container-startup-config/{{ step_path }}/{{ startup_data.key }}.json" + dest: "/var/lib/tripleo-config/container-startup-config/{{ item.0 }}/{{ startup_data.key }}.json" setype: container_file_t mode: 0600 no_log: true