Updated repo for new org

The role was changed to make it compatible with the OpenStack
CI. The changes effect defaults, handlers, and the tests for 
the role and adds gitignore/review files. 

The changes essentially get the role to a state where its passing
the tests which are spinning up a galera cluster, adding users 
and databases, and then testing integrity from every node. The 
tests specifically ensure we're able to guarantee that after the
role runs everything works. Previously to these changes the role
assumed everything was working and nothing had been done to 
guarantee cluster state. 

In the handler changes, the temporary "sst" directory is cleaned up
should the handler restart fail. This ensure that a node is in a clean
state if a leftover sst directory was on the disk which would cause 
a node to fail to join a cluster or bootstrap. Additionally the 
environment variable "MYSQLD_STARTUP_TIMEOUT" is now being passed
into the init script because the defaults are not being sourced
at the init script runtime. 

In the task changes a new configuration file, that is part of the 
mariadb package, is being removed which has unforeseen options within
it causing no logs to be created.

the default option "galera_innodb_additional_mem_pool_size" was removed
because its no longer valid within MariaDB10 and we'd never caught that
error message until now.

The tests were updated to support running the role from a user which 
was not root.

Change-Id: I16af30c660790656fc2d59f9943c172b88098905
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2015-12-10 11:46:19 -06:00
parent 25a9eb3901
commit cd11c5a56e
10 changed files with 162 additions and 13 deletions

62
.gitignore vendored Normal file
View File

@ -0,0 +1,62 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc
build/
dist/
doc/build/
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
.idea
.tox
*.sublime*
*.egg-info
Icon?
ehthumbs.db
Thumbs.db
.eggs
# User driven backup files #
############################
*.bak
# Generated by pbr while building docs
######################################
AUTHORS
ChangeLog
# Files created by releasenotes build
releasenotes/build
# Test temp files
tests/plugins

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=openstack/openstack-ansible-galera_server.git

View File

@ -44,7 +44,6 @@ galera_wait_timeout: 28800
## innodb options
galera_innodb_buffer_pool_size: 4096M
galera_innodb_additional_mem_pool_size: 24M
galera_innodb_log_file_size: 1024M
galera_innodb_log_buffer_size: 128M

View File

@ -18,8 +18,30 @@
name: mysql
state: restarted
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|success
failed_when: false
notify:
- "remove stale .sst"
- "Restart mysql fall back"
- name: remove stale .sst
file:
path: "/var/lib/mysql/.sst"
state: absent
when: galera_restart | failed
- name: Restart mysql fall back
service:
name: mysql
state: restarted
args: "{{ (not galera_existing_cluster | bool and inventory_hostname == galera_server_bootstrap_node) | ternary('--wsrep-new-cluster', '') }}"
environment:
MYSQLD_STARTUP_TIMEOUT: 180
when: galera_restart | failed
register: galera_restart_fall_back
until: galera_restart_fall_back | success
retries: 3
delay: 2
delay: 5

View File

@ -66,6 +66,13 @@
tags:
- galera-config
- name: remove default mysql_safe_syslog
file:
path: "/etc/mysql/conf.d/mysqld_safe_syslog.cnf"
state: absent
tags:
- galera-config
- name: Remove policy-rc
file:
path: "/usr/sbin/policy-rc.d"

View File

@ -15,6 +15,7 @@ socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
log_error = /var/log/mysql_logs/galera_server_error.log
[mysql]
@ -66,7 +67,6 @@ table-open-cache = 10240
# INNODB #
innodb-flush-method = O_DIRECT
innodb-additional-mem-pool-size = {{ galera_innodb_additional_mem_pool_size }}
innodb-log-file-size = {{ galera_innodb_log_file_size }}
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1

View File

@ -23,7 +23,11 @@
src: https://git.openstack.org/openstack/openstack-ansible-lxc_container_create
scm: git
version: master
- name: galera_client
src: https://github.com/os-cloud/openstack-ansible-galera_client
- name: openstack_hosts
src: https://git.openstack.org/openstack/openstack-ansible-openstack_hosts
scm: git
version: master
- name: galera_client
src: https://git.openstack.org/openstack/openstack-ansible-galera_client
scm: git
version: master

View File

@ -7,3 +7,6 @@ action_plugins = ../../plugins/actions
library = ../../plugins/library
host_key_checking = False
[ssh_connection]
control_path = /tmp/%%h-%%r

View File

@ -1,2 +1,6 @@
[all]
localhost ansible_connection=local ansible_become=True
[hosts]
localhost ansible_ssh_host=127.0.0.1

View File

@ -13,13 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Playbook for pre-role testing 1of2
hosts: localhost
- name: Playbook for pre-role testing 1of3
hosts: 127.0.0.1
connection: local
become: false
pre_tasks:
- name: Ensure root ssh key
- name: Create ssh key pair for root
user:
name: "{{ ansible_env.USER | default('root') }}"
name: "{{ ansible_ssh_user }}"
generate_ssh_key: "yes"
ssh_key_bits: 2048
ssh_key_file: ".ssh/id_rsa"
@ -28,10 +29,22 @@
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.253
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 }
@ -71,7 +84,7 @@
address: "{{ item.address }}"
bridge: "lxcbr0"
interface: "eth1"
netmask: "255.255.252.0"
netmask: "255.255.255.0"
type: "veth"
physical_host: localhost
container_name: "{{ item.name }}"
@ -80,6 +93,13 @@
- { 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
@ -90,17 +110,41 @@
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
- name: Playbook for role 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" }
roles:
- role: "{{ rolename | basename }}"
galera_server_id: "{{ inventory_hostname | string_2_int }}"
post_tasks:
- name: Playbook for testing
hosts: galera_all
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 }}"