From 0c0ea09be77d77a2146e3c4a65dfa5d42b656178 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Tue, 29 Oct 2019 16:37:47 -0400 Subject: [PATCH] Remove old Heat hosts entries in tripleo-hosts-entries For upgrades, this role now takes care of removing the old Heat entries if they are present in /etc/hosts. The test prepare process has been updated to create a temp file that would replicate what we'd expect in a live system. Change-Id: Ifc4d9553b74e6e6a9794902b418f54c0cfc7a39d --- .../molecule/default/prepare.yml | 10 +++++++++- .../roles/tripleo-hosts-entries/tasks/main.yml | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tripleo_ansible/roles/tripleo-hosts-entries/molecule/default/prepare.yml b/tripleo_ansible/roles/tripleo-hosts-entries/molecule/default/prepare.yml index ef85c3128..50ae900dd 100644 --- a/tripleo_ansible/roles/tripleo-hosts-entries/molecule/default/prepare.yml +++ b/tripleo_ansible/roles/tripleo-hosts-entries/molecule/default/prepare.yml @@ -14,8 +14,16 @@ # License for the specific language governing permissions and limitations # under the License. - - name: Prepare hosts: all roles: - role: test_deps + post_tasks: + - name: Create temp host file + copy: + content: | + HEAT_HOSTS_START - Do not edit manually within this section! + 0.0.0.0 test test.domain.local + 0.0.0.1 test test.domain.local + HEAT_HOSTS_END + dest: "{{ tripleo_hosts_entries_hosts_path }}" diff --git a/tripleo_ansible/roles/tripleo-hosts-entries/tasks/main.yml b/tripleo_ansible/roles/tripleo-hosts-entries/tasks/main.yml index 22ad54a63..3cb975c32 100644 --- a/tripleo_ansible/roles/tripleo-hosts-entries/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo-hosts-entries/tasks/main.yml @@ -14,6 +14,19 @@ # License for the specific language governing permissions and limitations # under the License. + +- name: Remove old Heat hosts configuration (if present) + become: true + blockinfile: + state: absent + path: "{{ tripleo_hosts_entries_hosts_path }}" + block: "" + marker: "# {mark}" + marker_begin: "HEAT_HOSTS_START - Do not edit manually within this section!" + marker_end: "HEAT_HOSTS_END" + tags: + - tripleo_hosts_entries + - name: Update /etc/hosts become: true blockinfile: