Added major version upgrade support
The change adds in the ability for the role to take care of a major upgrade in a version of an installed mariadb galera cluster. The change adds a new task file that checks if the installed version of the galera cluster matches that of the specified major version. The role will hard stop if there is a version mismatch and the option "galera_upgrade=true" is not passed. Change-Id: I26560668325d45f670c8b946c978c48559f58419 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
5bcdd4b772
commit
b651fa3bd8
@ -15,6 +15,7 @@
|
||||
|
||||
galera_server_bootstrap_node: "{{ groups['galera_all'][0] }}"
|
||||
galera_ignore_cluster_state: false
|
||||
galera_upgrade: false
|
||||
|
||||
galera_wsrep_node_name: "{{ inventory_hostname }}"
|
||||
galera_cluster_name: openstack_galera_cluster
|
||||
|
@ -17,11 +17,16 @@
|
||||
service:
|
||||
name: mysql
|
||||
state: restarted
|
||||
sleep: 2
|
||||
pattern: mysql
|
||||
args: "{{ (not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node) | ternary('--wsrep-new-cluster', '') }}"
|
||||
environment:
|
||||
MYSQLD_STARTUP_TIMEOUT: 180
|
||||
when: not galera_running_and_bootstrapped | bool
|
||||
register: galera_restart
|
||||
until: galera_restart_fall_back | success
|
||||
retries: 3
|
||||
delay: 5
|
||||
# notifies are only fired when status is "changed"
|
||||
changed_when: galera_restart | failed
|
||||
failed_when: false
|
||||
@ -39,6 +44,8 @@
|
||||
service:
|
||||
name: mysql
|
||||
state: restarted
|
||||
sleep: 2
|
||||
pattern: mysql
|
||||
args: "{{ (not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node) | ternary('--wsrep-new-cluster', '') }}"
|
||||
environment:
|
||||
MYSQLD_STARTUP_TIMEOUT: 180
|
||||
|
@ -13,15 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Check if mysql is running
|
||||
command: /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
|
||||
ignore_errors: true
|
||||
changed_when: mysql_running.rc != 0
|
||||
register: mysql_running
|
||||
notify: Restart mysql
|
||||
tags:
|
||||
- galera-cluster-state-check
|
||||
- galera-bootstrap
|
||||
- include: galera_running_check.yml
|
||||
vars:
|
||||
num_retries: 1
|
||||
wait_delay: 3
|
||||
|
||||
- name: Start cluster with wsrep
|
||||
service:
|
||||
|
@ -13,14 +13,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Check if mysql is running
|
||||
command: /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
|
||||
ignore_errors: true
|
||||
changed_when: mysql_running.rc != 0
|
||||
register: mysql_running
|
||||
notify: Restart mysql
|
||||
tags:
|
||||
- galera-cluster-state-check
|
||||
- include: galera_running_check.yml
|
||||
vars:
|
||||
num_retries: 1
|
||||
wait_delay: 3
|
||||
|
||||
- name: Check for cluster state failure
|
||||
fail:
|
||||
|
@ -79,3 +79,7 @@
|
||||
state: absent
|
||||
tags:
|
||||
- galera-config
|
||||
|
||||
- include: galera_upgrade_post.yml
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
|
34
tasks/galera_running_check.yml
Normal file
34
tasks/galera_running_check.yml
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
# Copyright 2015, Rackspace US, 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.
|
||||
|
||||
- name: Confirm service connectivity
|
||||
command: "/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping"
|
||||
changed_when: _mysql_running.rc != 0
|
||||
register: _mysql_running
|
||||
until: _mysql_running.rc == 0
|
||||
retries: "{{ num_retries }}"
|
||||
delay: "{{ wait_delay }}"
|
||||
failed_when: false
|
||||
changed_when: _mysql_running.rc != 0
|
||||
tags:
|
||||
- galera-cluster-state-check
|
||||
- galera-bootstrap
|
||||
|
||||
- name: Set running state fact
|
||||
set_fact:
|
||||
mysql_running: "{{ _mysql_running }}"
|
||||
tags:
|
||||
- galera-cluster-state-check
|
||||
- galera-bootstrap
|
53
tasks/galera_upgrade_check.yml
Normal file
53
tasks/galera_upgrade_check.yml
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
- name: Check major galera install version
|
||||
command: "dpkg -s {{ galera_mariadb_server_package }}"
|
||||
ignore_errors: true
|
||||
register: installed_galera_specific
|
||||
when:
|
||||
- not galera_upgrade | bool
|
||||
tags:
|
||||
- galera-package-deb
|
||||
- galera-apt-packages
|
||||
- galera-upgrade
|
||||
|
||||
- name: Check for any galera install version
|
||||
shell: |
|
||||
dpkg --get-selections | grep mariadb-galera-server
|
||||
ignore_errors: true
|
||||
register: installed_galera_any
|
||||
when:
|
||||
- not galera_upgrade | bool
|
||||
- installed_galera_specific.rc != 0
|
||||
tags:
|
||||
- galera-package-deb
|
||||
- galera-apt-packages
|
||||
- galera-upgrade
|
||||
|
||||
- name: Check if major version of Galera is installed
|
||||
fail:
|
||||
msg: "To install a new major version of mariadb-galera-server set '-e galera_upgrade=true'."
|
||||
when:
|
||||
- not galera_upgrade | bool
|
||||
- installed_galera_specific.rc != 0 and installed_galera_any.rc == 0
|
||||
tags:
|
||||
- galera-package-deb
|
||||
- galera-apt-packages
|
||||
- galera-upgrade
|
||||
|
||||
- include: galera_upgrade_pre.yml
|
||||
when:
|
||||
- galera_upgrade | bool
|
46
tasks/galera_upgrade_post.yml
Normal file
46
tasks/galera_upgrade_post.yml
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
# This is starting MySQL as it may be required to restart the service more than
|
||||
# once to get it to clean up old service files from the previous version.
|
||||
# If the service fails to start after 3 attempts the shell command will be failed.
|
||||
- name: Start MySQL
|
||||
shell: |
|
||||
for i in {1..3}; do
|
||||
/etc/init.d/mysql start || true
|
||||
if pgrep mysqld; then
|
||||
exit 0
|
||||
else
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
echo "Service failed to start"
|
||||
exit 1
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
tags:
|
||||
- galera-upgrade
|
||||
|
||||
- include: galera_running_check.yml
|
||||
vars:
|
||||
num_retries: 1
|
||||
wait_delay: 3
|
||||
|
||||
- name: Run MySQL Upgrade
|
||||
command: "/usr/bin/mysql_upgrade"
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
tags:
|
||||
- galera-upgrade
|
80
tasks/galera_upgrade_pre.yml
Normal file
80
tasks/galera_upgrade_pre.yml
Normal file
@ -0,0 +1,80 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
- name: Set fact to ignore cluster state
|
||||
set_fact:
|
||||
galera_ignore_cluster_state: true
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
tags:
|
||||
- galera-upgrade
|
||||
|
||||
- name: Stop MariaDB
|
||||
service:
|
||||
name: mysql
|
||||
state: stopped
|
||||
register: galera_restart_fall_back
|
||||
until: galera_restart_fall_back | success
|
||||
retries: 3
|
||||
delay: 5
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
tags:
|
||||
- galera-upgrade
|
||||
|
||||
- name: Find old sources
|
||||
shell: |
|
||||
grep -rnil maria /etc/apt/sources.list.d/*
|
||||
register: old_sources
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
tags:
|
||||
- galera-upgrade
|
||||
- galera-apt-packages
|
||||
|
||||
- name: Remove old sources
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
with_items: old_sources.stdout_lines
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
tags:
|
||||
- galera-upgrade
|
||||
- galera-apt-packages
|
||||
|
||||
- name: Update apt sources (Forced)
|
||||
apt:
|
||||
update_cache: yes
|
||||
cache_valid_time: 0
|
||||
register: apt_update
|
||||
until: apt_update|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
tags:
|
||||
- galera-upgrade
|
||||
- galera-apt-packages
|
||||
|
||||
- name: UN-Install galera-server package
|
||||
apt:
|
||||
pkg: "mariadb-galera-server*"
|
||||
state: absent
|
||||
when:
|
||||
- galera_upgrade | bool
|
||||
tags:
|
||||
- galera-upgrade
|
||||
- galera-apt-packages
|
@ -13,6 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- include: galera_upgrade_check.yml
|
||||
- include: galera_cluster_state.yml
|
||||
- include: galera_pre_install.yml
|
||||
- include: galera_install.yml
|
||||
@ -22,14 +23,10 @@
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Confirm service connectivity after mysql restart
|
||||
command: /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping
|
||||
changed_when: mysql_running.rc != 0
|
||||
register: mysql_running
|
||||
when: galera_restart is defined
|
||||
until: mysql_running|success
|
||||
retries: 12
|
||||
delay: 5
|
||||
- include: galera_running_check.yml
|
||||
vars:
|
||||
num_retries: 10
|
||||
wait_delay: 3
|
||||
|
||||
- include: galera_setup.yml
|
||||
when: inventory_hostname == galera_server_bootstrap_node
|
||||
|
54
tests/test-container-create.yml
Normal file
54
tests/test-container-create.yml
Normal file
@ -0,0 +1,54 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
- name: Playbook for pre-role upgrade testing
|
||||
hosts: all_containers
|
||||
connection: local
|
||||
gather_facts: false
|
||||
pre_tasks:
|
||||
- name: Destroy test containers
|
||||
lxc_container:
|
||||
name: "{{ container_name }}"
|
||||
state: "absent"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- container-destroy
|
||||
- name: Destroy container service directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: "absent"
|
||||
with_items:
|
||||
- "/openstack/{{ container_name }}"
|
||||
- "/openstack/backup/{{ container_name }}"
|
||||
- "/openstack/log/{{ container_name }}"
|
||||
- "/var/lib/lxc/{{ container_name }}"
|
||||
- "{{ lxc_container_directory|default('/var/lib/lxc') }}/{{ container_name }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- container-directories
|
||||
roles:
|
||||
- role: "lxc_container_create"
|
||||
lxc_container_release: trusty
|
||||
lxc_container_backing_store: dir
|
||||
global_environment_variables:
|
||||
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
post_tasks:
|
||||
- name: Wait for ssh to be available
|
||||
local_action:
|
||||
module: wait_for
|
||||
port: "{{ ansible_ssh_port | default('22') }}"
|
||||
host: "{{ ansible_ssh_host | default(inventory_hostname) }}"
|
||||
search_regex: OpenSSH
|
||||
delay: 1
|
84
tests/test-functional.yml
Normal file
84
tests/test-functional.yml
Normal file
@ -0,0 +1,84 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
- name: Playbook for testing
|
||||
hosts: galera_all
|
||||
user: root
|
||||
gather_facts: true
|
||||
vars:
|
||||
galera_root_password: secrete
|
||||
galera_root_user: root
|
||||
pre_tasks:
|
||||
- debug:
|
||||
msg: "===== Running Function Tests ====="
|
||||
tasks:
|
||||
- name: Create DB for service on 10.100.100.101
|
||||
mysql_db:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "10.100.100.101"
|
||||
name: "OSA-test"
|
||||
state: "present"
|
||||
tags:
|
||||
- neutron-db-setup
|
||||
when: ansible_ssh_host == '10.100.100.101'
|
||||
- name: Grant access to the DB on 10.100.100.102
|
||||
mysql_user:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "10.100.100.102"
|
||||
name: "osa-tester"
|
||||
password: "tester-secrete"
|
||||
host: "{{ item }}"
|
||||
state: "present"
|
||||
priv: "OSA-test.*:ALL"
|
||||
with_items:
|
||||
- "localhost"
|
||||
- "%"
|
||||
tags:
|
||||
- neutron-db-setup
|
||||
when: ansible_ssh_host == '10.100.100.102'
|
||||
- name: check cluster state incoming addresses
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
-e "show status like 'wsrep_incoming_addresses';" \
|
||||
--silent \
|
||||
--skip-column-names
|
||||
register: wsrep_incoming_addresses
|
||||
- name: check cluster state
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
-e "show status like 'wsrep_local_state_comment';" \
|
||||
--silent \
|
||||
--skip-column-names
|
||||
register: wsrep_local_state_comment
|
||||
- name: check cluster state
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
-e "show status like 'wsrep_evs_state';" \
|
||||
--silent \
|
||||
--skip-column-names
|
||||
register: wsrep_evs_state
|
||||
- name: Check contents
|
||||
assert:
|
||||
that:
|
||||
- "'Synced' in wsrep_local_state_comment.stdout"
|
||||
- "'OPERATIONAL' in wsrep_evs_state.stdout"
|
||||
- "'10.100.100.101' in wsrep_incoming_addresses.stdout"
|
||||
- "'10.100.100.102' in wsrep_incoming_addresses.stdout"
|
||||
- "'10.100.100.103' in wsrep_incoming_addresses.stdout"
|
96
tests/test-prep.yml
Normal file
96
tests/test-prep.yml
Normal file
@ -0,0 +1,96 @@
|
||||
---
|
||||
# Copyright 2016, Rackspace US, 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.
|
||||
|
||||
- name: Playbook for pre-role testing 1of3
|
||||
hosts: 127.0.0.1
|
||||
connection: local
|
||||
become: false
|
||||
pre_tasks:
|
||||
- name: Create ssh key pair for root
|
||||
user:
|
||||
name: "{{ ansible_ssh_user }}"
|
||||
generate_ssh_key: "yes"
|
||||
ssh_key_bits: 2048
|
||||
ssh_key_file: ".ssh/id_rsa"
|
||||
- name: get the calling users key
|
||||
command: cat ~/.ssh/id_rsa.pub
|
||||
register: key_get
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ key_get.stdout }}"
|
||||
|
||||
- name: Playbook for pre-role testing 2of3
|
||||
hosts: localhost
|
||||
connection: local
|
||||
pre_tasks:
|
||||
- name: Ensure root's new public ssh key is in authorized_keys
|
||||
authorized_key:
|
||||
user: root
|
||||
key: "{{ hostvars['127.0.0.1']['lxc_container_ssh_key'] }}"
|
||||
manage_dir: no
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ hostvars['127.0.0.1']['lxc_container_ssh_key'] }}"
|
||||
roles:
|
||||
- role: "lxc_hosts"
|
||||
lxc_net_address: 10.100.100.1
|
||||
lxc_net_dhcp_range: 10.100.100.2,10.100.100.100
|
||||
lxc_net_bridge: lxcbr0
|
||||
lxc_kernel_options:
|
||||
- { key: 'fs.inotify.max_user_instances', value: 1024 }
|
||||
lxc_container_caches:
|
||||
- url: "https://rpc-repo.rackspace.com/container_images/rpc-trusty-container.tgz"
|
||||
name: "trusty.tgz"
|
||||
sha256sum: "56c6a6e132ea7d10be2f3e8104f47136ccf408b30e362133f0dc4a0a9adb4d0c"
|
||||
chroot_path: trusty/rootfs-amd64
|
||||
- role: "py_from_git"
|
||||
git_repo: "https://github.com/lxc/python2-lxc"
|
||||
git_dest: "/opt/lxc_python2"
|
||||
git_install_branch: "master"
|
||||
post_tasks:
|
||||
# THIS TASK IS ONLY BEING DONE BECAUSE THE TOX SHARED LXC LIB IS NOT USABLE ON A
|
||||
# HOST MACHINE THAT MAY NOT HAVE ACCESS TO THE VENV.
|
||||
- name: Ensure the lxc lib is on the host
|
||||
command: /usr/local/bin/pip install /opt/lxc_python2
|
||||
# Inventory is being pre-loaded using a post tasks instead of through a dynamic
|
||||
# inventory system. While this is not a usual method for deployment it's being
|
||||
# done for functional testing.
|
||||
- name: Create container hosts
|
||||
add_host:
|
||||
groups: "all,all_containers,galera_all"
|
||||
hostname: "{{ item.name }}"
|
||||
inventory_hostname: "{{ item.name }}"
|
||||
ansible_ssh_host: "{{ item.address }}"
|
||||
ansible_become: true
|
||||
properties:
|
||||
service_name: "{{ item.service }}"
|
||||
container_networks:
|
||||
management_address:
|
||||
address: "{{ item.address }}"
|
||||
bridge: "lxcbr0"
|
||||
interface: "eth1"
|
||||
netmask: "255.255.255.0"
|
||||
type: "veth"
|
||||
physical_host: localhost
|
||||
container_name: "{{ item.name }}"
|
||||
with_items:
|
||||
- { name: "container1", service: "service1", address: "10.100.100.101" }
|
||||
- { name: "container2", service: "service2", address: "10.100.100.102" }
|
||||
- { name: "container3", service: "service3", address: "10.100.100.103" }
|
||||
|
||||
- name: Playbook for pre-role testing 2of2
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: true
|
||||
roles:
|
||||
- role: "openstack_hosts"
|
219
tests/test.yml
219
tests/test.yml
@ -13,107 +13,13 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Playbook for pre-role testing 1of3
|
||||
hosts: 127.0.0.1
|
||||
connection: local
|
||||
become: false
|
||||
pre_tasks:
|
||||
- name: Create ssh key pair for root
|
||||
user:
|
||||
name: "{{ ansible_ssh_user }}"
|
||||
generate_ssh_key: "yes"
|
||||
ssh_key_bits: 2048
|
||||
ssh_key_file: ".ssh/id_rsa"
|
||||
- name: get the calling users key
|
||||
command: cat ~/.ssh/id_rsa.pub
|
||||
register: key_get
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ key_get.stdout }}"
|
||||
# Run basic prep
|
||||
- include: test-prep.yml
|
||||
|
||||
- name: Playbook for pre-role testing 2of3
|
||||
hosts: localhost
|
||||
connection: local
|
||||
pre_tasks:
|
||||
- name: Ensure root's new public ssh key is in authorized_keys
|
||||
authorized_key:
|
||||
user: root
|
||||
key: "{{ hostvars['127.0.0.1']['lxc_container_ssh_key'] }}"
|
||||
manage_dir: no
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ hostvars['127.0.0.1']['lxc_container_ssh_key'] }}"
|
||||
roles:
|
||||
- role: "lxc_hosts"
|
||||
lxc_net_address: 10.100.100.1
|
||||
lxc_net_dhcp_range: 10.100.100.2,10.100.100.100
|
||||
lxc_net_bridge: lxcbr0
|
||||
lxc_kernel_options:
|
||||
- { key: 'fs.inotify.max_user_instances', value: 1024 }
|
||||
lxc_container_caches:
|
||||
- url: "https://rpc-repo.rackspace.com/container_images/rpc-trusty-container.tgz"
|
||||
name: "trusty.tgz"
|
||||
sha256sum: "56c6a6e132ea7d10be2f3e8104f47136ccf408b30e362133f0dc4a0a9adb4d0c"
|
||||
chroot_path: trusty/rootfs-amd64
|
||||
- role: "py_from_git"
|
||||
git_repo: "https://github.com/lxc/python2-lxc"
|
||||
git_dest: "/opt/lxc_python2"
|
||||
git_install_branch: "master"
|
||||
post_tasks:
|
||||
# THIS TASK IS ONLY BEING DONE BECAUSE THE TOX SHARED LXC LIB IS NOT USABLE ON A
|
||||
# HOST MACHINE THAT MAY NOT HAVE ACCESS TO THE VENV.
|
||||
- name: Ensure the lxc lib is on the host
|
||||
command: /usr/local/bin/pip install /opt/lxc_python2
|
||||
# Inventory is being pre-loaded using a post tasks instead of through a dynamic
|
||||
# inventory system. While this is not a usual method for deployment it's being
|
||||
# done for functional testing.
|
||||
- name: Create container hosts
|
||||
add_host:
|
||||
groups: "all,all_containers,galera_all"
|
||||
hostname: "{{ item.name }}"
|
||||
inventory_hostname: "{{ item.name }}"
|
||||
ansible_ssh_host: "{{ item.address }}"
|
||||
ansible_become: true
|
||||
properties:
|
||||
service_name: "{{ item.service }}"
|
||||
container_networks:
|
||||
management_address:
|
||||
address: "{{ item.address }}"
|
||||
bridge: "lxcbr0"
|
||||
interface: "eth1"
|
||||
netmask: "255.255.255.0"
|
||||
type: "veth"
|
||||
physical_host: localhost
|
||||
container_name: "{{ item.name }}"
|
||||
with_items:
|
||||
- { name: "container1", service: "service1", address: "10.100.100.101" }
|
||||
- { name: "container2", service: "service2", address: "10.100.100.102" }
|
||||
- { name: "container3", service: "service3", address: "10.100.100.103" }
|
||||
|
||||
- name: Playbook for pre-role testing 2of2
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: true
|
||||
roles:
|
||||
- role: "openstack_hosts"
|
||||
|
||||
- name: Playbook for pre-role testing 2of2
|
||||
hosts: all_containers
|
||||
connection: local
|
||||
gather_facts: false
|
||||
roles:
|
||||
- role: "lxc_container_create"
|
||||
lxc_container_release: trusty
|
||||
lxc_container_backing_store: dir
|
||||
global_environment_variables:
|
||||
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
post_tasks:
|
||||
- name: Wait for ssh to be available
|
||||
local_action:
|
||||
module: wait_for
|
||||
port: "{{ ansible_ssh_port | default('22') }}"
|
||||
host: "{{ ansible_ssh_host | default(inventory_hostname) }}"
|
||||
search_regex: OpenSSH
|
||||
delay: 1
|
||||
# Run container clean up and build
|
||||
- include: test-container-create.yml
|
||||
|
||||
# Deploy the environment
|
||||
- name: Playbook for role testing
|
||||
hosts: galera_all
|
||||
serial: 1
|
||||
@ -132,69 +38,64 @@
|
||||
- role: "{{ rolename | basename }}"
|
||||
galera_server_id: "{{ inventory_hostname | string_2_int }}"
|
||||
|
||||
- name: Playbook for testing
|
||||
# Run playbook test
|
||||
- include: test-functional.yml
|
||||
|
||||
############################# UPGRADE TESTING #############################
|
||||
|
||||
# Run container clean up and build
|
||||
- include: test-container-create.yml
|
||||
|
||||
# Deploy the environment running a 5.5 to 10.0 upgrade
|
||||
- name: Playbook for role upgrade testing
|
||||
hosts: galera_all
|
||||
serial: 1
|
||||
user: root
|
||||
gather_facts: true
|
||||
vars:
|
||||
galera_root_password: secrete
|
||||
galera_root_user: root
|
||||
tasks:
|
||||
- name: Create DB for service on 10.100.100.101
|
||||
mysql_db:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "10.100.100.101"
|
||||
name: "OSA-test"
|
||||
state: "present"
|
||||
tags:
|
||||
- neutron-db-setup
|
||||
when: ansible_ssh_host == '10.100.100.101'
|
||||
- name: Grant access to the DB on 10.100.100.102
|
||||
mysql_user:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "10.100.100.102"
|
||||
name: "osa-tester"
|
||||
password: "tester-secrete"
|
||||
host: "{{ item }}"
|
||||
state: "present"
|
||||
priv: "OSA-test.*:ALL"
|
||||
with_items:
|
||||
- "localhost"
|
||||
- "%"
|
||||
tags:
|
||||
- neutron-db-setup
|
||||
when: ansible_ssh_host == '10.100.100.102'
|
||||
- name: check cluster state incoming addresses
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
-e "show status like 'wsrep_incoming_addresses';" \
|
||||
--silent \
|
||||
--skip-column-names
|
||||
register: wsrep_incoming_addresses
|
||||
- name: check cluster state
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
-e "show status like 'wsrep_local_state_comment';" \
|
||||
--silent \
|
||||
--skip-column-names
|
||||
register: wsrep_local_state_comment
|
||||
- name: check cluster state
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
-e "show status like 'wsrep_evs_state';" \
|
||||
--silent \
|
||||
--skip-column-names
|
||||
register: wsrep_evs_state
|
||||
- name: Check contents
|
||||
assert:
|
||||
that:
|
||||
- "'Synced' in wsrep_local_state_comment.stdout"
|
||||
- "'OPERATIONAL' in wsrep_evs_state.stdout"
|
||||
- "'10.100.100.101' in wsrep_incoming_addresses.stdout"
|
||||
- "'10.100.100.102' in wsrep_incoming_addresses.stdout"
|
||||
- "'10.100.100.103' in wsrep_incoming_addresses.stdout"
|
||||
galera_innodb_buffer_pool_size: 512M
|
||||
galera_innodb_log_buffer_size: 32M
|
||||
galera_server_id: "{{ inventory_hostname | string_2_int }}"
|
||||
galera_wsrep_node_name: "{{ inventory_hostname }}"
|
||||
galera_wsrep_provider_options:
|
||||
- { option: "gcache.size", value: "32M" }
|
||||
pre_tasks:
|
||||
- debug:
|
||||
msg: "===== Running MariaDB 5.5 Deployment for Upgrade ====="
|
||||
roles:
|
||||
- role: "{{ rolename | basename }}"
|
||||
galera_mariadb_server_package: "mariadb-galera-server-5.5"
|
||||
galera_apt_repo_url: "https://mirror.rackspace.com/mariadb/repo/5.5/ubuntu"
|
||||
galera_server_id: "{{ inventory_hostname | string_2_int }}"
|
||||
|
||||
# Run initial playbook test
|
||||
- include: test-functional.yml
|
||||
|
||||
# Deploy the environment running a 5.5 to 10.0 upgrade
|
||||
- name: Playbook for role upgrade testing
|
||||
hosts: galera_all
|
||||
serial: 1
|
||||
user: root
|
||||
gather_facts: true
|
||||
vars:
|
||||
galera_root_password: secrete
|
||||
galera_root_user: root
|
||||
galera_innodb_buffer_pool_size: 512M
|
||||
galera_innodb_log_buffer_size: 32M
|
||||
galera_server_id: "{{ inventory_hostname | string_2_int }}"
|
||||
galera_wsrep_node_name: "{{ inventory_hostname }}"
|
||||
galera_wsrep_provider_options:
|
||||
- { option: "gcache.size", value: "32M" }
|
||||
pre_tasks:
|
||||
- debug:
|
||||
msg: "===== Running MariaDB 5.5 to current Upgrade ====="
|
||||
roles:
|
||||
- role: "{{ rolename | basename }}"
|
||||
galera_server_id: "{{ inventory_hostname | string_2_int }}"
|
||||
galera_ignore_cluster_state: true
|
||||
galera_upgrade: true
|
||||
|
||||
# Run final playbook test
|
||||
- include: test-functional.yml
|
||||
|
Loading…
x
Reference in New Issue
Block a user