Merge "db_setup: refactor database setup to a common file"
This commit is contained in:
3 changed files with 75 additions and 46 deletions
40
tasks/db_setup.yml
Normal file
40
tasks/db_setup.yml
Normal file
@@ -0,0 +1,40 @@
---
# Copyright 2019, VEXXHOST, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# WARNING:
# This file is maintained in the openstack-ansible-tests repository.
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/sync/tasks/db_setup.yml
# If you need to modify this file, update the one in the openstack-ansible-tests
# repository. Once it merges there, the changes will automatically be proposed to
# all the repositories which use it.
- name:Setup Database Service (MariaDB)
delegate_to:"{{ _oslodb_setup_host }}"
tags:
- common-mariadb
block:
- name:Create database for service
mysql_db:
name:"{{ item.name }}"
loop:"{{ _oslodb_databases }}"
- name:Grant access to the database for the service
mysql_user:
name:"{{ item.1.username }}"
password:"{{ item.1.password }}"
host:"{{ item.1.host | default('%') }}"
priv:"{{ item.0.name }}.*:{{ item.1.priv | default('ALL') }}"
loop:"{{ _oslodb_databases | subelements('users') }}"
no_log:true
@@ -35,6 +35,40 @@
tags:
- always
- import_tasks:db_setup.yml
when:
- "trove_services['trove-api']['group'] in group_names"
- "inventory_hostname == ((groups[trove_services['trove-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
vars:
_oslodb_setup_host:"{{ trove_db_setup_host }}"
_oslodb_databases:
- name:"{{ trove_galera_database_name }}"
users:
- username:"{{ trove_galera_user }}"
password:"{{ trove_galera_password }}"
tags:
- common-db
- trove-config
- import_tasks:mq_setup.yml
when:
- "trove_services['trove-api']['group'] in group_names"
- "inventory_hostname == ((groups[trove_services['trove-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
vars:
_oslomsg_rpc_setup_host:"{{ trove_oslomsg_rpc_setup_host }}"
_oslomsg_rpc_userid:"{{ trove_oslomsg_rpc_userid }}"
_oslomsg_rpc_password:"{{ trove_oslomsg_rpc_password }}"
_oslomsg_rpc_vhost:"{{ trove_oslomsg_rpc_vhost }}"
_oslomsg_rpc_transport:"{{ trove_oslomsg_rpc_transport }}"
_oslomsg_notify_setup_host:"{{ trove_oslomsg_notify_setup_host }}"
_oslomsg_notify_userid:"{{ trove_oslomsg_notify_userid }}"
_oslomsg_notify_password:"{{ trove_oslomsg_notify_password }}"
_oslomsg_notify_vhost:"{{ trove_oslomsg_notify_vhost }}"
_oslomsg_notify_transport:"{{ trove_oslomsg_notify_transport }}"
tags:
- common-mq
- trove-config
- include_tasks:trove_pre_install.yml
tags:
- trove-install
@@ -98,26 +132,7 @@
tags:
- trove-install
- import_tasks:mq_setup.yml
when:
- "trove_services['trove-api']['group'] in group_names"
- "inventory_hostname == ((groups[trove_services['trove-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
vars:
_oslomsg_rpc_setup_host:"{{ trove_oslomsg_rpc_setup_host }}"
_oslomsg_rpc_userid:"{{ trove_oslomsg_rpc_userid }}"
_oslomsg_rpc_password:"{{ trove_oslomsg_rpc_password }}"
_oslomsg_rpc_vhost:"{{ trove_oslomsg_rpc_vhost }}"
_oslomsg_rpc_transport:"{{ trove_oslomsg_rpc_transport }}"
_oslomsg_notify_setup_host:"{{ trove_oslomsg_notify_setup_host }}"
_oslomsg_notify_userid:"{{ trove_oslomsg_notify_userid }}"
_oslomsg_notify_password:"{{ trove_oslomsg_notify_password }}"
_oslomsg_notify_vhost:"{{ trove_oslomsg_notify_vhost }}"
_oslomsg_notify_transport:"{{ trove_oslomsg_notify_transport }}"
tags:
- common-mq
- trove-config
- include_tasks:trove_db_setup.yml
- include_tasks:trove_db_sync.yml
when:inventory_hostname == groups['trove_conductor'][0]
tags:
- trove-install
@@ -16,32 +16,6 @@
# (c) 2016 Donovan Francesco <donovan.francesco@is.co.za>
# (c) 2016 Paul Stevens <paul.stevens@is.co.za>
- name:Create DB for service
mysql_db:
login_user:"{{ galera_root_user }}"
login_password:"{{ galera_root_password }}"
login_host:"{{ trove_galera_address }}"
name:"{{ trove_galera_database_name }}"
state:"present"
delegate_to:"{{ trove_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:"{{ trove_galera_address }}"
name:"{{ trove_galera_user }}"
password:"{{ trove_galera_password }}"
host:"{{ item }}"
state:"present"
priv:"{{ trove_galera_database_name }}.*:ALL"
delegate_to:"{{ trove_db_setup_host }}"
with_items:
- "localhost"
- "%"
no_log:True
- name:Perform a trove DB sync
command:>
{{trove_bin }}/trove-manage
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.