Files
openstack-ansible-lxc_hosts/tasks/lxc_install_dnf.yml
Dmitriy Rabotyagov c84b23b258 Do not install COPR repo for CentOS LXC
EPEL does contain LXC package for CentOS 8 and 9 Stream, so we can
install LXC from there. For CentOS 9 COPR still needed for lxc-templates

With that we also add control of what packages are going to be installed
from EPEL.

Change-Id: I60f1b04c2378c91905440e8de223c29dd6da4d17
2025-05-28 18:23:46 +00:00

91 lines
2.6 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: Download EPEL gpg keys
ansible.builtin.get_url:
url: "{{ lxc_centos_epel_key }}"
dest: /etc/pki/rpm-gpg
mode: "0640"
register: _get_yum_keys
until: _get_yum_keys is success
retries: 5
delay: 2
- name: Install EPEL gpg keys
ansible.builtin.rpm_key:
key: "/etc/pki/rpm-gpg/{{ lxc_centos_epel_key.split('/')[-1] }}"
state: present
- name: Install the EPEL repository
ansible.builtin.yum_repository:
name: epel-lxc_hosts
baseurl: "{{ lxc_centos_epel_mirror ~ '/' ~ ansible_facts['distribution_major_version'] ~ '/Everything/' ~ ansible_facts['architecture'] }}"
description: "Extra Packages for Enterprise Linux {{ ansible_facts['distribution_major_version'] }} - $basearch"
gpgcheck: true
gpgkey: "file:///etc/pki/rpm-gpg/{{ lxc_centos_epel_key.split('/')[-1] }}"
enabled: true
state: present
includepkgs: "{{ lxc_hosts_epel_packages | join(' ') }}"
register: install_epel_repo
until: install_epel_repo is success
retries: 5
delay: 2
when:
- lxc_hosts_epel_packages | length > 0
- 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