Files
openstack-ansible-lxc_hosts/tasks/lxc_install_dnf.yml
Dmitriy Rabotyagov 058003873f Transform GPG/Repo installed to be a list
While we keep current behaviour without any major changes,
having repos as a list may allow us extending the list by adding
third-party repositories for some distros if needed (like for EL10).

Change-Id: I49f56a72ac3e5e5d039240011440390d488c6abb
2025-06-06 07:23:46 +00:00

108 lines
3.0 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: Ensure createrepo package is installed
ansible.builtin.dnf:
name: createrepo
state: present
- name: Drop COPR yum repo for lxc
ansible.builtin.yum_repository:
name: thm-lxc3.0
state: absent
register: repo_removed
- name: Clean yum metadata # noqa: no-handler
ansible.builtin.command: yum clean metadata
changed_when: false
when:
- repo_removed is changed
- name: If a keyfile is provided, copy gpg keyfiles to the key location
ansible.builtin.copy:
src: "{{ item.keyfile }}"
dest: "{{ item.key }}"
mode: "0644"
loop: "{{ lxc_centos_repo_keys | selectattr('keyfile', 'defined') }}"
loop_control:
label: "{{ item.key }}"
- name: If key url is provideds, download gpg keyfiles to the key location
ansible.builtin.get_url:
url: "{{ item.url }}"
dest: "{{ item.key }}"
mode: "0640"
loop: "{{ lxc_centos_repo_keys | selectattr('url', 'defined') }}"
loop_control:
label: "{{ item.key }}"
register: _get_yum_keys
until: _get_yum_keys is success
retries: 5
delay: 2
- name: Install gpg keys
ansible.builtin.rpm_key:
key: "{{ item.key }}"
validate_certs: "{{ item.validate_certs | default(omit) }}"
state: "{{ item.state | default('present') }}"
loop: "{{ lxc_centos_repo_keys }}"
loop_control:
label: "{{ item.key }}"
- name: Install the EPEL repository
ansible.builtin.yum_repository:
name: "{{ item.name }}"
baseurl: "{{ item.baseurl }}"
description: "{{ item.description | default(omit) }}"
gpgcheck: "{{ item.gpgcheck | default(omit) }}"
gpgkey: "{{ item.gpgkey }}"
enabled: "{{ item.enabled | default(true) }}"
state: "{{ item.state | default('present') }}"
includepkgs: "{{ item.includepkgs | default(omit) }}"
register: install_repo
until: install_repo is success
retries: 5
delay: 2
loop: "{{ lxc_centos_repos }}"
loop_control:
label: "{{ item.name }}"
- name: Install distro packages
ansible.builtin.package:
pkg: "{{ lxc_hosts_distro_packages }}"
state: "{{ lxc_hosts_package_state }}"
register: install_packages
until: install_packages is success
retries: 5
delay: 2
tags:
- lxc-packages
- name: Remove sub system lock if found
ansible.builtin.file:
path: "/var/lock/subsys/lxc"
state: "absent"
owner: "root"
group: "root"
tags:
- lxc-directories
- name: Enable lxc service
ansible.builtin.service:
name: lxc
enabled: "yes"
tags:
- lxc_hosts-config