diff --git a/defaults/main.yml b/defaults/main.yml index 1e1c609c..b31a94c1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -53,6 +53,13 @@ nova_db_max_overflow: 10 nova_db_max_pool_size: 120 nova_db_pool_timeout: 30 +## DB API +nova_api_galera_user: nova_api +nova_api_galera_database: nova_api +nova_api_db_max_overflow: 10 +nova_api_db_max_pool_size: 120 +nova_api_db_pool_timeout: 30 + ## RabbitMQ info nova_rabbitmq_userid: nova nova_rabbitmq_vhost: /nova diff --git a/tasks/nova_db_setup.yml b/tasks/nova_db_setup.yml index f9880f20..9d62d291 100644 --- a/tasks/nova_db_setup.yml +++ b/tasks/nova_db_setup.yml @@ -39,6 +39,32 @@ tags: - nova-db-setup +- name: Create API DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ nova_api_galera_address }}" + name: "{{ nova_api_galera_database }}" + state: "present" + tags: + - nova-db-setup + +- name: Grant access to the API DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ nova_api_galera_address }}" + name: "{{ nova_api_galera_user }}" + password: "{{ nova_api_container_mysql_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ nova_api_galera_database }}.*:ALL" + with_items: + - "localhost" + - "%" + tags: + - nova-db-setup + - name: Perform a Nova DB sync command: "{{ nova_bin }}/nova-manage db sync" become: yes @@ -47,3 +73,12 @@ - nova-db-setup - nova-setup - nova-command-bin + +- name: Perform a Nova API DB sync + command: "{{ nova_bin }}/nova-manage api_db sync" + become: yes + become_user: "{{ nova_system_user_name }}" + tags: + - nova-db-setup + - nova-setup + - nova-command-bin diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index 2c558667..5d495559 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -208,12 +208,19 @@ memcache_secret_key = {{ memcached_encryption_key }} check_revocations_for_cached = False -{% if inventory_hostname not in groups['nova_compute'] %} +{% if inventory_hostname in (groups['nova_conductor'] + groups['nova_scheduler'] + groups['nova_api_os_compute'] + groups['nova_api_metadata']) %} [database] connection = mysql+pymysql://{{ nova_galera_user }}:{{ nova_container_mysql_password }}@{{ nova_galera_address }}/{{ nova_galera_database }}?charset=utf8 max_overflow = {{ nova_db_max_overflow }} max_pool_size = {{ nova_db_max_pool_size }} pool_timeout = {{ nova_db_pool_timeout }} + + +[api_database] +connection = mysql+pymysql://{{ nova_api_galera_user }}:{{ nova_api_container_mysql_password }}@{{ nova_api_galera_address }}/{{ nova_api_galera_database }}?charset=utf8 +max_overflow = {{ nova_api_db_max_overflow }} +max_pool_size = {{ nova_api_db_max_pool_size }} +pool_timeout = {{ nova_api_db_pool_timeout }} {% endif %}