summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Sedovic <tomas@sedovic.cz>2017-09-13 17:44:45 +0200
committerTomas Sedovic <tomas@sedovic.cz>2017-09-13 17:44:45 +0200
commit8a204aaec709135ebfa716459f2ba3bcf1db4f04 (patch)
tree4897fe7905a11fed34e471236f2a202f7f81effe
parentc478cfcd54bc89918bea21b9e47fcc9421bec568 (diff)
downloadopenshift-8a204aaec709135ebfa716459f2ba3bcf1db4f04.tar.gz
openshift-8a204aaec709135ebfa716459f2ba3bcf1db4f04.tar.bz2
openshift-8a204aaec709135ebfa716459f2ba3bcf1db4f04.tar.xz
openshift-8a204aaec709135ebfa716459f2ba3bcf1db4f04.zip
Clear the previous inventory during provisioning
If there was a left-over inventory from a previous run that had nodes which were subsequently removed, these would still show up in the Ansible's in-memory inventory and Ansible would fail trying to connect to them. This is because Ansible automatically loads the `inventory/hosts` file if it exists and even if we overwrite it later, every node and group still remains in the memory. By removing the inventory file and and calling the `refresh_inventory` meta task, we make sure that any left-over values are removed.
-rw-r--r--roles/static_inventory/tasks/main.yml8
1 files changed, 8 insertions, 0 deletions
diff --git a/roles/static_inventory/tasks/main.yml b/roles/static_inventory/tasks/main.yml
index 24e11beb6..3dab62df2 100644
--- a/roles/static_inventory/tasks/main.yml
+++ b/roles/static_inventory/tasks/main.yml
@@ -1,4 +1,12 @@
---
+- name: Remove any existing inventory
+ file:
+ path: "{{ inventory_path }}/hosts"
+ state: absent
+
+- name: Refresh the inventory
+ meta: refresh_inventory
+
- name: Generate in-memory inventory
include: openstack.yml