Ansible - How to deal with offline hosts

ansible

#1

Hello!

I was wondering how to deal with offline hosts when running Ansible roles from Foreman. With Puppet this is simple. Once the host gets online, the assigned puppet classes get applied.
But how can this be managed with assigned Ansible roles? Is there some kind of auto-rescheduling for offline hosts?
Or is the Ansible plugin in Foreman not meant to be used this way? If not, what is the intended use case for Ansible in Foreman?


#2

So Foreman gives you two use-cases for ansible integration. The first is configuration management like with puppet, the second is arbitrary remote execution. I suppose you’re most interested in the first one.

Of course the main difference between puppet and ansible is, there’s no daemon that would rerun the configuration. There are 2 ways you can get the similar behaviour though in Foreman.

A) You can setup recurring execution of running ansible roles. If you go to the invocation form, you can select the recurring, see attached screenshot.

B) you can setup cron to trigger the same through API

The limitation is that if host is offline, the job will fail and it’s status will turn red. Once it comes back online and ansible run is triggered again, it comes back green. There’s no “ignore the failure I know the host is down” feature atm. You can disable host reporting so you won’t receive configuration report for such host at least. Good thing is, that at least the interval for “host out of sync” can be adjusted via settings, so you can define what is your expected ansible rerun interval.


#3

Thank you for your infos.
I wonder how this scales. For example if you schedule hourly Ansible runs for like 300 hosts?


#4

For 300 hosts it should still be okay-ish (and almost surely fine once the ansible-runner support gets into a stable release), but it depends. The best would be if you could just try it and see if it works for you. You can always cancel the recurring job if you’re not satisfied with how it goes


#5

Are there any examples around for B) you can setup cron to trigger the same through API?