From cff6ea0533b52cc310f75e08599de26f4a4c0be4 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 10 May 2016 21:58:00 -0500 Subject: [PATCH] Added the DB and DB user create to the plays All of the database and database user creates have been removed from the roles into the playbooks. This allows the roles to be tested independently of the deployed database and also allows the toles to be used independently of infrastructure choices made by the integrated OSA project. Change-Id: If58e482034a65c0e50241448dbe298a73c1ae71b Signed-off-by: Kevin Carter --- playbooks/os-cinder-install.yml | 32 +++++++++- playbooks/os-glance-install.yml | 32 +++++++++- playbooks/os-heat-install.yml | 32 +++++++++- playbooks/os-horizon-install.yml | 32 +++++++++- playbooks/os-ironic-install.yml | 63 +++++++++--------- playbooks/os-keystone-install.yml | 6 +- playbooks/os-neutron-install.yml | 32 +++++++++- playbooks/os-nova-install.yml | 64 ++++++++++++++++++- ...-create-in-playbooks-6fb8232da53fe1e1.yaml | 8 +++ 9 files changed, 262 insertions(+), 39 deletions(-) create mode 100644 releasenotes/notes/db-create-in-playbooks-6fb8232da53fe1e1.yaml diff --git a/playbooks/os-cinder-install.yml b/playbooks/os-cinder-install.yml index 0a54351ca9..302d1d3e16 100644 --- a/playbooks/os-cinder-install.yml +++ b/playbooks/os-cinder-install.yml @@ -143,6 +143,34 @@ tags: - cinder-rabbitmq - cinder-rabbitmq-user + - name: Create DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ cinder_galera_address }}" + name: "{{ cinder_galera_database }}" + state: "present" + when: inventory_hostname == groups['cinder_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + tags: + - mysql-db-setup + - name: Grant access to the DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ cinder_galera_address }}" + name: "{{ cinder_galera_user }}" + password: "{{ cinder_container_mysql_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ cinder_galera_database }}.*:ALL" + when: inventory_hostname == groups['cinder_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + with_items: + - "localhost" + - "%" + tags: + - mysql-db-setup - name: Set cinder storage bridge (is_metal) set_fact: storage_bridge: "{{ 'ansible_' + hostvars[inventory_hostname]['container_networks']['storage_address']['bridge'] | replace('-', '_') }}" @@ -187,7 +215,6 @@ - role: "os_cinder" cinder_venv_tag: "{{ openstack_release }}" cinder_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/cinder-{{ openstack_release }}.tgz" - cinder_galera_address: "{{ internal_lb_vip_address }}" cinder_management_address: "{{ ansible_ssh_host }}" cinder_glance_host: "{{ internal_lb_vip_address }}" cinder_glance_service_port: "{{ glance_service_port }}" @@ -211,6 +238,9 @@ vars: galera_address: "{{ internal_lb_vip_address }}" is_metal: "{{ properties.is_metal|default(false) }}" + cinder_galera_user: cinder + cinder_galera_database: cinder + cinder_galera_address: "{{ galera_address }}" cinder_rabbitmq_userid: cinder cinder_rabbitmq_vhost: /cinder cinder_rabbitmq_servers: "{{ rabbitmq_servers }}" diff --git a/playbooks/os-glance-install.yml b/playbooks/os-glance-install.yml index 1e4ed95df8..29b84ad8b4 100644 --- a/playbooks/os-glance-install.yml +++ b/playbooks/os-glance-install.yml @@ -119,9 +119,36 @@ tags: - glance-rabbitmq - glance-rabbitmq-user + - name: Create DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ glance_galera_address }}" + name: "{{ glance_galera_database }}" + state: "present" + when: inventory_hostname == groups['glance_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + tags: + - mysql-db-setup + - name: Grant access to the DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ glance_galera_address }}" + name: "{{ glance_galera_user }}" + password: "{{ glance_container_mysql_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ glance_galera_database }}.*:ALL" + when: inventory_hostname == groups['glance_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + with_items: + - "localhost" + - "%" + tags: + - mysql-db-setup roles: - role: "os_glance" - glance_galera_address: "{{ galera_address }}" glance_venv_tag: "{{ openstack_release }}" glance_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/glance-{{ openstack_release }}.tgz" tags: @@ -145,6 +172,9 @@ vars: galera_address: "{{ internal_lb_vip_address }}" is_metal: "{{ properties.is_metal|default(false) }}" + glance_galera_user: glance + glance_galera_database: glance + glance_galera_address: "{{ galera_address }}" glance_rabbitmq_userid: glance glance_rabbitmq_vhost: /glance glance_rabbitmq_servers: "{{ rabbitmq_servers }}" diff --git a/playbooks/os-heat-install.yml b/playbooks/os-heat-install.yml index 42b20d736e..ea87ca8468 100644 --- a/playbooks/os-heat-install.yml +++ b/playbooks/os-heat-install.yml @@ -102,11 +102,38 @@ tags: - heat-rabbitmq - heat-rabbitmq-user + - name: Create DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ heat_galera_address }}" + name: "{{ heat_galera_database }}" + state: "present" + when: inventory_hostname == groups['heat_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + tags: + - mysql-db-setup + - name: Grant access to the DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ heat_galera_address }}" + name: "{{ heat_galera_user }}" + password: "{{ heat_container_mysql_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ heat_galera_database }}.*:ALL" + when: inventory_hostname == groups['heat_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + with_items: + - "localhost" + - "%" + tags: + - mysql-db-setup roles: - role: "os_heat" heat_venv_tag: "{{ openstack_release }}" heat_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/heat-{{ openstack_release }}.tgz" - heat_galera_address: "{{ galera_address }}" tags: - "os-heat" - role: "rsyslog_client" @@ -122,6 +149,9 @@ vars: galera_address: "{{ internal_lb_vip_address }}" is_metal: "{{ properties.is_metal|default(false) }}" + heat_galera_user: heat + heat_galera_database: heat + heat_galera_address: "{{ galera_address }}" heat_rabbitmq_userid: heat heat_rabbitmq_vhost: /heat heat_rabbitmq_servers: "{{ rabbitmq_servers }}" diff --git a/playbooks/os-horizon-install.yml b/playbooks/os-horizon-install.yml index 7c071cf03c..bee5f0605a 100644 --- a/playbooks/os-horizon-install.yml +++ b/playbooks/os-horizon-install.yml @@ -75,9 +75,36 @@ when: is_metal | bool tags: - horizon-logs + - name: Create DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ horizon_galera_address }}" + name: "{{ horizon_galera_database }}" + state: "present" + when: inventory_hostname == groups['horizon_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + tags: + - mysql-db-setup + - name: Grant access to the DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ horizon_galera_address }}" + name: "{{ horizon_galera_user }}" + password: "{{ horizon_container_mysql_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ horizon_galera_database }}.*:ALL" + when: inventory_hostname == groups['horizon_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + with_items: + - "localhost" + - "%" + tags: + - mysql-db-setup roles: - role: "os_horizon" - horizon_galera_address: "{{ galera_address }}" horizon_server_name: "{{ container_name }}" horizon_venv_tag: "{{ openstack_release }}" horizon_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/horizon-{{ openstack_release }}.tgz" @@ -96,3 +123,6 @@ vars: galera_address: "{{ internal_lb_vip_address }}" is_metal: "{{ properties.is_metal|default(false) }}" + horizon_galera_user: horizon + horizon_galera_database: horizon + horizon_galera_address: "{{ galera_address }}" diff --git a/playbooks/os-ironic-install.yml b/playbooks/os-ironic-install.yml index efe97e0903..71812007a7 100644 --- a/playbooks/os-ironic-install.yml +++ b/playbooks/os-ironic-install.yml @@ -40,34 +40,6 @@ retries: 3 tags: - ssh-wait - - name: Create DB for Ironic - mysql_db: - login_user: "{{ galera_root_user }}" - login_password: "{{ galera_root_password }}" - login_host: "{{ ironic_galera_address }}" - name: "{{ ironic_galera_database }}" - state: "present" - delegate_to: "{{ groups['galera_all'][0] }}" - run_once: true - tags: - - ironic-db-setup - - name: Grant access to the DB for Ironic - mysql_user: - login_user: "{{ galera_root_user }}" - login_password: "{{ galera_root_password }}" - login_host: "{{ ironic_galera_address }}" - name: "{{ ironic_galera_user }}" - password: "{{ ironic_galera_password }}" - host: "{{ item }}" - state: "present" - priv: "{{ ironic_galera_database }}.*:ALL" - with_items: - - "localhost" - - "%" - delegate_to: "{{ groups['galera_all'][0] }}" - run_once: true - tags: - - ironic-db-setup - name: Ensure Rabbitmq vhost for Ironic rabbitmq_vhost: name: "{{ ironic_rabbitmq_vhost }}" @@ -91,6 +63,36 @@ tags: - ironic-rabbitmq - ironic-rabbitmq-user + - name: Create DB for Ironic + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ ironic_galera_address }}" + name: "{{ ironic_galera_database }}" + state: "present" + when: inventory_hostname == groups['ironic_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + run_once: true + tags: + - mysql-db-setup + - name: Grant access to the DB for Ironic + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ ironic_galera_address }}" + name: "{{ ironic_galera_user }}" + password: "{{ ironic_galera_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ ironic_galera_database }}.*:ALL" + when: inventory_hostname == groups['ironic_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + with_items: + - "localhost" + - "%" + run_once: true + tags: + - mysql-db-setup - name: Sort the rabbitmq servers dist_sort: value_to_lookup: "{{ container_name }}" @@ -124,7 +126,10 @@ tags: - "system-crontab-coordination" vars: + galera_address: "{{ internal_lb_vip_address }}" ansible_hostname: "{{ container_name }}" ansible_ssh_host: "{{ container_address }}" - ironic_galera_address: "{{ internal_lb_vip_address }}" is_metal: "{{ properties.is_metal|default(false) }}" + ironic_galera_user: ironic + ironic_galera_database: ironic + ironic_galera_address: "{{ galera_address }}" diff --git a/playbooks/os-keystone-install.yml b/playbooks/os-keystone-install.yml index 542f732129..c9931db384 100644 --- a/playbooks/os-keystone-install.yml +++ b/playbooks/os-keystone-install.yml @@ -123,7 +123,7 @@ mysql_db: login_user: "{{ galera_root_user }}" login_password: "{{ galera_root_password }}" - login_host: "{{ galera_address }}" + login_host: "{{ keystone_galera_address }}" name: "{{ keystone_galera_database }}" state: "present" when: inventory_hostname == groups['keystone_all'][0] @@ -134,7 +134,7 @@ mysql_user: login_user: "{{ galera_root_user }}" login_password: "{{ galera_root_password }}" - login_host: "{{ galera_address }}" + login_host: "{{ keystone_galera_address }}" name: "{{ keystone_galera_database }}" password: "{{ keystone_container_mysql_password }}" host: "{{ item }}" @@ -151,7 +151,6 @@ - role: "os_keystone" keystone_venv_tag: "{{ openstack_release }}" keystone_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/keystone-{{ openstack_release }}.tgz" - keystone_galera_address: "{{ galera_address }}" tags: - "os-keystone" - { role: "openstack_openrc", tags: [ "openstack-openrc" ] } @@ -172,6 +171,7 @@ keystone_admin_port: 35357 keystone_galera_user: keystone keystone_galera_database: keystone + keystone_galera_address: "{{ galera_address }}" keystone_rabbitmq_userid: keystone keystone_rabbitmq_vhost: /keystone keystone_rabbitmq_servers: "{{ rabbitmq_servers }}" diff --git a/playbooks/os-neutron-install.yml b/playbooks/os-neutron-install.yml index e50c45dbe6..8c9d2cac8d 100644 --- a/playbooks/os-neutron-install.yml +++ b/playbooks/os-neutron-install.yml @@ -121,6 +121,34 @@ tags: - neutron-rabbitmq - neutron-rabbitmq-user + - name: Create DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ neutron_galera_address }}" + name: "{{ neutron_galera_database }}" + state: "present" + when: inventory_hostname == groups['neutron_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + tags: + - mysql-db-setup + - name: Grant access to the DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ neutron_galera_address }}" + name: "{{ neutron_galera_user }}" + password: "{{ neutron_container_mysql_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ neutron_galera_database }}.*:ALL" + when: inventory_hostname == groups['neutron_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + with_items: + - "localhost" + - "%" + tags: + - mysql-db-setup - name: Create the neutron provider networks facts provider_networks: provider_networks: "{{ provider_networks }}" @@ -156,7 +184,6 @@ - role: "os_neutron" neutron_venv_tag: "{{ openstack_release }}" neutron_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/neutron-{{ openstack_release }}.tgz" - neutron_galera_address: "{{ galera_address }}" neutron_local_ip: "{{ _local_ip }}" neutron_overlay_network: "{{ _overlay_network }}" neutron_provider_networks: "{{ _provider_networks }}" @@ -179,6 +206,9 @@ vars: galera_address: "{{ internal_lb_vip_address }}" is_metal: "{{ properties.is_metal|default(false) }}" + neutron_galera_user: neutron + neutron_galera_database: neutron + neutron_galera_address: "{{ galera_address }}" bind_prefix: "{{ provider_network_bind_prefix|default('') }}" neutron_rabbitmq_userid: neutron neutron_rabbitmq_vhost: /neutron diff --git a/playbooks/os-nova-install.yml b/playbooks/os-nova-install.yml index 74943609cd..30fe69d66b 100644 --- a/playbooks/os-nova-install.yml +++ b/playbooks/os-nova-install.yml @@ -154,6 +154,62 @@ tags: - nova-rabbitmq - nova-rabbitmq-user + - name: Create DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ nova_galera_address }}" + name: "{{ nova_galera_database }}" + state: "present" + when: inventory_hostname == groups['nova_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + tags: + - mysql-db-setup + - name: Grant access to the DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ nova_galera_address }}" + name: "{{ nova_galera_user }}" + password: "{{ nova_container_mysql_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ nova_galera_database }}.*:ALL" + when: inventory_hostname == groups['nova_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + with_items: + - "localhost" + - "%" + tags: + - mysql-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" + when: inventory_hostname == groups['nova_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + tags: + - mysql-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" + when: inventory_hostname == groups['nova_all'][0] + delegate_to: "{{ groups['galera_all'][0] }}" + with_items: + - "localhost" + - "%" + tags: + - mysql-db-setup - name: Set nova management bridge (is_metal) set_fact: management_bridge: "{{ 'ansible_' + hostvars[inventory_hostname]['management_bridge'] | replace('-', '_') }}" @@ -192,8 +248,6 @@ nova_novncproxy_git_install_branch: "{{ novncproxy_git_install_branch }}" nova_spicehtml5_git_repo: "{{ openstack_repo_git_url }}/spice-html5" nova_spicehtml5_git_install_branch: "{{ spicehtml5_git_install_branch }}" - nova_galera_address: "{{ galera_address }}" - nova_api_galera_address: "{{ galera_address }}" nova_management_address: "{{ management_address }}" nova_venv_tag: "{{ openstack_release }}" nova_venv_download_url: "{{ openstack_repo_url }}/venvs/{{ openstack_release }}/{{ ansible_distribution | lower }}/nova-{{ openstack_release }}.tgz" @@ -222,6 +276,12 @@ vars: galera_address: "{{ internal_lb_vip_address }}" is_metal: "{{ properties.is_metal|default(false) }}" + nova_galera_user: nova + nova_galera_database: nova + nova_api_galera_user: nova_api + nova_api_galera_database: nova_api + nova_galera_address: "{{ galera_address }}" + nova_api_galera_address: "{{ galera_address }}" glance_host: "{{ internal_lb_vip_address }}" nova_rabbitmq_userid: nova nova_rabbitmq_vhost: /nova diff --git a/releasenotes/notes/db-create-in-playbooks-6fb8232da53fe1e1.yaml b/releasenotes/notes/db-create-in-playbooks-6fb8232da53fe1e1.yaml new file mode 100644 index 0000000000..93f35d0b0e --- /dev/null +++ b/releasenotes/notes/db-create-in-playbooks-6fb8232da53fe1e1.yaml @@ -0,0 +1,8 @@ +--- +features: + - All of the database and database user creates have + been removed from the roles into the playbooks. This + allows the roles to be tested independently of the + deployed database and also allows the roles to be + used independently of infrastructure choices made by + the integrated OSA project.