Browse Source

Use dnf/yum vars based on what is available

With [1] it used yum/vars but in CentOS8-Stream
that is not available, so detect and use dnf or yum
vars.

Closes-Bug: #1927302
Change-Id: Idda53d1b68b97e5bb65314b1e07d507736932531
changes/99/789999/2 1.2.2
yatinkarel 1 month ago
parent
commit
2c53d70612
3 changed files with 24 additions and 12 deletions
  1. +12
    -0
      tasks/yum_common.yml
  2. +6
    -2
      tasks/yum_install_buildah.yml
  3. +6
    -10
      tasks/yum_update_buildah.yml

+ 12
- 0
tasks/yum_common.yml View File

@ -0,0 +1,12 @@
---
- name: Identify the primary package manager (dnf or yum)
shell: command -v dnf || command -v yum
register: pkg_mgr_output
- name: Set fact for the used package manager binary
set_fact:
pkg_mgr: "{{ pkg_mgr_output.stdout }}"
- name: Set fact for pkg_mgr_suffix
set_fact:
pkg_mgr_suffix: "{{ pkg_mgr.split('/')[-1] }}"

+ 6
- 2
tasks/yum_install_buildah.yml View File

@ -22,6 +22,10 @@
state: file
register: yum_install
- import_tasks: yum_common.yml
tags:
- always
- name: Prepare yum_install.sh script
copy:
src: files/yum_install.sh
@ -40,7 +44,7 @@
buildah run
--volume {{ yum_install.path }}:/tmp/yum_install.sh
--volume {{ yum_repos_dir_path }}:/etc/yum.repos.d
--volume /etc/yum/vars:/etc/yum/vars
--volume /etc/{{ pkg_mgr_suffix }}/vars:/etc/{{ pkg_mgr_suffix }}/vars
{% for repo in file_repos.stdout_lines %}
{% if repo is exists %}
--volume {{ repo }}:{{ repo }}
@ -58,7 +62,7 @@
buildah --debug run
--volume {{ yum_install.path }}:/tmp/yum_install.sh
--volume {{ yum_repos_dir_path }}:/etc/yum.repos.d
--volume /etc/yum/vars:/etc/yum/vars
--volume /etc/{{ pkg_mgr_suffix }}/vars:/etc/{{ pkg_mgr_suffix }}/vars
{% for repo in file_repos.stdout_lines %}
{% if repo is exists %}
--volume {{ repo }}:{{ repo }}


+ 6
- 10
tasks/yum_update_buildah.yml View File

@ -25,17 +25,13 @@
state: file
register: yum_update
- name: Identify the primary package manager (dnf or yum)
shell: command -v dnf || command -v yum
register: pkg_mgr_output
- name: Set fact for the used package manager binary
set_fact:
pkg_mgr: "{{ pkg_mgr_output.stdout }}"
- import_tasks: yum_common.yml
tags:
- always
- name: Set fact for the used cache path
set_fact:
cache_path: /var/cache/{{ pkg_mgr.split('/')[-1] }}
cache_path: /var/cache/{{ pkg_mgr_suffix }}
- import_tasks: copy_rpms.yml
@ -107,7 +103,7 @@
buildah run
--volume {{ yum_update.path }}:/tmp/yum_update.sh
--volume {{ yum_repos_dir_path }}:/etc/yum.repos.d
--volume /etc/yum/vars:/etc/yum/vars
--volume /etc/{{ pkg_mgr_suffix }}/vars:/etc/{{ pkg_mgr_suffix }}/vars
--volume /etc/pki:/etc/pki
{% if cache_volume is defined and cache_volume %}
--volume {{ cache_volume }}
@ -129,7 +125,7 @@
buildah --debug run
--volume {{ yum_update.path }}:/tmp/yum_update.sh
--volume {{ yum_repos_dir_path }}:/etc/yum.repos.d
--volume /etc/yum/vars:/etc/yum/vars
--volume /etc/{{ pkg_mgr_suffix }}/vars:/etc/{{ pkg_mgr_suffix }}/vars
--volume /etc/pki:/etc/pki
{% for repo in file_repos.stdout_lines %}
{% if repo is exists %}


Loading…
Cancel
Save