Foreman ansible best place to override ansible_python_interpreter

A bit of background:
I’ve been using ansible directly for some time now.
I’m stuck with a handful of legacy centos 5 machines, which just barely work with ansible… IF I override
ansible_python_interpreter by setting it in the “hosts” inventory file.
eg:

[centos5-boxes]
some.legacy.host ansible_python_interpreter=/usr/bin/python2.6

and yes it has to be python 2.6, not the system default which is 2.4

Anyways… is there a consensus on the best place to set this, for centos 5 hosts in foreman?
I was hoping there would be a way to set a smart variable from within a host group, like there is for puppet. So I would make a “CentOS 5” host group, and set it once and for all.
But…that does not even seem to be an option.
So where do I go from here?

If I recall correctly all parameters are available in ansible runs as host vars. Wouldn’t setting a ansible_python_interpreter parameter on the hostgroup do the trick?

2 Likes

Doh…
the first time I went to the host vars page in a hostgroup, I saw “Puppet” all over the place, and didnt see anything else.
But now I went there again, and see that the " Host Group Parameters" could be separate from puppet.
I"ll give it a try. Thank you for the reply.
(but now I have to get centos 5 TLS1.0 openssl libs happy with foreman somehow, first)

It seems to me like the best place to do this, is actually to add the parameter to the “Centos 5.x” Operating system definition in foreman-ansible, rather than hostgroup.
I didnt see that I could do that, the first time around.

2 Likes

Yeah, the same parameters can be set on multiple levels - Organization, Location, OS, Subnet, Domain, Hostgroup, Host. I think this is also roughly the order they are evaluated for a given host. I believe you found the best place for this case, so marking as a solution.

1 Like