Add repos only when there're packages for install
At the moment we allow not to install packages by providing systemd_networkd_distro_packages as an empty list. When that happens it makes sense also to skip all tasks related to adding repositories when no packages are going to be installed. Not installing packages might be useful for containers creation or in situations when there is no networking yet, but we know that systemd-networkd is already present. Change-Id: I5e12cb0eb07b5eb8dcca462dbe8239a926ef80e6
This commit is contained in:
parent
356db62780
commit
0ae090b0d5
@ -28,9 +28,13 @@
|
||||
tags:
|
||||
- always
|
||||
|
||||
# Copy all factored-in GPG keys.
|
||||
# KeyID 2F86D6A1 from https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
|
||||
- name: If a keyfile is provided, copy the gpg keyfile to the key location
|
||||
- name: Install required repos and packages
|
||||
when:
|
||||
- systemd_networkd_distro_packages | length > 0
|
||||
block:
|
||||
# Copy all factored-in GPG keys.
|
||||
# KeyID 2F86D6A1 from https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
|
||||
- name: If a keyfile is provided, copy the gpg keyfile to the key location
|
||||
copy:
|
||||
src: "{{ item.keyfile }}"
|
||||
dest: "{{ item.key }}"
|
||||
@ -39,15 +43,15 @@
|
||||
when:
|
||||
- ansible_facts['os_family'] | lower == 'redhat'
|
||||
|
||||
- name: Ensure GPG keys have the correct SELinux contexts applied
|
||||
- name: Ensure GPG keys have the correct SELinux contexts applied
|
||||
command: restorecon -Rv /etc/pki/rpm-gpg/
|
||||
# TODO(evrardjp): Be more idempotent
|
||||
changed_when: false
|
||||
when:
|
||||
- ansible_facts['os_family'] | lower == 'redhat'
|
||||
|
||||
# Handle gpg keys manually
|
||||
- name: Install gpg keys
|
||||
# Handle gpg keys manually
|
||||
- name: Install gpg keys
|
||||
rpm_key:
|
||||
key: "{{ key.key }}"
|
||||
validate_certs: "{{ key.validate_certs | default(omit) }}"
|
||||
@ -62,8 +66,8 @@
|
||||
when:
|
||||
- ansible_facts['os_family'] | lower == 'redhat'
|
||||
|
||||
# NOTE(jrosser) this repo is configured with the path to the first gpg key provided
|
||||
- name: Install the EPEL repository
|
||||
# NOTE(jrosser) this repo is configured with the path to the first gpg key provided
|
||||
- name: Install the EPEL repository
|
||||
yum_repository:
|
||||
name: epel-networkd
|
||||
baseurl: "{{ systemd_networkd_epel_mirror ~ '/' ~ ansible_facts['distribution_major_version'] ~ '/Everything/' ~ ansible_facts['architecture'] }}"
|
||||
@ -80,15 +84,13 @@
|
||||
retries: 5
|
||||
delay: 2
|
||||
|
||||
- name: Install networkd distro packages
|
||||
- name: Install networkd distro packages
|
||||
package:
|
||||
name: "{{ systemd_networkd_distro_packages }}"
|
||||
state: "present"
|
||||
update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}"
|
||||
cache_valid_time: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary(600, omit) }}"
|
||||
enablerepo: "{{ systemd_networkd_enablerepo | default(omit) }}"
|
||||
when:
|
||||
- systemd_networkd_distro_packages | length > 0
|
||||
register: install_packages
|
||||
until: install_packages is success
|
||||
retries: 3
|
||||
|
Loading…
x
Reference in New Issue
Block a user