Bootstrap FreeKB - Ansible - Install roles from RHEL system roles (rhel-system-roles)
Ansible - Install roles from RHEL system roles (rhel-system-roles)

Updated:   |  Ansible articles

RHEL system roles is a package that can be installed that includes common roles. dnf (on Red Hat 8) or yum (on Red Hat 7) can be used to install the RHEL system roles package.

dnf install rhel-system-roles

 

By default, the roles will be installed at /usr/share/ansible/roles.

~]# ll /usr/share/ansible/roles/
drwxr-xr-x.  9 root root 4096 Aug 17 02:06 rhel-system-roles.kdump
drwxr-xr-x.  8 root root 4096 Aug 17 02:06 rhel-system-roles.network
drwxr-xr-x.  6 root root   89 Aug 17 02:06 rhel-system-roles.postfix
drwxr-xr-x.  8 root root 4096 Aug 17 02:06 rhel-system-roles.selinux
drwxr-xr-x. 10 root root 4096 Aug 17 02:06 rhel-system-roles.storage
drwxr-xr-x. 11 root root 4096 Aug 17 02:06 rhel-system-roles.timesync

 

Let's say you want to use the timesync role. One option is to include the full path to the role in your playbook.

---
- hosts: all
  roles:
    - /usr/share/ansible/roles/rhel-system-roles.timesync
...

 

Or you could copy the role into your base roles directory. For example, let's say your ansible.cfg file has the following.

roles_path = /usr/local/ansible/roles

 

In this scenario you could copy the RHEL system role to /usr/local/ansible/roles.

cp -R /usr/share/ansible/roles/rhel-system-roles.timesync /usr/local/ansible/roles

 

By having the role in your base roles path directory, you could then just include the name of the roles directory in your playbook.

---
- hosts: all
  vars:
    timesync_ntp_servers:
      - hostname: 0.rhel.pool.ntp.org
        pool: yes
        iburst: yes
  roles:
    - rhel-system-roles.timesync

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter bd2423 in the box below so that we can be sure you are a human.