From 681e24d27dc0b11215bd455d52b80a044e9f6a0d Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Wed, 12 Sep 2018 15:06:39 -0700
Subject: [PATCH] Treat unparsed inventory as a failure

We don't want to run ansible if we don't get a complete inventory from
our clouds. The reason for this is we cannot be sure that the ordering
of git servers, gerrit, and zuul or our serialized updates of afs
servers will work correctly if we have an incomplete inventory.

Instead we just want ansible to fail and try again in the future (we can
then debug why our clouds are not working).

From the ansible docs for any_unparsed_is_failed:

  If 'true', it is a fatal error when any given inventory source
  cannot be successfully parsed by any available inventory plugin;
  otherwise, this situation only attracts a warning.

Additionally we tell openstack inventory plugin to report failures
rather than empty inventory so that the unparsed failures happen.

Change-Id: I9025776af4316fbdd2c910566883eb3a2530852a
---
 inventory/openstack.yaml                          | 1 +
 playbooks/roles/install-ansible/files/ansible.cfg | 1 +
 2 files changed, 2 insertions(+)

diff --git a/inventory/openstack.yaml b/inventory/openstack.yaml
index 1771881612..fd66a913cf 100644
--- a/inventory/openstack.yaml
+++ b/inventory/openstack.yaml
@@ -1,2 +1,3 @@
 plugin: openstack
 cache: True
+fail_on_errors: True
diff --git a/playbooks/roles/install-ansible/files/ansible.cfg b/playbooks/roles/install-ansible/files/ansible.cfg
index b384ae508c..3551ee88a7 100644
--- a/playbooks/roles/install-ansible/files/ansible.cfg
+++ b/playbooks/roles/install-ansible/files/ansible.cfg
@@ -17,6 +17,7 @@ enable_plugins=openstack,constructed,yaml,advanced_host_list,ini
 cache=True
 cache_plugin=jsonfile
 cache_connection=/var/cache/ansible/inventory
+any_unparsed_is_failed=True
 
 [ssh_connection]
 retries=3