From bc5f3aba90eaec8f04223c557a6caf88515a2aef Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Mon, 5 Mar 2018 17:05:54 +0000
Subject: [PATCH] Fix use of tags with overcloud post configure

When specifying tags with 'kayobe overcloud post configure --tags <tags>', the
expected plays typically do not run. This seems to be due to an ansible bug,
where if a dynamically created group is referenced before creation, it will
remain empty. See https://github.com/ansible/ansible/issues/20360.

This change works around this issue by modifying the name of the dynamic groups
used in the post configure playbooks to be unique to each playbook.

Fixes: #138
(cherry picked from commit 77a41a9d0a37acd2d4c25bd7d969d965a9552428)

Change-Id: I7a884f538cfeba9d6b4b990ec445b5ad6f914193
---
 .../overcloud-introspection-rules-dell-lldp-workaround.yml    | 4 ++--
 ansible/overcloud-introspection-rules.yml                     | 4 ++--
 ansible/overcloud-ipa-build.yml                               | 4 ++--
 ansible/overcloud-ipa-images.yml                              | 4 ++--
 ansible/provision-net.yml                                     | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/ansible/overcloud-introspection-rules-dell-lldp-workaround.yml b/ansible/overcloud-introspection-rules-dell-lldp-workaround.yml
index b3e1d7278..21bbcc967 100644
--- a/ansible/overcloud-introspection-rules-dell-lldp-workaround.yml
+++ b/ansible/overcloud-introspection-rules-dell-lldp-workaround.yml
@@ -16,10 +16,10 @@
   tasks:
     - name: Create controllers group with ironic enabled
       group_by:
-        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic | bool }}"
+        key: "controllers_for_introspection_rules_dell_lldp_workaround_{{ kolla_enable_ironic | bool }}"
 
 - name: Group controller hosts in systems requiring the workaround
-  hosts: controllers_with_ironic_enabled_True
+  hosts: controllers_for_introspection_rules_dell_lldp_workaround_True
   gather_facts: False
   tags:
     - introspection-rules
diff --git a/ansible/overcloud-introspection-rules.yml b/ansible/overcloud-introspection-rules.yml
index 3aa29c7fd..b18e50823 100644
--- a/ansible/overcloud-introspection-rules.yml
+++ b/ansible/overcloud-introspection-rules.yml
@@ -6,11 +6,11 @@
   tasks:
     - name: Create controllers group with ironic enabled
       group_by:
-        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic | bool }}"
+        key: "controllers_for_introspection_rules_{{ kolla_enable_ironic | bool }}"
 
 - name: Ensure introspection rules are registered in Ironic Inspector
   # Only required to run on a single host.
-  hosts: controllers_with_ironic_enabled_True[0]
+  hosts: controllers_for_introspection_rules_True[0]
   gather_facts: False
   tags:
     - introspection-rules
diff --git a/ansible/overcloud-ipa-build.yml b/ansible/overcloud-ipa-build.yml
index ce3ecb132..a63d1d2a8 100644
--- a/ansible/overcloud-ipa-build.yml
+++ b/ansible/overcloud-ipa-build.yml
@@ -11,10 +11,10 @@
   tasks:
     - name: Create controllers group with ironic enabled
       group_by:
-        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic | bool }}"
+        key: "controllers_for_ipa_build_{{ kolla_enable_ironic | bool }}"
 
 - name: Ensure Ironic Python Agent images are built and installed
-  hosts: controllers_with_ironic_enabled_True[0]
+  hosts: controllers_for_ipa_build_True[0]
   gather_facts: False
   tags:
     - ipa-build
diff --git a/ansible/overcloud-ipa-images.yml b/ansible/overcloud-ipa-images.yml
index e32829b25..0a2151edf 100644
--- a/ansible/overcloud-ipa-images.yml
+++ b/ansible/overcloud-ipa-images.yml
@@ -6,10 +6,10 @@
   tasks:
     - name: Create controllers group with ironic enabled
       group_by:
-        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic | bool }}"
+        key: "controllers_for_ipa_images_{{ kolla_enable_ironic | bool }}"
 
 - name: Ensure Ironic Python Agent (IPA) images are downloaded and registered
-  hosts: controllers_with_ironic_enabled_True[0]
+  hosts: controllers_for_ipa_images_True[0]
   gather_facts: False
   tags:
     - ipa-images
diff --git a/ansible/provision-net.yml b/ansible/provision-net.yml
index d33181d1f..113cae4de 100644
--- a/ansible/provision-net.yml
+++ b/ansible/provision-net.yml
@@ -6,11 +6,11 @@
   tasks:
     - name: Create controllers group with ironic enabled
       group_by:
-        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic | bool }}"
+        key: "controllers_for_provision_net_{{ kolla_enable_ironic | bool }}"
 
 - name: Ensure provisioning network and subnet are registered in neutron
   # Only required to run on a single host.
-  hosts: controllers_with_ironic_enabled_True[0]
+  hosts: controllers_for_provision_net_True[0]
   gather_facts: False
   tags:
     - provision-net