Files
openstack-ansible-galera_se…/tasks/galera_install_apt.yml
Dmitriy Rabotyagov d887be4b80 Use loop label for deb822_repository
The module has quite massive output due to included GPG key
into the structure, which makes it barely readable.

Using loop label on the module will limit output to necessary set
of arguments.

Change-Id: I6aa4ea1b0c4151fdde2dbe26c02949cd12b77e4c
Signed-off-by: Dmitriy Rabotyagov <dmitriy.rabotyagov@cleura.com>
2025-09-01 12:24:06 +02:00

106 lines
3.8 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: Validate repo config is deb822 format
vars:
_repo_check: "{{ galera_repo | selectattr('repo', 'defined') | map(attribute='repo') }}"
ansible.builtin.assert:
that: _repo_check | length == 0
fail_msg: "The following repository definitions must be updated to deb822 format {{ _repo_check }}"
- name: Remove conflicting distro packages
ansible.builtin.package:
name: "{{ galera_mariadb_distro_packages_remove | default([]) }}"
state: absent
when: galera_install_method == 'external_repo'
# NOTE(jrosser) remove this task for the 2025.2 release
- name: Clean up legacy repository config not in deb822 format
vars:
galera_apt_repo_cleanup:
- MariaDB.list
ansible.builtin.file:
path: "/etc/apt/sources.list.d/{{ item }}"
state: absent
with_items: "{{ galera_apt_repo_cleanup }}"
register: apt_repo_removed
- name: Ensure python3-debian package is available
ansible.builtin.apt:
name: python3-debian
- name: Manage apt repositories
ansible.builtin.deb822_repository:
allow_downgrade_to_insecure: "{{ item.allow_downgrade_to_insecure | default(omit) }}"
allow_insecure: "{{ item.allow_insecure | default(omit) }}"
allow_weak: "{{ item.allow_weak | default(omit) }}"
architectures: "{{ item.architectures | default(omit) }}"
by_hash: "{{ item.by_hash | default(omit) }}"
check_date: "{{ item.check_date | default(omit) }}"
check_valid_until: "{{ item.check_valid_until | default(omit) }}"
components: "{{ item.components | default(omit) }}"
date_max_future: "{{ item.date_max_future | default(omit) }}"
enabled: "{{ item.enabled | default(omit) }}"
inrelease_path: "{{ item.inrelease_path | default(omit) }}"
languages: "{{ item.languages | default(omit) }}"
mode: "{{ item.mode | default(omit) }}"
name: "{{ item.name }}"
pdiffs: "{{ item.pdiffs | default(omit) }}"
signed_by: "{{ item.signed_by | default(omit) }}"
state: "{{ item.state | default(omit) }}"
suites: "{{ item.suites | default(omit) }}"
targets: "{{ item.targets | default(omit) }}"
trusted: "{{ item.trusted | default(omit) }}"
types: "{{ item.types | default(omit) }}"
uris: "{{ item.uris | default(omit) }}"
loop: "{{ galera_repo }}"
loop_control:
label: "{{ loop_label | to_json }}"
vars:
loop_label:
name: "{{ item.name }}"
uris: "{{ item.uris | default('') }}"
state: "{{ item.state | default('present') }}"
suites: "{{ item.suites | default('') }}"
register: deb822_repos
- name: Update apt repositories when config is changed
ansible.builtin.apt:
update_cache: true
when: (apt_repo_removed is changed) or (deb822_repos is changed)
- name: Preseed galera password(s)
ansible.builtin.debconf:
name: "{{ item.name }}"
question: "{{ item.question }}"
value: "{{ item.value }}"
vtype: "{{ item.vtype }}"
with_items: "{{ galera_debconf_items }}"
no_log: true
- name: Install galera role remote packages (apt)
ansible.builtin.apt:
name: "{{ galera_packages_list }}"
state: "{{ galera_package_state }}"
policy_rc_d: 101
update_cache: true
cache_valid_time: "{{ cache_timeout }}"
register: install_remote_apt_packages
until: install_remote_apt_packages is success
retries: 5
delay: 2
notify:
- Restart all mysql