ahaerpfer / ansible-inventory-omd-livestatus

Ansible dynamic inventory script for OMD Livestatus.
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

Add possibility to create inventory by name instead of by IP #3

Closed ahaerpfer closed 8 years ago

ahaerpfer commented 8 years ago

Warp inventory data around and create output by host, e.g. (--to-static format):

myhost      ansible_host=10.1.2.3 omd_alias="My cool host"

instead of the by-IP output

10.1.2.3    omd_alias="My cool host" omd_name="myhost"

Open issues:

ahaerpfer commented 8 years ago

After some testing …

Actually, it's just the other way round and in Nagios IPs are not guaranteed to be unique but host names are! Trying to define two host objects with the same name results in a configuration error.

Having two hosts with the same IP address does not break Nagios. The by-name representation of the inventory works as expected in this case. However, in the by-IP representation omd_alias and omd_name of both objects end up as duplicates of the second host. In the static output we then have duplicate lines, in the JSON output there is only one hostvars section for this IP.

Conclusion

ahaerpfer commented 8 years ago

The warning for duplicate IPs will only be issued for --static output. For the JSON output we try not to mess up things with additional (and potentially confusing) output … although ansible and ansible-playbook seem to completely discard output on stderr, anyway (i.e. it does not get printed to the TTY either).