openstack-ansible-galera_se.../tasks/galera_install_apt.yml

103 lines
3.2 KiB
YAML

---
# 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: Add galera apt-keys
block:
- name: Add keys (primary keyserver)
apt_key:
id: "{{ item.hash_id }}"
keyserver: "{{ item.keyserver | default(omit) }}"
data: "{{ item.data | default(omit) }}"
url: "{{ item.url | default(omit) }}"
state: "present"
register: add_keys
until: add_keys | success
retries: 5
delay: 2
with_items: "{{ galera_gpg_keys }}"
rescue:
- name: Add keys (fallback keyserver)
apt_key:
id: "{{ item.hash_id }}"
keyserver: "{{ item.fallback_keyserver | default(omit) }}"
url: "{{ item.fallback_url | default(omit) }}"
state: "present"
register: add_keys_fallback
until: add_keys_fallback | success
retries: 5
delay: 2
with_items: "{{ galera_gpg_keys }}"
when:
- item.fallback_keyserver is defined or item.fallback_url is defined
- name: Remove old repos
lineinfile:
dest: "/etc/apt/sources.list.d/{{ item.name }}.list"
regexp: "^((?!{{ item.repo }}).*)$"
state: absent
with_items:
- { name: "MariaDB", repo: "{{ galera_repo.repo }}" }
- { name: "Percona", repo: "{{ galera_percona_xtrabackup_repo.repo }}" }
- name: Add galera repo
apt_repository:
repo: "{{ galera_repo.repo }}"
filename: "{{ galera_repo.filename | default(omit) }}"
state: "{{ galera_repo.state }}"
update_cache: "no"
register: add_galera_repo
- name: Add percona repo
apt_repository:
repo: "{{ galera_percona_xtrabackup_repo.repo }}"
filename: "{{ galera_percona_xtrabackup_repo.filename | default(omit) }}"
state: "{{ galera_percona_xtrabackup_repo.state }}"
update_cache: "no"
register: add_percona_repo
- name: Preseed galera password(s)
debconf:
name: "{{ item.name }}"
question: "{{ item.question }}"
value: "{{ item.value }}"
vtype: "{{ item.vtype }}"
with_items: "{{ galera_debconf_items }}"
no_log: yes
- name: Prevent galera from starting on install
copy:
src: "policy-rc.d"
dest: "/usr/sbin/policy-rc.d"
mode: "0755"
backup: yes
changed_when: false
- name: Install galera_server role remote packages (apt)
apt:
name: "{{ galera_packages_list }}"
state: "{{ galera_server_package_state }}"
update_cache: yes
cache_valid_time: "{{ (add_galera_repo | changed or add_percona_repo | changed) | ternary('0', cache_timeout) }}"
register: install_remote_apt_packages
until: install_remote_apt_packages|success
retries: 5
delay: 2
- name: Remove policy-rc now that the package install is complete
file:
path: "/usr/sbin/policy-rc.d"
state: absent
changed_when: false