diff --git a/defaults/main.yml b/defaults/main.yml index d93571c..1a9054e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -53,10 +53,11 @@ aodh_system_comment: aodh system user aodh_system_user_home: "/var/lib/{{ aodh_system_user_name }}" ## Database info +aodh_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" +aodh_db_address: "{{ galera_address | default('127.0.0.1') }}" aodh_database_name: aodh aodh_database_user: aodh aodh_db_type: "mysql+pymysql" -aodh_db_address: localhost aodh_galera_use_ssl: "{{ galera_use_ssl | default(False) }}" aodh_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/galera-ca.pem') }}" aodh_connection_string: "{{ aodh_db_type }}://{{ aodh_database_user }}:{{ aodh_container_db_password }}@{{ aodh_db_address }}/{{ aodh_database_name }}?charset=utf8{% if aodh_galera_use_ssl | bool %}&ssl_ca={{ aodh_galera_ssl_ca_cert }}{% endif %}" diff --git a/examples/playbook.yml b/examples/playbook.yml index 09f014e..ddb3aef 100644 --- a/examples/playbook.yml +++ b/examples/playbook.yml @@ -2,7 +2,7 @@ hosts: aodh_all user: root roles: - - { role: "os_aodh" } + - role: "os_aodh" vars: # Needed for aodh to talk to MongoDB aodh_container_db_password: "secrete" @@ -32,3 +32,7 @@ keystone_service_internalurl: "{{ keystone_service_internaluri }}/v3" keystone_service_adminuri: "http://5.6.7.8:35357" keystone_service_adminurl: "{{ keystone_service_adminuri }}/v3" + galera_root_user: root + vars_prompt: + - name: "galera_root_password" + prompt: "What is galera_root_password?" diff --git a/tasks/aodh_db_setup.yml b/tasks/aodh_db_setup.yml index 5c9a161..00e343b 100644 --- a/tasks/aodh_db_setup.yml +++ b/tasks/aodh_db_setup.yml @@ -13,6 +13,32 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Create DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ aodh_db_address }}" + name: "{{ aodh_database_name }}" + state: "present" + delegate_to: "{{ aodh_db_setup_host }}" + no_log: True + +- name: Grant access to the DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ aodh_db_address }}" + name: "{{ aodh_database_user }}" + password: "{{ aodh_container_db_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ aodh_database_name }}.*:ALL" + delegate_to: "{{ aodh_db_setup_host }}" + with_items: + - "localhost" + - "%" + no_log: True + - name: Perform a Aodh DB sync command: "{{ aodh_bin }}/aodh-dbsync" become: yes diff --git a/tests/test-install-aodh.yml b/tests/test-install-aodh.yml index 13709b9..143fccc 100644 --- a/tests/test-install-aodh.yml +++ b/tests/test-install-aodh.yml @@ -25,10 +25,7 @@ notify_vhost: "{{ aodh_oslomsg_notify_vhost }}" notify_user: "{{ aodh_oslomsg_notify_userid }}" notify_password: "{{ aodh_oslomsg_notify_password }}" - - include: common/create-grant-db.yml - db_name: "{{ aodh_database_name }}" - db_password: "{{ aodh_container_db_password }}" roles: - - role: "{{ aodh_rolename | default('os_aodh') }}" + - role: "os_aodh" vars_files: - common/test-vars.yml