From 67d4fdd2afe9b2f3a820a742894cd02d493f3ef9 Mon Sep 17 00:00:00 2001
From: Doug Szumski <doug@stackhpc.com>
Date: Thu, 12 Apr 2018 14:30:42 +0100
Subject: [PATCH] Do not create nova db user if database unchanged

This change prevents the task running if the database
has not been changed when a preconfigured external
database is not in use. This was the behaviour before
the preconfigured database feature was introduced.

Close-Bug: 1763375
Change-Id: I4f68905732dac75bc0deddab88047c9c0d7d65b5
---
 ansible/roles/nova/tasks/bootstrap.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ansible/roles/nova/tasks/bootstrap.yml b/ansible/roles/nova/tasks/bootstrap.yml
index 34a85d98f2..28172ff9f7 100644
--- a/ansible/roles/nova/tasks/bootstrap.yml
+++ b/ansible/roles/nova/tasks/bootstrap.yml
@@ -44,7 +44,9 @@
       database_password: "{{ nova_api_database_password }}"
   run_once: True
   delegate_to: "{{ groups['nova-api'][0] }}"
-  when: database.changed or not use_preconfigured_databases | bool
+  when:
+    - database.changed
+    - not use_preconfigured_databases | bool
 
 - include: bootstrap_service.yml
   when: database.changed or use_preconfigured_databases | bool