Move database creation into role
There is no record for why we implement the database creation outside of the role in the playbook, when we could do it inside the role. Implementing it inside the role allows us to reduce the quantity of group_vars duplicated from the role, and allows us to better document the required variables in the role. The delegation can still be done as it is done in the playbook too. In this patch we implement a new variable called 'panko_db_setup_host' which is used in the role to allow delegation of the database setup task to any host, but defaults to the first member of the galera_all host group. We also document the variable 'panko_galera_address' which has been used for a long time, but never documented. A bunch of unused variables have also been removed. Change-Id: Ib31b94433183bb12209fe824ea5c8ee67aaa8276
This commit is contained in:
parent
9375bb4612
commit
e5b8094b74
|
@ -48,10 +48,11 @@ panko_system_comment: panko system user
|
|||
panko_system_user_home: "/var/lib/{{ panko_system_user_name }}"
|
||||
|
||||
## DB info
|
||||
panko_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}"
|
||||
panko_database_name: panko
|
||||
panko_database_user: panko
|
||||
panko_db_type: "mysql+pymysql"
|
||||
panko_db_address: localhost
|
||||
panko_db_address: "{{ galera_address | default('127.0.0.1') }}"
|
||||
panko_connection_string: "{{ panko_db_type }}://{{ panko_database_user }}:{{ panko_container_db_password }}@{{ panko_db_address }}/{{ panko_database_name }}?charset=utf8"
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,3 @@
|
|||
# limitations under the License.
|
||||
|
||||
panko_service_region: "{{ service_region }}"
|
||||
panko_galera_user: panko
|
||||
panko_galera_database: panko
|
||||
panko_galera_address: "{{ internal_lb_vip_address }}"
|
||||
panko_connection_string: "mysql+pymysql://{{ panko_galera_user }}:{{ panko_container_db_password }}@{{ panko_galera_address }}/{{ panko_galera_database }}?charset=utf8"
|
||||
|
|
|
@ -15,37 +15,28 @@
|
|||
- name: Install the panko components
|
||||
hosts: panko_all
|
||||
gather_facts: "{{ osa_gather_facts | default(True) }}"
|
||||
max_fail_percentage: 20
|
||||
user: root
|
||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||
tags:
|
||||
- panko
|
||||
pre_tasks:
|
||||
- include: common-tasks/os-lxc-container-setup.yml
|
||||
|
||||
- include: common-tasks/os-log-dir-setup.yml
|
||||
vars:
|
||||
log_dirs:
|
||||
- src: "/openstack/log/{{ inventory_hostname }}-panko"
|
||||
dest: "/var/log/panko"
|
||||
- include: common-tasks/mysql-db-user.yml
|
||||
static: no
|
||||
vars:
|
||||
user_name: "{{ panko_galera_user }}"
|
||||
password: "{{ panko_container_db_password }}"
|
||||
login_host: "{{ panko_galera_address }}"
|
||||
db_name: "{{ panko_galera_database }}"
|
||||
when: inventory_hostname == groups['panko_all'][0]
|
||||
- include: common-tasks/package-cache-proxy.yml
|
||||
roles:
|
||||
- role: "os_panko"
|
||||
|
||||
- role: "openstack_openrc"
|
||||
tags:
|
||||
- openrc
|
||||
|
||||
- role: "rsyslog_client"
|
||||
rsyslog_client_log_rotate_file: panko_log_rotate
|
||||
rsyslog_client_log_dir: "/var/log/panko"
|
||||
rsyslog_client_config_name: "99-panko-rsyslog-client.conf"
|
||||
tags:
|
||||
- rsyslog
|
||||
vars:
|
||||
is_metal: "{{ properties.is_metal|default(false) }}"
|
||||
environment: "{{ deployment_environment_variables | default({}) }}"
|
||||
tags:
|
||||
- panko
|
||||
|
|
|
@ -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: "{{ panko_db_address }}"
|
||||
name: "{{ panko_database_name }}"
|
||||
state: "present"
|
||||
delegate_to: "{{ panko_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: "{{ panko_db_address }}"
|
||||
name: "{{ panko_database_user }}"
|
||||
password: "{{ panko_container_db_password }}"
|
||||
host: "{{ item }}"
|
||||
state: "present"
|
||||
priv: "{{ panko_database_name }}.*:ALL"
|
||||
delegate_to: "{{ panko_db_setup_host }}"
|
||||
with_items:
|
||||
- "localhost"
|
||||
- "%"
|
||||
no_log: True
|
||||
|
||||
- name: Perform a panko DB sync
|
||||
command: "{{ panko_bin }}/panko-dbsync"
|
||||
become: yes
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
panko_container_db_password: "secrete"
|
||||
panko_db_address: "{{ test_galera_host }}"
|
||||
panko_database_name: panko
|
||||
panko_venv_tag: "testing"
|
||||
panko_developer_mode: true
|
||||
panko_service_password: "secrete"
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
hosts: panko_all
|
||||
user: root
|
||||
gather_facts: true
|
||||
pre_tasks:
|
||||
- include: common/create-grant-db.yml
|
||||
db_name: "{{ panko_database_name }}"
|
||||
db_password: "{{ panko_container_db_password }}"
|
||||
roles:
|
||||
- role: "{{ panko_rolename | default('os_panko') }}"
|
||||
vars_files:
|
||||
|
|
Loading…
Reference in New Issue