Remove references to unsupported operating systems

All references to Gentoo, SUSE, Debian stretch and Centos-7  are removed.
Conditional tasks, ternary operators and variables are simplified where possible
OS specific variables files are generalised where possible

Change-Id: I50bb0f00658e292f39269c3980109e56319a00ca
This commit is contained in:
Jonathan Rosser 2021-03-16 09:23:50 +00:00
parent 27e938b38b
commit 49b7d9488b
9 changed files with 154 additions and 438 deletions

View File

@ -22,17 +22,14 @@ galaxy_info:
platforms:
- name: Debian
versions:
- stretch
- buster
- name: Ubuntu
versions:
- xenial
- bionic
- focal
- name: EL
versions:
- 7
- name: opensuse
versions:
- 15
- 8
categories:
- cloud
- galera

View File

@ -1 +0,0 @@
galera_install_yum.yml

View File

@ -0,0 +1,150 @@
---
# 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.
# Unfortunately yum is case-insensitive, and RDO has mariadb-* packages,
# while the MariaDB repo has MariaDB-* packages and they conflict.
# To work around this we have to query for any installed RDO/CentOS
# packages using rpm, then remove them. We have to remove them without
# dependencies, otherwise for distro package installation types on shared
# hosts it removes far too many packages.
- name: Remove conflicting packages
shell: |
exit_code=0
for pkg in {{ galera_mariadb_distro_packages_remove | join(' ') }}; do
if rpm --query --quiet ${pkg}; then
rpm -ev --nodeps ${pkg}
exit_code=2
fi
done
exit ${exit_code}
register: _remove_existing_mariadb_packages
changed_when: _remove_existing_mariadb_packages.rc == 2
failed_when: _remove_existing_mariadb_packages.rc not in [0, 2]
args:
warn: no
executable: /bin/bash
# In CentOS systems, /etc/my.cnf.d may already exist on the
# system. We need to ensure that it is removed if that is true so
# that we can replace it with symlinks to the directories expected
# to be used by the MariaDB packages instead.
- name: Stat /etc/my.cnf.d
stat:
path: /etc/my.cnf.d
get_attributes: no
get_checksum: no
get_mime: no
register: mycnfd_stat
- name: Destroy my.cnf.d dir if is dir
file:
path: /etc/my.cnf.d
state: absent
force: true
when:
- mycnfd_stat.stat.isdir is defined
- mycnfd_stat.stat.isdir
# We replace the default paths for the system with symlinks to
# the paths used by the MariaDB packages so ensure that any other
# system expectations are still met.
- name: Update the local file system CRUD
file:
src: "{{ item.src | default(omit) }}"
path: "{{ item.path }}"
state: "{{ item.state }}"
force: "{{ item.force | default(omit) }}"
mode: "{{ item.mode | default(omit) }}"
with_items:
- path: "/etc/mysql"
state: "directory"
mode: '0755'
- path: "/etc/mysql/conf.d"
state: "directory"
- src: "/usr/lib64/galera"
path: "/usr/lib/galera"
state: "link"
force: true
- src: "/etc/mysql/conf.d"
path: "/etc/my.cnf.d"
state: "link"
force: true
- src: "/etc/mysql/my.cnf"
path: "/etc/my.cnf"
state: "link"
force: true
- name: If a keyfile is provided, copy the gpg keyfile to the key location
copy:
src: "gpg/{{ item.key | basename }}"
dest: "{{ item.key }}"
mode: '0644'
with_items: "{{ galera_gpg_keys }}"
- name: Install gpg keys
rpm_key: "{{ key }}"
with_items: "{{ galera_gpg_keys }}"
loop_control:
loop_var: key
register: _add_yum_keys
until: _add_yum_keys is success
retries: 5
delay: 2
- name: Add galera repo
yum_repository:
name: "{{ galera_repo.name }}"
description: "{{ galera_repo.description }}"
baseurl: "{{ galera_repo.baseurl }}"
gpgkey: "{{ galera_repo.gpgkey | default(omit) }}"
gpgcheck: yes
enabled: yes
priority: 25
register: add_galera_repos
until: add_galera_repos is success
retries: 5
delay: 2
- name: Enable module_hotfixes
lineinfile:
dest: "/etc/yum.repos.d/{{ galera_repo.name }}.repo"
line: "module_hotfixes=1"
regexp: "^module_hotfixes"
insertafter: "^enabled"
# When changing the repo URL, the metadata does
# not reliably update, resulting in the right
# URL being used, but the wrong package list.
# This is why we force the metadata to be
# cleaned out whenever the repo config changes.
- name: Force the expiry of the repo metadata
command: "{{ ansible_facts['pkg_mgr'] }} clean metadata"
args:
warn: no
when: add_galera_repos is changed
tags:
- skip_ansible_lint
- name: Install galera role remote packages
package:
name: "{{ galera_packages_list }}"
state: "{{ galera_package_state }}"
register: install_remote_packages
until: install_remote_packages is success
retries: 5
delay: 2
notify:
- Manage LB
- Restart all mysql

View File

@ -1,42 +0,0 @@
---
# Copyright 2019, Matthew Thode
#
# 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: Install galera role packages
package:
name: "{{ galera_packages_list }}"
state: "{{ galera_package_state }}"
newuse: "{{ (ansible_facts['pkg_mgr'] == 'portage') | ternary('yes', omit) }}"
changed_use: "{{ (ansible_facts['pkg_mgr'] == 'portage') | ternary('yes', omit) }}"
noreplace: "{{ (ansible_facts['pkg_mgr'] == 'portage') | ternary('yes', omit) }}"
jobs: "{{ (ansible_facts['pkg_mgr'] == 'portage') | ternary('4', omit) }}"
register: install_remote_packages
until: install_remote_packages is success
retries: 5
delay: 2
notify:
- Manage LB
- Restart all mysql
- name: Ensure mysql config directories exists
file:
src: "{{ item.src | default(omit) }}"
path: "{{ item.path }}"
state: "{{ item.state }}"
force: "{{ item.force | default(omit) }}"
with_items:
- path: "/etc/mysql"
state: "directory"
- path: "{{ galera_etc_include_dir }}"
state: "directory"

View File

@ -1,151 +0,0 @@
---
# 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.
# Unfortunately yum is case-insensitive, and RDO has mariadb-* packages,
# while the MariaDB repo has MariaDB-* packages and they conflict.
# To work around this we have to query for any installed RDO/CentOS
# packages using rpm, then remove them. We have to remove them without
# dependencies, otherwise for distro package installation types on shared
# hosts it removes far too many packages.
- name: Remove conflicting packages
shell: |
exit_code=0
for pkg in {{ galera_mariadb_distro_packages_remove | join(' ') }}; do
if rpm --query --quiet ${pkg}; then
rpm -ev --nodeps ${pkg}
exit_code=2
fi
done
exit ${exit_code}
register: _remove_existing_mariadb_packages
changed_when: _remove_existing_mariadb_packages.rc == 2
failed_when: _remove_existing_mariadb_packages.rc not in [0, 2]
args:
warn: no
executable: /bin/bash
# In SUSE/CentOS systems, /etc/my.cnf.d may already exist on the
# system. We need to ensure that it is removed if that is true so
# that we can replace it with symlinks to the directories expected
# to be used by the MariaDB packages instead.
- name: Stat /etc/my.cnf.d
stat:
path: /etc/my.cnf.d
get_attributes: no
get_checksum: no
get_mime: no
register: mycnfd_stat
- name: Destroy my.cnf.d dir if is dir
file:
path: /etc/my.cnf.d
state: absent
force: true
when:
- mycnfd_stat.stat.isdir is defined
- mycnfd_stat.stat.isdir
# We replace the default paths for the system with symlinks to
# the paths used by the MariaDB packages so ensure that any other
# system expectations are still met.
- name: Update the local file system CRUD
file:
src: "{{ item.src | default(omit) }}"
path: "{{ item.path }}"
state: "{{ item.state }}"
force: "{{ item.force | default(omit) }}"
mode: "{{ item.mode | default(omit) }}"
with_items:
- path: "/etc/mysql"
state: "directory"
mode: '0755'
- path: "/etc/mysql/conf.d"
state: "directory"
- src: "/usr/lib64/galera"
path: "/usr/lib/galera"
state: "link"
force: true
- src: "/etc/mysql/conf.d"
path: "/etc/my.cnf.d"
state: "link"
force: true
- src: "/etc/mysql/my.cnf"
path: "/etc/my.cnf"
state: "link"
force: true
- name: If a keyfile is provided, copy the gpg keyfile to the key location
copy:
src: "gpg/{{ item.key | basename }}"
dest: "{{ item.key }}"
mode: '0644'
with_items: "{{ galera_gpg_keys }}"
- name: Install gpg keys
rpm_key: "{{ key }}"
with_items: "{{ galera_gpg_keys }}"
loop_control:
loop_var: key
register: _add_yum_keys
until: _add_yum_keys is success
retries: 5
delay: 2
- name: Add galera repo
yum_repository:
name: "{{ galera_repo.name }}"
description: "{{ galera_repo.description }}"
baseurl: "{{ galera_repo.baseurl }}"
gpgkey: "{{ galera_repo.gpgkey | default(omit) }}"
gpgcheck: yes
enabled: yes
priority: 25
register: add_galera_repos
until: add_galera_repos is success
retries: 5
delay: 2
- name: Enable module_hotfixes
lineinfile:
dest: "/etc/yum.repos.d/{{ galera_repo.name }}.repo"
line: "module_hotfixes=1"
regexp: "^module_hotfixes"
insertafter: "^enabled"
when: ansible_facts['distribution_major_version'] is version('8', '>=')
# When changing the repo URL, the metadata does
# not reliably update, resulting in the right
# URL being used, but the wrong package list.
# This is why we force the metadata to be
# cleaned out whenever the repo config changes.
- name: Force the expiry of the repo metadata
command: "{{ ansible_facts['pkg_mgr'] }} clean metadata"
args:
warn: no
when: add_galera_repos is changed
tags:
- skip_ansible_lint
- name: Install galera role remote packages
package:
name: "{{ galera_packages_list }}"
state: "{{ galera_package_state }}"
register: install_remote_packages
until: install_remote_packages is success
retries: 5
delay: 2
notify:
- Manage LB
- Restart all mysql

View File

@ -1,97 +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.
- name: Remove conflicting distro packages
package:
name: "{{ galera_mariadb_distro_packages_remove }}"
state: absent
# In SUSE/CentOS systems, /etc/my.cnf.d may already exist on the
# system. We need to ensure that it is removed if that is true so
# that we can replace it with symlinks to the directories expected
# to be used by the MariaDB packages instead.
- name: Stat /etc/my.cnf.d
stat:
path: /etc/my.cnf.d
get_attributes: no
get_checksum: no
get_mime: no
register: mycnfd_stat
- name: Destroy my.cnf.d dir if is dir
file:
path: /etc/my.cnf.d
state: absent
force: true
when:
- mycnfd_stat.stat.isdir is defined
- mycnfd_stat.stat.isdir
# We replace the default paths for the system with symlinks to
# the paths used by the MariaDB packages so ensure that any other
# system expectations are still met.
- name: Update the local file system CRUD
file:
src: "{{ item.src|default(omit) }}"
path: "{{ item.path }}"
state: "{{ item.state }}"
force: "{{ item.force|default(omit) }}"
with_items:
- { path: "/etc/mysql", state: "directory" }
- { path: "/etc/mysql/conf.d", state: "directory" }
- { src: "/etc/mysql/conf.d", path: "/etc/my.cnf.d", state: "link", force: true }
- { src: "/etc/mysql/my.cnf", path: "/etc/my.cnf", state: "link", force: true }
- name: If a keyfile is provided, copy the gpg keyfile to the key location
copy:
src: "gpg/{{ item.key | basename }}"
dest: "{{ item.key }}"
mode: '0644'
with_items: "{{ galera_gpg_keys }}"
- name: Install gpg keys
rpm_key: "{{ key }}"
with_items: "{{ galera_gpg_keys }}"
loop_control:
loop_var: key
register: _add_zypper_keys
until: _add_zypper_keys is success
retries: 5
delay: 2
- name: Add galera repo
zypper_repository:
name: "{{ galera_repo.name }}"
description: "{{ galera_repo.description }}"
repo: "{{ galera_repo.baseurl }}"
autorefresh: yes
auto_import_keys: no
enabled: yes
register: add_repos
until: add_repos is success
retries: 5
delay: 2
- name: Install galera_server role remote packages (zypper)
zypper:
name: "{{ galera_packages_list }}"
state: "{{ galera_package_state }}"
register: install_remote_packages
until: install_remote_packages is success
retries: 5
delay: 2
notify:
- Manage LB
- Restart all mysql

View File

@ -46,7 +46,6 @@
# as all of these tasks will be run on Package install
# and running them again will cause a conflict within
# debian based deployments.
# NOTE(prometheanfire): Ditto Gentoo ^
- name: Create galera initial secure tool
template:
src: "galera_secure_node.j2"
@ -54,7 +53,6 @@
mode: "0750"
when:
- ansible_facts['pkg_mgr'] != "apt"
- ansible_facts['pkg_mgr'] != "portage"
- not galera_upgrade
- name: Run galera secure
@ -64,7 +62,6 @@
warn: no
when:
- ansible_facts['pkg_mgr'] != "apt"
- ansible_facts['pkg_mgr'] != "portage"
- not galera_upgrade
tags:
- skip_ansible_lint
@ -129,20 +126,11 @@
- Manage LB
- Restart all mysql
# Safe to run multiple times, config has it's own checks
- name: initialize database (gentoo)
command: "emerge --config dev-db/mariadb"
failed_when: false
when:
- ansible_facts['pkg_mgr'] == 'portage'
- name: Apply service defaults
template:
src: "mysql_defaults.j2"
dest: "/etc/default/mariadb"
mode: "0644"
when:
- ansible_facts['pkg_mgr'] != 'portage'
notify:
- Manage LB
- Restart all mysql
@ -154,8 +142,6 @@
dest: "/etc/default/mysql"
state: "link"
force: "yes"
when:
- ansible_facts['pkg_mgr'] != 'portage'
- name: remove default mysql_safe_syslog
file:

View File

@ -1,48 +0,0 @@
---
# Copyright 2019, Matthew Thode
#
# 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.
## APT Cache Options
cache_timeout: 600
# Default private device setting
_galera_disable_privatedevices: yes
galera_server_required_distro_packages:
- sys-apps/xinetd
galera_etc_conf_file: "/etc/mysql/my.cnf"
galera_etc_include_dir: "/etc/mysql/conf.d"
galera_var_run_socket: "/var/run/mysqld/mysqld.sock"
# The package name for mariaDB is set as a variable
# so that it can be used in debconf later in the
# "galera_common" role.
_galera_mariadb_server_package: "dev-db/mariadb"
# NB This is specifically galera_server_mariadb_distro_packages as these
# packages only get installed during the galera play - this is because of
# the preseed task and the service startup control used when installing
# mariadb-galera-server and galera.
galera_server_mariadb_distro_packages:
- "{{ galera_mariadb_server_package }}"
- sys-cluster/galera
- net-misc/rsync
- net-misc/socat
- dev-python/mysql-python
# The packages to uninstall during an upgrade from a previous version
galera_server_upgrade_packages_remove:
galera_wsrep_provider: "/usr/lib64/galera/libgalera_smm.so"

View File

@ -32,7 +32,7 @@ galera_server_required_distro_packages:
- libgcrypt
- MariaDB-client
- MariaDB-devel
- "{{ ansible_facts['distribution_major_version'] is version('8', '<') | ternary('MySQL-python', 'python3-PyMySQL') }}" # needed by mysql_user
- python3-PyMySQL
- xinetd
galera_etc_conf_file: "/etc/mysql/my.cnf"

View File

@ -1,78 +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.
# Galera GPG Keys
_galera_gpg_keys:
# MariaDB Package Signing Key <package-signing-key@mariadb.org>
- key: /etc/pki/RPM-GPG-KEY-MariaDB
# Default private device setting
_galera_disable_privatedevices: yes
galera_server_required_distro_packages:
- galera
- gpg2
- libaio-devel
- libstdc++-devel
- libgcrypt-devel
- MariaDB-client
- MariaDB-devel
- python-MySQL-python # needed by mysql_user
- python3-PyMySQL
- xinetd
galera_etc_conf_file: "/etc/mysql/my.cnf"
galera_etc_include_dir: "/etc/mysql/conf.d"
galera_var_run_socket: "/var/lib/mysql/mysql.sock"
_galera_mariadb_server_package: "MariaDB-server"
galera_server_mariadb_distro_packages:
- which
- "{{ galera_mariadb_server_package }}"
- MariaDB-backup
- MariaDB-shared
- rsync
- socat
# Conflicting packages with those from the MariaDB repository
galera_mariadb_distro_packages_remove:
- libmariadb-devel
- mariadb
- mariadb-client
- mariadb-tools
# The packages to uninstall during an upgrade from a previous version
galera_server_upgrade_packages_remove:
- MariaDB-Galera-server
- MariaDB-server
_galera_opensuse_dir: "{{ ansible_facts['distribution_major_version'] }}"
_galera_repo_url: "http://{{ galera_repo_host }}/MariaDB/mariadb-{{ galera_major_version }}.{{ galera_minor_version }}/yum/opensuse{{ _galera_opensuse_dir }}-amd64"
_galera_repo:
name: MariaDB
description: "MariaDB Repo"
baseurl: "{{ galera_repo_url }}"
galera_wsrep_provider: "/usr/lib64/galera/libgalera_smm.so"
galera_unix_socket: "/var/lib/mysqld/mysqld.sock"
mariadb_delete_etc_conf_files:
- default_plugins.cnf
- galera.cnf
- error_log.cnf
galera_client_distro_packages:
- MariaDB-client