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 'tacker_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 'tacker_galera_address' which
has been used for a long time, but never documented. A bunch of unused
variables have also been removed.

The extras folder is removed given that tacker's playbooks have been
merged into the integrated repository.

Change-Id: I7c300ca89657863d58f8dc1178f6c57400bcaa80
This commit is contained in:
Jesse Pretorius 2018-06-28 16:55:06 +01:00
parent 0c0bffd92a
commit c1d339219e
10 changed files with 28 additions and 161 deletions

View File

@ -64,6 +64,8 @@ glance_rabbitmq_servers: 127.0.0.1
glance_rabbitmq_use_ssl: False
## Database info
tacker_db_setup_host: "{{ ('galera_all' in groups) | ternary(groups['galera_all'][0], 'localhost') }}"
tacker_galera_address: "{{ galera_address | default('127.0.0.1') }}"
tacker_galera_database: tacker
tacker_galera_user: tacker
tacker_galera_use_ssl: "{{ galera_use_ssl | default(False) }}"

View File

@ -1,23 +0,0 @@
---
# (C)2016 Brocade Communications Systems, Inc.
# 130 Holger Way, San Jose, CA 95134.
# All rights reserved.
#
# 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.
tacker_hosts:
aio1:
affinity:
tacker_container: 1
ip: 172.29.236.100

View File

@ -1,40 +0,0 @@
---
# (C)2016 Brocade Communications Systems, Inc.
# 130 Holger Way, San Jose, CA 95134.
# All rights reserved.
#
# 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.
component_skel:
tacker_server:
belongs_to:
- tacker_all
container_skel:
tacker_container:
belongs_to:
- tacker_containers
contains:
- tacker_server
properties:
service_name: tacker
physical_skel:
tacker_containers:
belongs_to:
- all_containers
tacker_hosts:
belongs_to:
- hosts

View File

@ -1,10 +0,0 @@
---
- service:
haproxy_service_name: tacker_server
haproxy_backend_nodes: "{{ groups['tacker_server'] | default([]) }}"
haproxy_port: 9890
haproxy_balance_type: http
haproxy_backend_options:
- "forwardfor"
- "httpchk"
- "httplog"

View File

@ -1,5 +0,0 @@
---
# Python packages to be installed into the utility container
utility_pip_packages:
- python-tackerclient

View File

@ -1,64 +0,0 @@
---
# Copyright 2017, SUSE LINUX GmbH.
#
# 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.
# Start tacker service
- name: Install the tacker components
hosts: tacker_all
gather_facts: "{{ gather_facts | default(True) }}"
max_fail_percentage: 20
user: root
pre_tasks:
- include: common-tasks/os-lxc-container-setup.yml
- include: common-tasks/rabbitmq-vhost-user.yml
static: no
vars:
user: "{{ tacker_rabbitmq_userid }}"
password: "{{ tacker_rabbitmq_password }}"
vhost: "{{ tacker_rabbitmq_vhost }}"
_rabbitmq_host_group: "{{ tacker_rabbitmq_host_group }}"
when:
- inventory_hostname == groups['tacker_all'][0]
- groups[tacker_rabbitmq_host_group] | length > 0
- include: common-tasks/os-log-dir-setup.yml
vars:
log_dirs:
- src: "/openstack/log/{{ inventory_hostname }}-tacker"
dest: "/var/log/tacker"
- include: common-tasks/mysql-db-user.yml
static: no
vars:
user_name: "{{ tacker_galera_user }}"
password: "{{ tacker_container_mysql_password }}"
login_host: "{{ tacker_galera_address }}"
db_name: "{{ tacker_galera_database }}"
when: inventory_hostname == groups['tacker_all'][0]
- include: common-tasks/package-cache-proxy.yml
roles:
- role: "os_tacker"
- role: "openstack_openrc"
tags:
- openrc
- role: "rsyslog_client"
rsyslog_client_log_rotate_file: tacker_log_rotate
rsyslog_client_log_dir: "/var/log/tacker"
rsyslog_client_config_name: "99-tacker-rsyslog-client.conf"
tags:
- rsyslog
vars:
is_metal: "{{ properties.is_metal|default(false) }}"
tacker_galera_address: "{{ internal_lb_vip_address }}"
environment: "{{ deployment_environment_variables | default({}) }}"
tags:
- tacker

View File

@ -1,12 +0,0 @@
---
## Tacker Service
tacker_git_repo: https://git.openstack.org/openstack/tacker
tacker_git_install_branch: 3f4e899f79903a76ffc2562531012801afb6468e # HEAD of master as of 2016-09-16
tacker_git_dest: "/opt/tacker_{{ tacker_git_install_branch | replace('/', '_') }}"
tacker_git_project_group: tacker_all
## Tacker Horizon
tackerhorizon_git_repo: https://git.openstack.org/openstack/tacker-horizon
tackerhorizon_git_install_branch: 79e99e762f2cef3a4474532135ab8ef19f9a459c # HEAD of master as of 2016-09-20
tackerhorizon_git_dest: "/opt/tackerhorizon_{{ tacker_git_install_branch | replace('/', '_') }}"
tackerhorizon_git_project_group: tacker_all

View File

@ -1,4 +0,0 @@
---
tacker_service_password:
tacker_container_mysql_password:
tacker_rabbitmq_password:

View File

@ -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: "{{ tacker_galera_address }}"
name: "{{ tacker_galera_database }}"
state: "present"
delegate_to: "{{ tacker_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: "{{ tacker_galera_address }}"
name: "{{ tacker_galera_user }}"
password: "{{ tacker_container_mysql_password }}"
host: "{{ item }}"
state: "present"
priv: "{{ tacker_galera_database }}.*:ALL"
delegate_to: "{{ tacker_db_setup_host }}"
with_items:
- "localhost"
- "%"
no_log: True
- name: Perform a tacker DB sync
command: "{{ tacker_bin }}/tacker-db-manage
--config-file {{ tacker_etc_dir }}/tacker.conf upgrade head"

View File

@ -25,9 +25,6 @@
user_name: "{{ tacker_rabbitmq_userid }}"
user_password: "{{ tacker_rabbitmq_password }}"
when: groups['rabbitmq_all'] is defined
- include: common/create-grant-db.yml
db_name: "{{ tacker_galera_database }}"
db_password: "{{ tacker_container_mysql_password }}"
roles:
- role: os_tacker
vars_files: