From e7dfd63bfc5cfba0117c410d418feaff0f7999f3 Mon Sep 17 00:00:00 2001 From: SamYaple Date: Mon, 1 Feb 2016 23:01:59 +0000 Subject: [PATCH] Create nova-api database This is a required patch. Kilo introduced a nova-api database but didn't use it. [1] Mitaka now uses it and has broken booting instances. [2] [1] https://wiki.openstack.org/wiki/ReleaseNotes/Kilo#OpenStack_Compute_.28Nova.29 [2] https://github.com/openstack/nova/blob/df0fca62cf5324f5b6eae0fed1f88c6c9ed61c71/releasenotes/notes/request-spec-api-db-b9cc6e0624d563c5.yaml Change-Id: If0a7f4ba4937fab8d60f5236ca00db06faa768c7 Closes-Bug: #1540579 --- ansible/roles/nova/defaults/main.yml | 3 ++ ansible/roles/nova/tasks/bootstrap.yml | 36 +++++++++++++++++++++++ ansible/roles/nova/templates/nova.conf.j2 | 3 ++ docker/nova/nova-api/extend_start.sh | 1 + etc/kolla/passwords.yml | 1 + 5 files changed, 44 insertions(+) diff --git a/ansible/roles/nova/defaults/main.yml b/ansible/roles/nova/defaults/main.yml index 9d1f0194b0..e98f061d54 100644 --- a/ansible/roles/nova/defaults/main.yml +++ b/ansible/roles/nova/defaults/main.yml @@ -21,6 +21,9 @@ nova_database_name: "nova" nova_database_user: "nova" nova_database_address: "{{ kolla_internal_address }}" +nova_api_database_name: "nova_api" +nova_api_database_user: "nova_api" +nova_api_database_address: "{{ kolla_internal_address }}" #################### # Docker diff --git a/ansible/roles/nova/tasks/bootstrap.yml b/ansible/roles/nova/tasks/bootstrap.yml index 9f874efd50..c9ed43175f 100644 --- a/ansible/roles/nova/tasks/bootstrap.yml +++ b/ansible/roles/nova/tasks/bootstrap.yml @@ -17,6 +17,24 @@ set_fact: database_created: "{{ (database.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}" +- name: Creating Nova-api database + command: docker exec -t kolla_ansible /usr/bin/ansible localhost + -m mysql_db + -a "login_host='{{ database_address }}' + login_user='{{ database_user }}' + login_password='{{ database_password }}' + name='{{ nova_api_database_name }}'" + register: database_api + changed_when: "{{ database_api.stdout.find('localhost | SUCCESS => ') != -1 and + (database_api.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}" + failed_when: database_api.stdout.split()[2] != 'SUCCESS' + run_once: True + delegate_to: "{{ groups['nova-api'][0] }}" + +- name: Reading json from variable + set_fact: + database_api_created: "{{ (database_api.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}" + - name: Creating Nova database user and setting permissions command: docker exec -t kolla_ansible /usr/bin/ansible localhost -m mysql_user @@ -35,6 +53,24 @@ run_once: True delegate_to: "{{ groups['nova-api'][0] }}" +- name: Creating Nova-api database user and setting permissions + command: docker exec -t kolla_ansible /usr/bin/ansible localhost + -m mysql_user + -a "login_host='{{ database_address }}' + login_user='{{ database_user }}' + login_password='{{ database_password }}' + name='{{ nova_api_database_name }}' + password='{{ nova_api_database_password }}' + host='%' + priv='{{ nova_api_database_name }}.*:ALL' + append_privs='yes'" + register: database_api_user_create + changed_when: "{{ database_api_user_create.stdout.find('localhost | SUCCESS => ') != -1 and + (database_api_user_create.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}" + failed_when: database_api_user_create.stdout.split()[2] != 'SUCCESS' + run_once: True + delegate_to: "{{ groups['nova-api'][0] }}" + - name: Running Nova bootstrap container kolla_docker: action: "start_container" diff --git a/ansible/roles/nova/templates/nova.conf.j2 b/ansible/roles/nova/templates/nova.conf.j2 index 3f6efe1834..f5021fdd7a 100644 --- a/ansible/roles/nova/templates/nova.conf.j2 +++ b/ansible/roles/nova/templates/nova.conf.j2 @@ -125,6 +125,9 @@ password = {{ neutron_keystone_password }} [database] connection = mysql+pymysql://{{ nova_database_user }}:{{ nova_database_password }}@{{ nova_database_address }}/{{ nova_database_name }} +[api_database] +connection = mysql+pymysql://{{ nova_api_database_user }}:{{ nova_api_database_password }}@{{ nova_api_database_address }}/{{ nova_api_database_name }} + [keystone_authtoken] auth_uri = http://{{ kolla_internal_address }}:{{ keystone_public_port }} auth_url = http://{{ kolla_internal_address }}:{{ keystone_admin_port }} diff --git a/docker/nova/nova-api/extend_start.sh b/docker/nova/nova-api/extend_start.sh index 93b63d53ff..c7bc9c8624 100644 --- a/docker/nova/nova-api/extend_start.sh +++ b/docker/nova/nova-api/extend_start.sh @@ -4,5 +4,6 @@ # of the KOLLA_BOOTSTRAP variable being set, including empty. if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then nova-manage db sync + nova-manage api_db sync exit 0 fi diff --git a/etc/kolla/passwords.yml b/etc/kolla/passwords.yml index 369053b0b4..050ec20863 100644 --- a/etc/kolla/passwords.yml +++ b/etc/kolla/passwords.yml @@ -33,6 +33,7 @@ glance_database_password: "password" glance_keystone_password: "password" nova_database_password: "password" +nova_api_database_password: "password" nova_keystone_password: "password" neutron_database_password: "password"