The first thing we need to do is to create the roles/common/tasks and roles/common/templates folders. In the first one, we will add the following main.yaml file. The full code is available on GitHub:
---
- name: Ensure EPEL is enabled yum: name: epel-release state: present become: True - name: Ensure libselinux-python is present yum: name: libselinux-python state: present become: True - name: Ensure libsemanage-python is present yum: name: libsemanage-python state: present become: True ...
As you can see, this is very similar to our common_tasks.yaml playbooks. In fact, there are only two differences:
- The hosts, remote_user, and tasks lines (lines 2, 3, and 4) have been deleted.
- The indentation of the rest of the file has been fixed accordingly.
In this role, we used the template task to create...