Currently, we have written an ansible playbook which will install puppet agents on ubuntu machines, then hosts will be added to foreman after successful play.
But we are facing an issue on installing puppet agents on ubuntu systems due to some repository update issues, some of them having repo cache issues.
So how to onboard hosts to foreman via ansible without puppet agent.once hosts added via ansible, we will install agent on puppet from foreman to collect facts of systems. How do we achieve it using ansible?
Also i have seen a topic “road to making puppet optional” so if we do not have puppet in future releases, how do we get facts of systems and i hope remote execution do not use puppet agent anyway. Please suggest on this.
If you set up the foreman ansible plugin and enable ansible callback as detailed in https://theforeman.org/plugins/foreman_ansible/3.x/index.html#2.Installation you should be getting facts and reports for ansible runs in foreman as well.
As was mentioned in the making puppet optional post, we are considering making the ansible fact processing part of foreman core in the future, so it would work even if you don’t install the ansible plugin (which includes much more functionality, such as assigning and running roles on hosts). In any case, that effort will take several releases to complete, so I wouldn’t make decisions based on it right now. If all you use puppet for is collecting facts, you can definitely drop it in favor of ansible facts. If you are using puppet for other use cases, it will continue working in the future as well.
Remote execution does not use puppet, it uses SSH, ansible-runner or salt as backends for executing remote jobs.
We have used ansible call back plugin to add hosts
– but here we will run ansible playbook only once to onboard hosts, after addition of hosts, they are going to out of sync state since we don’t run ansible playbook on hosts. how do we get rid out of this issue?
– Also the hostname of hosts in foreman is taking from ansible inventory, we use ip addresses in inventory, how do we get actual hostname of host to be added in foreman instead of looking into ansible inventory? because we don’t make any dns entries for all hosts.
There should be ansible_out_of_sync_disabled setting which can be used to prevent hosts from going into out of sync state if they don’t receive ansible reports regularly. If you’re going to use ansible to only onboard the hosts, this might be a viable option.
I had set ansible_out_of_sync_disabled to yes, now i am not seeing out of sync state.
We have to get actual hostnames of devices first then update the inventory like you said. but here when we run playbook to get actual hostnames, the ipaddress in inventory will be added to foreman through callback plugin. We have number of sites and lot of devices present in each site.
so updating hostnames manually in ansible inventory is hard.
*Is there any setting in foreman like take hostname by looking ansibe_hostname parameter from ansible facts instead of taking from ansible inventory?
Sorry, I had the reply as a draft but somehow didn’t post it.
I’m not aware of a way to use ansible_hostname instead of the inventory name. You would have to temporarily disable the callback plugin when gathering the hostnames and then enable it again when running the actual registration.
But In our Environment, we do not have static ip configured on hosts. If ip address changes in hosts, then hostname and ip address will not be updated in foreman GUI since we run ansible playbook only once to register hosts. We could see duplicate entries in foreman if we run playbook again.
In this case having dynamic ip address, please suggest us on how could we register the hosts and manage them in foreman?
I’m afraid I’m not following. You run ansible to register the hosts. This once, you will use ip addresses to connect to the hosts and you’ll get your hosts in foreman. Next time you need to run ansible, you do it from Foreman and it will use hostnames so it doesn’t matter that the ip addresses have changed.