have a playbook bit to distribute syslog-ng.conf to a bunch of servers,
some running syslog-ng 3.3 and some running 3.5. so there are two
different configuration files.
is there a way to detect which version a host is running so i can
distribute the appropriate one? for the moment i have an embarrassing
hack based on host entries
randy
I would recommend adding the syslog-ng version to facts using a custom module – see http://docs.ansible.com/developing_modules.html#module-provided-facts
Your “custom facts module” can be a simple shell script like:
----cut here—
#! /bin/sh
rsyslogd -v | awk ‘/^rsyslogd/ {printf(“{ "changed": false, "rc": 0, "ansible_facts": { "rsyslog_ver": "%s" } }\n”, $2)}’
----cut here—
(the awk stuff might appear a bit cryptic but what it does is to output valid Json on stdout).
This is for rsyslogd on my machine; you need to have something different for syslog-ng.on yours. (And maybe anticipate that there might not be syslog-ng at all?)
Let know if this helps.
-Yassen
Randy, FYI: the output of that script (after beautifying it a bit):
`
{
“changed”: false,
“rc”: 0,
“ansible_facts”: {
“rsyslog_ver”: “5.8.6,”
}
}
`
(The trailing comma in the rsyslog_ver value is redundant but you should get the idea.)
ok, for the record, here is what i ended up with