NethServer and Ansible: base facts

Hi all,

We use Ansible to deploy and configure some machines and we have now an interesting problem to solve, which is: NethServer and CentOS are completely indistinguishable between themselves, based on native Ansible facts collected at setup phase.

We could guess indirectly it is a NethServer since facter_rpms.nethserver-release exists and we are already thinking on installing a custom fact script to publish to Ansible the contents of db configuration show sysconfig, but I would like to discuss it also with developers and other advanced users.

How do you distinguish in Ansible between NethServer and CentOS, if you ever need it? What are your best educated guess on doing that?

I am also thinking, since some years already, to support event much better Ansible writing an e-smith plugin (to do db commands and signalling events the Ansible way); we just have flawed trials and we didn’t even put the right efforts on it, TBH.

Thanks for your attention.

Hi Emiliano,

a quicker proof the system IS a NethServer is testing one file exists. It has the benefit of avoid RPM db locks. For instance /etc/nethserver-release. This is a general rule: if you want to see if an RPM is installed, test if a well-known path exists (choose it wisely…).

Yes, me too :blush: I’m happy I’m not alone with this idea. My hope is to have a NS8 with both e-smith and Ansible programming interfaces.

Despite the fact that e-smith is old (and Perl), it has two great advantages over Ansible:

  • It’s faster
  • IMO it’s more intuitive (but Ansible is much more spread out)
  • The trivial implementation can be easily hacked (but I admit I didn’t study the Ansible code)

Do you have any pointer to your experiments?

Here’s python code for the fact:

#!/usr/bin/env python

from json import dumps
from os.path import isfile
print(dumps(isfile('/etc/nethserver-release')))

Calling it is_nethserver.fact allows to check it with ansible_local.is_nethserver, returns obviously true or false.

I will search for them, but don’t wait so eagerly :smile:

2 Likes