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
This commit is contained in:
Markos Chandras 2018-09-28 14:12:40 +01:00
parent 6b4c019918
commit d771be8fb2
1 changed files with 2 additions and 0 deletions

View File

@ -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"