Hi Everyone,
I am trying to configure an automatic listing for the existing machines.
Please let me know if I should follow the same procedures at the video but with ansible module?
I would like to create automation that will run automatically registration ( I can see the hosts in foreman but I didn’t register the host)
Global Registration Deep Dive- Global Registration Deep Dive - YouTube
Thanks,
Shay
Hi @shaycohen11
I am not familiar with the Ansible way. If you use the Global Registration it will generate a curl command for you that you can pass to multiple systems that you want to use that activation key on. I guess you could pass that to Ansible as a command/shell argument.
Hi,
Thanks I am creating module of ansible to do it
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 
When you run role / playbook against host, with foreman_ansible callback host is automatically created in the Foreman. Maybe that’s the way you want to go