# detecting version of syslog-ng

**URL:** <https://forum.ansible.com/t/detecting-version-of-syslog-ng/18166>\
**Category:** Ansible Project\
**Created:** [May 6, 2015, 6:54am UTC](https://forum.ansible.com/t/detecting-version-of-syslog-ng/18166 "2015-05-06T06:54:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Randy\_Bush](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Randy\_Bush](https://forum.ansible.com/u/Randy_Bush)\
**Post date:** [May 6, 2015, 6:54am UTC](https://forum.ansible.com/t/detecting-version-of-syslog-ng/18166/1 "2015-05-06T06:54:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [May 8, 2015, 9:59am UTC](https://forum.ansible.com/t/detecting-version-of-syslog-ng/18166/2 "2015-05-08T09:59:49Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [May 8, 2015, 10:05am UTC](https://forum.ansible.com/t/detecting-version-of-syslog-ng/18166/3 "2015-05-08T10:05:38Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![Randy\_Bush](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Randy\_Bush](https://forum.ansible.com/u/Randy_Bush)\
**Post date:** [May 9, 2015, 2:27am UTC](https://forum.ansible.com/t/detecting-version-of-syslog-ng/18166/4 "2015-05-09T02:27:37Z")

</div>

ok, for the record, here is what i ended up with

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [May 9, 2015, 8:42pm UTC](https://forum.ansible.com/t/detecting-version-of-syslog-ng/18166/5 "2015-05-09T20:42:53Z")

</div>

Very elegant!  
-Y.
