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

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

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





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




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |