diff --git a/ansible/roles/ansible-datamover-api/defaults/main.yml b/ansible/roles/ansible-datamover-api/defaults/main.yml index ee392cec7..f16f76fed 100644 --- a/ansible/roles/ansible-datamover-api/defaults/main.yml +++ b/ansible/roles/ansible-datamover-api/defaults/main.yml @@ -1,11 +1,13 @@ # Database vars -dmapi_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" +dmapi_db_setup_host_victoria: "{{ openstack_db_setup_host | default('localhost') }}" +dmapi_db_setup_host_ussuri: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" dmapi_galera_address: "{{ galera_address | default('127.0.0.1') }}" dmapi_galera_database: dmapi dmapi_galera_user: dmapi dmapi_galera_use_ssl: "{{ galera_use_ssl | default(False) }}" dmapi_galera_ssl_ca_cert: "{{ galera_ssl_ca_cert | default('/etc/ssl/certs/galera-ca.pem') }}" dmapi_galera_password: "{{DMAPI_MYSQL_PASSWORD}}" +dmapi_galera_port: 3306 # RPC @@ -35,8 +37,10 @@ dmapi_oslomsg_notify_vhost: "{{ dmapi_oslomsg_rpc_vhost }}" # Set the host which will execute the shade modules # for the service setup. The host must already have # clouds.yaml properly configured. + dmapi_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}" dmapi_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((dmapi_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +dmapi_db_setup_python_interpreter_victoria: "{{ openstack_db_setup_python_interpreter | default((dmapi_db_setup_host_victoria == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" # Keystone AuthToken/Middleware dmapi_keystone_auth_plugin: password diff --git a/ansible/roles/ansible-datamover-api/tasks/create_dmapi_db.yml b/ansible/roles/ansible-datamover-api/tasks/create_dmapi_db.yml index 6f962599d..bda2a4a5a 100644 --- a/ansible/roles/ansible-datamover-api/tasks/create_dmapi_db.yml +++ b/ansible/roles/ansible-datamover-api/tasks/create_dmapi_db.yml @@ -1,12 +1,29 @@ -- import_tasks: db_setup.yml +- import_tasks: db_setup_victoria.yml run_once: True vars: - _oslodb_setup_host: "{{ dmapi_db_setup_host }}" + _oslodb_setup_host: "{{ dmapi_db_setup_host_victoria }}" + _oslodb_ansible_python_interpreter: "{{ dmapi_db_setup_python_interpreter_victoria }}" + _oslodb_setup_endpoint: "{{ dmapi_galera_address }}" + _oslodb_setup_port: "{{ dmapi_galera_port }}" _oslodb_databases: - name: "{{ dmapi_galera_database }}" users: - username: "{{ dmapi_galera_user }}" password: "{{ dmapi_galera_password }}" + when: + OPENSTACK_DIST | upper == "VICTORIA" + +- import_tasks: db_setup_ussuri.yml + run_once: True + vars: + _oslodb_setup_host: "{{ dmapi_db_setup_host_ussuri }}" + _oslodb_databases: + - name: "{{ dmapi_galera_database }}" + users: + - username: "{{ dmapi_galera_user }}" + password: "{{ dmapi_galera_password }}" + when: + OPENSTACK_DIST | upper == "USSURI" - import_tasks: mq_setup.yml run_once: True diff --git a/ansible/roles/ansible-datamover-api/tasks/db_setup.yml b/ansible/roles/ansible-datamover-api/tasks/db_setup_ussuri.yml similarity index 79% rename from ansible/roles/ansible-datamover-api/tasks/db_setup.yml rename to ansible/roles/ansible-datamover-api/tasks/db_setup_ussuri.yml index 957d71eba..8a324a79e 100644 --- a/ansible/roles/ansible-datamover-api/tasks/db_setup.yml +++ b/ansible/roles/ansible-datamover-api/tasks/db_setup_ussuri.yml @@ -2,13 +2,13 @@ - name: Setup Database Service (MariaDB) delegate_to: "{{_oslodb_setup_host }}" block: - - name: Create database for service + - name: Ussuri | Create database for service Ussri mysql_db: name: "{{ item.name }}" loop: "{{ _oslodb_databases }}" no_log: true - - name: Grant access to the database for the service + - name: Ussuri | Grant access to the database for the service mysql_user: name: "{{ item.1.username }}" password: "{{ item.1.password }}" @@ -17,4 +17,4 @@ priv: "{{ item.0.name }}.*:{{ item.1.priv | default('ALL') }}" append_privs: yes loop: "{{ _oslodb_databases | subelements('users') }}" - no_log: true + no_log: true \ No newline at end of file diff --git a/ansible/roles/ansible-datamover-api/tasks/db_setup_victoria.yml b/ansible/roles/ansible-datamover-api/tasks/db_setup_victoria.yml new file mode 100644 index 000000000..d3900c969 --- /dev/null +++ b/ansible/roles/ansible-datamover-api/tasks/db_setup_victoria.yml @@ -0,0 +1,26 @@ +--- +- name: Setup Database Service (MariaDB) + delegate_to: "{{_oslodb_setup_host }}" + vars: + ansible_python_interpreter: "{{ _oslodb_ansible_python_interpreter }}" + block: + - name: Victoria | Create database for service + mysql_db: + name: "{{ item.name }}" + login_host: "{{ _oslodb_setup_endpoint | default(omit) }}" + login_port: "{{ _oslodb_setup_port | default(omit) }}" + loop: "{{ _oslodb_databases }}" + no_log: true + + - name: Victoria | Grant access to the database for the service + mysql_user: + name: "{{ item.1.username }}" + password: "{{ item.1.password }}" + update_password: always + host: "{{ item.1.host | default('%') }}" + priv: "{{ item.0.name }}.*:{{ item.1.priv | default('ALL') }}" + login_host: "{{ _oslodb_setup_endpoint | default(omit) }}" + login_port: "{{ _oslodb_setup_port | default(omit) }}" + append_privs: yes + loop: "{{ _oslodb_databases | subelements('users') }}" + no_log: true