From c33d2a4e0e9644acff4bc8d5be95ff94e0def9da Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Mon, 13 Nov 2017 19:15:48 +0000
Subject: [PATCH] Don't run baremetal compute tasks when ironic is disabled

This includes:
* Building and registering IPA images
* Registering a provisioning network
* Registering ironic inspector introspection rules
* Creating an inspection store container
---
 ansible/group_vars/all/inspector              |  2 +-
 ansible/kolla-openstack.yml                   | 24 ++++++++++---------
 ...trospection-rules-dell-lldp-workaround.yml | 11 ++++++++-
 ansible/overcloud-introspection-rules.yml     | 10 +++++++-
 ansible/overcloud-ipa-build.yml               | 10 +++++++-
 ansible/overcloud-ipa-images.yml              | 10 +++++++-
 ansible/provision-net.yml                     | 10 +++++++-
 7 files changed, 60 insertions(+), 17 deletions(-)

diff --git a/ansible/group_vars/all/inspector b/ansible/group_vars/all/inspector
index 463f22ed..422f5971 100644
--- a/ansible/group_vars/all/inspector
+++ b/ansible/group_vars/all/inspector
@@ -323,7 +323,7 @@ inspector_dell_switch_lldp_workaround_group:
 # data which may be useful in environments without Swift.
 
 # Whether the inspection data store is enabled.
-inspector_store_enabled: "{{ not kolla_enable_swift | bool }}"
+inspector_store_enabled: "{{ kolla_enable_ironic | bool and not kolla_enable_swift | bool }}"
 
 # Port on which the inspection data store should listen.
 inspector_store_port: 8080
diff --git a/ansible/kolla-openstack.yml b/ansible/kolla-openstack.yml
index 71c5765b..5045a1a7 100644
--- a/ansible/kolla-openstack.yml
+++ b/ansible/kolla-openstack.yml
@@ -1,6 +1,6 @@
 ---
 
-- name: Ensure Ironic is enabled
+- name: Check whether Ironic is enabled
   hosts: controllers
   tasks:
     - name: Create controllers group with ironic enabled
@@ -146,17 +146,19 @@
               }}
           with_items: "{{ kolla_neutron_ml2_generic_switch_hosts }}"
 
-        - name: Set facts containing IPA kernel and ramdisk URLs
-          set_fact:
-            kolla_inspector_ipa_kernel_upstream_url: "{{ inspector_ipa_kernel_upstream_url }}"
-            kolla_inspector_ipa_ramdisk_upstream_url: "{{ inspector_ipa_ramdisk_upstream_url }}"
-          when: not ipa_build_images | bool
+        - block:
+            - name: Set facts containing IPA kernel and ramdisk URLs
+              set_fact:
+                kolla_inspector_ipa_kernel_upstream_url: "{{ inspector_ipa_kernel_upstream_url }}"
+                kolla_inspector_ipa_ramdisk_upstream_url: "{{ inspector_ipa_ramdisk_upstream_url }}"
+              when: not ipa_build_images | bool
 
-        - name: Set facts containing IPA kernel and ramdisk paths
-          set_fact:
-            kolla_inspector_ipa_kernel_path: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ ipa_images_kernel_name }}"
-            kolla_inspector_ipa_ramdisk_path: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ ipa_images_ramdisk_name }}"
-          when: ipa_build_images | bool
+            - name: Set facts containing IPA kernel and ramdisk paths
+              set_fact:
+                kolla_inspector_ipa_kernel_path: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ ipa_images_kernel_name }}"
+                kolla_inspector_ipa_ramdisk_path: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ ipa_images_ramdisk_name }}"
+              when: ipa_build_images | bool
+          when: kolla_enable_ironic | bool
       tags:
         - config
   roles:
diff --git a/ansible/overcloud-introspection-rules-dell-lldp-workaround.yml b/ansible/overcloud-introspection-rules-dell-lldp-workaround.yml
index 3d369433..ac44d501 100644
--- a/ansible/overcloud-introspection-rules-dell-lldp-workaround.yml
+++ b/ansible/overcloud-introspection-rules-dell-lldp-workaround.yml
@@ -8,8 +8,16 @@
 # each ironic node that matches against the switch system and the relevant
 # interface name, then sets the node's name appropriately.
 
-- name: Group controller hosts in systems requiring the workaround
+- name: Check whether Ironic is enabled
   hosts: controllers
+  tasks:
+    - name: Create controllers group with ironic enabled
+      group_by:
+        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic }}"
+
+- name: Group controller hosts in systems requiring the workaround
+  hosts: controllers_with_ironic_enabled_True
+  gather_facts: False
   tasks:
     - name: Group controller hosts in systems requiring the Dell switch LLDP workaround
       group_by:
@@ -18,6 +26,7 @@
 - name: Ensure introspection rules for Dell switch LLDP workarounds are registered in Ironic Inspector
   # Only required to run on a single host.
   hosts: controllers_require_workaround_True[0]
+  gather_facts: False
   vars:
     all_switch_interfaces: []
     ironic_inspector_rules: []
diff --git a/ansible/overcloud-introspection-rules.yml b/ansible/overcloud-introspection-rules.yml
index bbb88e8b..502373e1 100644
--- a/ansible/overcloud-introspection-rules.yml
+++ b/ansible/overcloud-introspection-rules.yml
@@ -1,7 +1,15 @@
 ---
+- name: Check whether Ironic is enabled
+  hosts: controllers
+  tasks:
+    - name: Create controllers group with ironic enabled
+      group_by:
+        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic }}"
+
 - name: Ensure introspection rules are registered in Ironic Inspector
   # Only required to run on a single host.
-  hosts: controllers[0]
+  hosts: controllers_with_ironic_enabled_True[0]
+  gather_facts: False
   vars:
     venv: "{{ virtualenv_path }}/shade"
   pre_tasks:
diff --git a/ansible/overcloud-ipa-build.yml b/ansible/overcloud-ipa-build.yml
index ab38300a..587a8b46 100644
--- a/ansible/overcloud-ipa-build.yml
+++ b/ansible/overcloud-ipa-build.yml
@@ -4,8 +4,16 @@
 #
 # The images will be stored in {{ image_cache_path }}/{{ ipa_image_name }}.
 
+- name: Check whether Ironic is enabled
+  hosts: controllers
+  tasks:
+    - name: Create controllers group with ironic enabled
+      group_by:
+        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic }}"
+
 - name: Ensure Ironic Python Agent images are built and installed
-  hosts: controllers[0]
+  hosts: controllers_with_ironic_enabled_True[0]
+  gather_facts: False
   vars:
     ipa_image_name: "ipa"
   tasks:
diff --git a/ansible/overcloud-ipa-images.yml b/ansible/overcloud-ipa-images.yml
index 7d59fb15..488ea66c 100644
--- a/ansible/overcloud-ipa-images.yml
+++ b/ansible/overcloud-ipa-images.yml
@@ -1,6 +1,14 @@
 ---
+- name: Check whether Ironic is enabled
+  hosts: controllers
+  tasks:
+    - name: Create controllers group with ironic enabled
+      group_by:
+        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic }}"
+
 - name: Ensure Ironic Python Agent (IPA) images are downloaded and registered
-  hosts: controllers[0]
+  hosts: controllers_with_ironic_enabled_True[0]
+  gather_facts: False
   vars:
     # These are the filenames generated by overcloud-ipa-build.yml.
     ipa_image_name: "ipa"
diff --git a/ansible/provision-net.yml b/ansible/provision-net.yml
index aceb1417..7fe84421 100644
--- a/ansible/provision-net.yml
+++ b/ansible/provision-net.yml
@@ -1,7 +1,15 @@
 ---
+- name: Check whether Ironic is enabled
+  hosts: controllers
+  tasks:
+    - name: Create controllers group with ironic enabled
+      group_by:
+        key: "controllers_with_ironic_enabled_{{ kolla_enable_ironic }}"
+
 - name: Ensure provisioning network and subnet are registered in neutron
   # Only required to run on a single host.
-  hosts: controllers[0]
+  hosts: controllers_with_ironic_enabled_True[0]
+  gather_facts: False
   pre_tasks:
     - name: Validate OpenStack password authentication parameters
       fail:
-- 
GitLab