Skip to content

Commit

Permalink
Merge pull request #12 from mhakala/master
Browse files Browse the repository at this point in the history
adding dnf support for Centos8
  • Loading branch information
VilleS1 authored Sep 21, 2020
2 parents 13789db + a9db744 commit f8131ca
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
# tasks file for ansible-role-yum

- include_tasks: redhat.yml
when: ansible_os_family == "RedHat"
- include_tasks: redhat7.yml
when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "7"

- include_tasks: redhat8.yml
when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "8"
File renamed without changes.
96 changes: 96 additions & 0 deletions tasks/redhat8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
# tasks file for ansible-role-yum Redhat-8 family
# In Redhat8/CentOS8. Yum has been replaced with dnf. Using yum still in ansible parameter names,
# but changing already to dnf packet manager

- name: install repos that are in repos from CentOS
dnf:
name: "{{ centos_releases | default({}) }}"
state: present

- name: add local defined yum repositories
yum_repository:
name: "{{ item.name }}"
description: "{{ item.name }}"
baseurl: "{{ item.url }}"
gpgkey: "{{ item.gpgkey | default(omit) }}"
gpgcheck: "{{ item.gpgcheck | default(omit) }}"
enabled: "{{ item.enabled | default(omit) }}"
exclude: "{{ item.exclude | default(omit) }}"
state: "{{ item.state | default(omit) }}"
with_items: "{{ yum_repos | default({}) }}"

- name: import GPG key for repos
rpm_key:
key: "{{ item.gpgkey }}"
with_items: "{{ yum_repos | default({}) }}"
when: item.gpgkey is defined

- name: always install libselinux-python without it ansible facts cannot tell if selinux is enabled
dnf:
name: python3-libselinux
state: present

# /etc/dnf/dnf.conf
- name: template in dnf.conf on CentOS8 if yum_conf_template is True
template:
src: dnf.conf.j2
dest: /etc/dnf/dnf.conf
mode: 0644
owner: root
group: root
backup: yes
when:
- yum_conf_template
- ansible_distribution == "CentOS"

- name: update all the things
dnf:
name: "*"
state: latest
update_cache: "{{ yum_update_cache }}"
when: yum_update_all_the_things|bool

- name: install IB software that do not need extra configuration - on nodes with ib interfaces
dnf:
name: "{{ ib_unconfigured_packages | default({}) }}"
state: present
when:
- infiniband_available|bool
- ib_unconfigured_packages is defined
- ib_unconfigured_packages | length > 0

- name: install software that do not need extra configuration
dnf:
name: "{{ unconfigured_packages | default({}) }}"
state: present
when:
- unconfigured_packages is defined
- unconfigured_packages | length > 0

- name: install globally software that do not need extra configuration
dnf:
name: "{{ unconfigured_packages_global | default({}) }}"
state: present
when:
- unconfigured_packages_global is defined
- unconfigured_packages_global | length > 0

- name: remove software
dnf:
name: "{{ remove_packages | default({}) }}"
state: absent
when:
- remove_packages is defined
- remove_packages | length > 0

- name: disable and stop services
service:
name: "{{ item }}"
enabled: no
state: stopped
with_items: "{{ disable_packages | default({}) }}"
when:
- disable_packages is defined
- disable_packages | length > 0

34 changes: 34 additions & 0 deletions templates/dnf.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# {{ ansible_managed }}
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
keepcache=False
cachedir=/var/cache/yum/$basearch/$releasever
debuglevel=2
obsoletes=true
plugins=true
fastestmirror=1

{% if yum_conf_template %}
{% if yum_ip_resolve is defined %}
ip_resolve={{ yum_ip_resolve }}
{% endif %}
{% endif %}


{% if yum_conf_template %}
{% if yum_proxy is defined %}
proxy={{ yum_proxy }}
{% endif %}
{% endif %}

{% if yum_conf_extra_settings is defined %}
# Extra yum settings
{% for yumsetting in yum_conf_extra_settings %}
{{ yumsetting }}
{% endfor %}
{% endif %}

0 comments on commit f8131ca

Please sign in to comment.