There’s no real need to make a module for that. The existing modules for subscription manager can take care of registering a system to Foreman.
- Configure /etc/rhsm/rhsm.conf to point to the foreman server/smartproxy
- Run a 2 tasks like:
- name: 'Ensure katello-ca-consumer'
ansible.builtin.yum:
name: "http://{{ rhsm_foreman_server }}/pub/katello-ca-consumer-latest.noarch.rpm"
state: 'present'
disable_gpg_check: true
when: rhsm_server_type != 'cdn'
- name: 'Register system'
community.general.redhat_subscription:
state: 'present'
org_id: "{{ rhsm_organization }}"
activationkey: "{{ rhsm_activation_key }}"
server_hostname: "{{ rhsm_foreman_server }}"
force_register: "{{ rhsm_force_register }}"
The role this came from is on github