Recently I need to install a package called
Lmod on a Red Hat 8 server.
Lmod is available from RHEL 8 EPEL8 repository, however it has a dependency called
lua-filesystem which is only available from
codeready-builder repository. On my RHEL 8 server, the
codeready-builder repository is not enabled by default.
Here is how I’ve got
Lmod installed manually:
# subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms # dnf install Lmod
Looking at the above commands, I needed to enable the
codeready-builder-for-rhel-8-x86_64-rpms first before installing
Lmod. The thing is, I’m going to forget that
lua-filesystem which is not available from the same repository as
Lmod unless I write it down somewhere. Or better yet, let’s automate it with Ansible!
Tonight, I just learn that there is a community Ansible module which provides the exact feature that I’m looking for - it’s called
Here is a working example I used in my Ansible playbook:
- name: Enable codeready-builder repository community.general.rhsm_repository: name: codeready-builder-for-rhel-8-x86_64-rpms when: ansible_os_family == 'RedHat' tags: - lmod - name: Install Lmod package package: name: - lua-filesystem # this is not required - Lmod state: present when: ansible_os_family == 'RedHat' tags: - lmod
Well, there is nothing fancy, but it worked.
Learn more about this awesome Ansible module at: community.general.rhsm_repository.
If you want to add a repo is not managed by RHEL subscription manager, you can read this article available at Red Hat Enable Sysadmin instead: Add a repo and install a package the Ansible way.