openstack-ansible-ceph_client/tasks/ceph_preinstall_apt.yml
Dmitriy Rabotyagov 7f73f730ff Map all relevant architectures for deb822 repository setup
At the moment we fixup only x86_64 arch while there way more arches
in the wild. So it's worth to have a mapping for architectures in place
rather then maintain quite complex replaces.

Related-Bug: #2081764
Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-openstack_hosts/+/930272
Change-Id: Ia695be454060cfcce83e072828db71331c8d6928
2024-09-24 11:41:25 +02:00

86 lines
3.2 KiB
YAML

---
# Copyright 2016 IBM Corp
#
# 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: "{{ ceph_repos | 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 }}"
when:
- ceph_pkg_source == 'ceph'
# NOTE(jrosser) remove this task for the 2025.2 release
- name: Find legacy repository files
find:
paths: /etc/apt/sources.list.d/
patterns: "{{ ceph_repo_url | urlsplit('hostname') | replace('.', '_') }}_*.list"
register: _legacy_apt_repos
- name: Clean up legacy repository config not in deb822 format
file:
path: "{{ item['path'] }}"
state: absent
with_items: "{{ _legacy_apt_repos['files'] }}"
register: apt_repo_removed
- name: Ensure python3-debian package is available
apt:
name: python3-debian
- name: Manage apt repositories
vars:
loop_label:
name: "{{ item.name }}"
uris: "{{ item.uris | default('') }}"
state: "{{ item.state | default('present') }}"
suites: "{{ item.suites | default('') }}"
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: "{{ ceph_repos }}"
loop_control:
label: "{{ loop_label | to_json }}"
register: deb822_repos
- name: Update Apt cache
apt:
update_cache: yes
when: (apt_repo_removed is changed) or (deb822_repos is changed)
register: update_apt_cache
until: update_apt_cache is success
retries: 5
delay: 2