openstack-ansible/playbooks/roles/galera_server/tasks/galera_pre_install.yml
git-harry 4a860f715c Restart mysql when config changed
Currently mysql is only (re)started when creating a cluster, adding a
node or the service isn't running. This means changes to configuration
files are not used.

This commit moves the restart functionality to a handler and sets
notifies on the the appropriate tasks so that when the config is changes
mysql is restarted.

This commit modifies the galera play to run in serial so that only one
instance of mysql can be restarted at a time. This is to prevent the
possibility of them all being restarted in one go. An additional play
'Check galera cluster status' has been added, this makes an attempt to
check that the cluster is healthy before proceeding with any possible
config changes. The checks can be overridden by setting
'galera_ignore_cluster_state=true' when running the playbook.

A facts module has been added to gather information about the status of
the cluster for use by the galera-install playbook.

DocImpact
Closes-bug: #1449958

Change-Id: Id83ba642c114d1f5cac04cc219be151a82a1023f
2015-07-12 18:04:10 +01:00

104 lines
2.4 KiB
YAML

---
# Copyright 2014, 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: Update apt sources
apt:
update_cache: yes
cache_valid_time: 600
register: apt_update
until: apt_update|success
retries: 5
delay: 2
tags:
- galera-apt-packages
- name: Install galera pre packages
apt:
pkg: "{{ item }}"
state: latest
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: galera_pre_apt_packages
tags:
- galera-pre-apt-packages
- name: Add galera apt-keys
apt_key:
id: "{{ item.hash_id }}"
keyserver: "{{ item.keyserver }}"
state: "present"
register: add_keys
until: add_keys|success
ignore_errors: True
retries: 5
delay: 2
with_items: galera_gpg_keys
tags:
- galera-apt-keys
- name: Add galera apt-keys using fallback keyserver
apt_key:
id: "{{ item.hash_id }}"
keyserver: "{{ item.fallback_keyserver }}"
state: "present"
register: add_keys_fallback
until: add_keys_fallback|success
retries: 5
delay: 2
with_items: galera_gpg_keys
when: add_keys|failed and item.fallback_keyserver is defined
tags:
- galera-apt-keys
- name: Drop galera repo pin
template:
src: "galera_pin.pref.j2"
dest: "/etc/apt/preferences.d/galera_pin.pref"
owner: "root"
group: "root"
mode: "0644"
tags:
- galera-repo-pin
- name: Add galera repo(s)
apt_repository:
repo: "{{ galera_apt_repo.repo }}"
state: "{{ galera_apt_repo.state }}"
register: add_repos
until: add_repos|success
retries: 5
delay: 2
tags:
- galera-repos
- name: Prevent galera from starting on install
copy:
src: "policy-rc.d"
dest: "/usr/sbin/policy-rc.d"
mode: "0755"
backup: yes
tags:
- galera-config
- name: Drop limits config
template:
src: "limits.conf.j2"
dest: "/etc/security/limits.conf"
notify: Restart mysql
tags:
- galera-config