From d771be8fb209c9bfc1d993e19f8ce6161ae2428c Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Fri, 28 Sep 2018 14:12:40 +0100 Subject: [PATCH] tasks: neutron_db_setup: Only create the DB from the first neutron server The DB creation task should only be executed once and ideally from a single neutron-server host otherwise it's possible to hit a race condition where multiple neutron server hosts try to create the same DB at the same time and only one will eventually succeed leading to task failures such as the following one: TASK [os_neutron : Create DB for service] ************************************** changed: [server2] fatal: [server1]: FAILED! => {...} Change-Id: I803c90f78bb0bfcccd8bc4c0c76db0755b2ddf32 --- tasks/neutron_db_setup.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/neutron_db_setup.yml b/tasks/neutron_db_setup.yml index 9c188eb1..99df6f94 100644 --- a/tasks/neutron_db_setup.yml +++ b/tasks/neutron_db_setup.yml @@ -22,6 +22,7 @@ state: "present" delegate_to: "{{ neutron_db_setup_host }}" no_log: True + when: "inventory_hostname == ((groups[neutron_services['neutron-server']['group']]| intersect(ansible_play_hosts)) | list)[0]" - name: Grant access to the DB for the service mysql_user: @@ -38,6 +39,7 @@ - "localhost" - "%" no_log: True + when: "inventory_hostname == ((groups[neutron_services['neutron-server']['group']]| intersect(ansible_play_hosts)) | list)[0]" - name: Perform a DB expand command: "{{ neutron_bin }}/neutron-db-manage upgrade --expand"