From e5edf98266a3c679b99bc0ca497291590acce715 Mon Sep 17 00:00:00 2001
From: caoyuan <cao.yuan@99cloud.net>
Date: Wed, 11 Oct 2017 10:36:36 +0800
Subject: [PATCH] Add the ironic_dnsmasq_dhcp_range prechecks for Ironic
 Dnsmasq

When deploy ironic, the ironic_dnsmasq keep restaring if
ironic_dnsmasq_dhcp_range is missing, so it necessary to add a
prechecks to ensure it be set.

Change-Id: I0c1d91f62f4e5dad2d9a45a2a7bb51b5121dbfda
---
 ansible/roles/ironic/tasks/precheck.yml | 9 +++++++++
 etc/kolla/globals.yml                   | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ansible/roles/ironic/tasks/precheck.yml b/ansible/roles/ironic/tasks/precheck.yml
index 1ad15ae229..52f6b50225 100644
--- a/ansible/roles/ironic/tasks/precheck.yml
+++ b/ansible/roles/ironic/tasks/precheck.yml
@@ -41,3 +41,12 @@
   with_items:
     - "ironic-agent.kernel"
     - "ironic-agent.initramfs"
+
+- name: Ensure dnsmasq_dhcp_range configured for Ironic Dnsmasq
+  fail:
+    msg: >
+      ironic_dnsmasq_dhcp_range must be set when enable ironic
+  connection: local
+  run_once: True
+  when:
+    - ironic_dnsmasq_dhcp_range is none
diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml
index 94528b8132..6062082167 100644
--- a/etc/kolla/globals.yml
+++ b/etc/kolla/globals.yml
@@ -359,7 +359,9 @@ kolla_internal_vip_address: "10.10.10.254"
 #############################
 # Ironic options
 #############################
-#ironic_dnsmasq_dhcp_range:
+# following value must be set when enable ironic, the value format
+# is "192.168.0.10,192.168.0.100".
+ironic_dnsmasq_dhcp_range:
 
 ######################################
 # Manila - Shared File Systems Options