diff --git a/defaults/main.yml b/defaults/main.yml index 97fa541..003ba86 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -46,6 +46,8 @@ rally_venv_download: "{{ not rally_developer_mode | bool }}" rally_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/rally.tgz # Database vars +rally_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}" +rally_galera_address: "{{ galera_address | default('127.0.0.1') }}" rally_galera_database: rally rally_galera_user: rally rally_database_connection_string: mysql+pymysql://{{ rally_galera_user }}:{{ rally_galera_password }}@{{ rally_galera_address }}/{{ rally_galera_database }}?charset=utf8 diff --git a/tasks/rally_db_setup.yml b/tasks/rally_db_setup.yml index e1312d4..bae3b13 100644 --- a/tasks/rally_db_setup.yml +++ b/tasks/rally_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: "{{ rally_galera_address }}" + name: "{{ rally_galera_database }}" + state: "present" + delegate_to: "{{ rally_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: "{{ rally_galera_address }}" + name: "{{ rally_galera_user }}" + password: "{{ rally_galera_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ rally_galera_database }}.*:ALL" + delegate_to: "{{ rally_db_setup_host }}" + with_items: + - "localhost" + - "%" + no_log: True + - name: Check for db command: "{{ rally_bin }}/rally deployment list" changed_when: false diff --git a/tests/os_rally-overrides.yml b/tests/os_rally-overrides.yml index 5e8f219..8573f78 100644 --- a/tests/os_rally-overrides.yml +++ b/tests/os_rally-overrides.yml @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -rally_galera_address: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}" -rally_galera_database: rally rally_galera_password: "SuperSecrete" rally_venv_tag: "testing" rally_venv_download: False diff --git a/tests/test-install-rally.yml b/tests/test-install-rally.yml index 1c79b78..e1c2ddc 100644 --- a/tests/test-install-rally.yml +++ b/tests/test-install-rally.yml @@ -17,33 +17,6 @@ hosts: utility_all user: root gather_facts: true - pre_tasks: - - name: Create DB for service - mysql_db: - login_user: "root" - login_password: "secrete" - login_host: "localhost" - name: "{{ rally_galera_database }}" - state: "present" - delegate_to: "10.100.100.2" - when: inventory_hostname == groups['utility_all'][0] - no_log: true - - name: Grant access to the DB for the service - mysql_user: - login_user: "root" - login_password: "secrete" - login_host: "localhost" - name: "{{ rally_galera_database }}" - password: "{{ rally_galera_password }}" - host: "{{ item }}" - state: "present" - priv: "{{ rally_galera_database }}.*:ALL" - with_items: - - "localhost" - - "%" - delegate_to: "10.100.100.2" - when: inventory_hostname == groups['utility_all'][0] - no_log: true roles: - role: "os_rally" vars_files: