Hostname is being populated by host: in ansible callback which is set to localhost

The way we are setting up the foreman environment is to have ansible callbacks from the different systems send facts into the foreman server, which in turn, creates a new host. The problem with that is, if the ansible playbook has an inventory hosts set to localhost, then foreman will create the new host with that name in the system. Is there a way to set the callback to use the systems hostname rather than the the inventory hosts name?


- hosts: localhost

  - name: Update system
      name: "*"
      state: latest
    become: yes

Callback settings in ansible.cfg

url = 'fqdn'
ssl_cert = /projects/pub.pem
ssl_key = /projects/key.pem
verify_certs = /projects/ca.pem

Thank You

Foreman and Proxy versions:
Foreman 3.7 RHEL 8

I’m afraid not. This behavior seems to be hardcoded right now.

Could you somehow influence the inventory name? Or use the proper name in the inventory but then use local connection?


I don’t know. I did find where in the callback plugin itself where it calls the value for the variable Host. I am going to see about changing that to something like hostname and make it read the value from the hostname file. Hopefully this works.