Execution
Date 08 Dec 2025 13:27:39 +0000
Duration 00:05:33.94
Controller aio1.openstack.local
User root
Versions
Ansible 2.18.6
ara 1.7.4 / 1.7.4
Python 3.12.3
Summary
2 Hosts
316 Tasks
313 Results
18 Plays
136 Files
0 Records

File: /home/zuul/src/opendev.org/openstack/openstack-ansible-openstack_hosts/tasks/openstack_hosts_configure_apt.yml

---
# Copyright 2017, 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.

# APT configuration tasks that apply on all nodes.

- name: Ensure /etc/apt/sources.list.d exists
  ansible.builtin.file:
    path: /etc/apt/sources.list.d
    state: directory
    owner: root
    group: root
    mode: "0755"

- name: Validate repo config is deb822 format
  vars:
    _repo_check: "{{ openstack_hosts_package_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 }}"

# NOTE(jrosser) remove this task for the 2025.2 release
- name: Clean up legacy repository config not in deb822 format
  vars:
    openstack_hosts_apt_repo_cleanup:
      - uca.list
      - osbpo.list
  ansible.builtin.file:
    path: "/etc/apt/sources.list.d/{{ item }}"
    state: absent
  register: _cleanup_apt_repositories
  with_items: "{{ openstack_hosts_apt_repo_cleanup }}"

- name: Add requirement packages (repositories gpg keys, toolkits...)
  ansible.builtin.apt:
    name: "{{ openstack_hosts_package_list | rejectattr('state', 'equalto', 'absent') | map(attribute='name') | list }}"
    state: "{{ openstack_hosts_package_state }}"
    update_cache: true
    cache_valid_time: "{{ cache_timeout }}"
  register: _install_packages
  until: _install_packages  is success
  retries: 5
  delay: 2

- 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: "{{ openstack_hosts_package_repos }}"
  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: _manage_apt_repositories

- name: Add apt extra conf
  ansible.builtin.copy:
    content: "{{ openstack_hosts_package_manager_default_conf + openstack_hosts_package_manager_extra_conf }}"
    dest: /etc/apt/apt.conf.d/99openstack-ansible
    mode: "0644"
  when:
    - openstack_hosts_package_manager_extra_conf | length > 0 or openstack_hosts_package_manager_default_conf | length > 0

- name: Update Apt cache
  ansible.builtin.apt:
    update_cache: true
  when:
    - (_manage_apt_repositories is changed) or (_cleanup_apt_repositories is changed)
  register: _update_apt_cache
  until: _update_apt_cache  is success
  changed_when: false
  retries: 5
  delay: 2