Get Started with Ansible Foreman Modules
There has, evidently, been some shakeup in how to use Ansible to manage a Red Hat Satellite server.
The new way is to use the Foreman Ansible modules. I need to do so from a Red Hat 8 client, so these brief instructions are suitable for that platform. This is a quick four-step process to ensure that your Ansible installation can use the foreman modules.
First, make sure that your client machine has the Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) package repository enabled.
Second, install the necessary system packages:
sudo dnf install \
https://yum.theforeman.org/releases/latest/el8/x86_64/foreman-release.rpm
sudo dnf install ansible-collection-theforeman-foreman
Third, write a simple playbook and save it as test.yml
. You’ll
want to adjust the two variables in the vars
stanza; my sample
values are unlikely to be appropriate to your situation.
- name: Test Foreman Modules
hosts: localhost
gather_facts: false
collections:
- theforeman.foreman
vars:
certvalidate: "no"
myserver: "https://satellite.your.com"
vars_prompt:
- name: myuser
prompt: "Enter Satellite user name"
private: no
- name: mypass
prompt: "Enter password"
tasks:
- name: ping server
status_info:
server_url: '{{ myserver }}'
validate_certs: '{{ certvalidate }}'
username: '{{ myuser }}'
password: '{{ mypass }}'
Fourth, run the playbook!
ansible-playbook test.yml
This playbook doesn’t do anything useful other than verify contact with your Satellite server, but if the output ends with an ‘ok’ message, everything should be in shape to begin getting real work started.
RHEL 9
The Foreman modules can easily be installed on a system running RHEL 9 as well. Make sure the Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs) repository is enabled; then proceed in a version-specific variation on the procedure outlined above:
sudo dnf install \
https://yum.theforeman.org/releases/latest/el9/x86_64/foreman-release.rpm
sudo dnf install ansible-collection-theforeman-foreman