# Collecting and filtering remote facts

**URL:** <https://forum.ansible.com/t/collecting-and-filtering-remote-facts/18036>\
**Category:** Ansible Project\
**Created:** [April 21, 2015, 11:34am UTC](https://forum.ansible.com/t/collecting-and-filtering-remote-facts/18036 "2015-04-21T11:34:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raghu\_Udiyar](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Raghu\_Udiyar](https://forum.ansible.com/u/Raghu_Udiyar)\
**Post date:** [April 21, 2015, 11:34am UTC](https://forum.ansible.com/t/collecting-and-filtering-remote-facts/18036/1 "2015-04-21T11:34:35Z")

</div>

Hello

Let me start with the use case. I have to retrieve the filename pointed by a symlink, say /etc/current → /etc/version-1.0 and determine if this filename is the same across a bunch of nodes.

I figure I have to do two things:

1. Use file module, and get the filename, and use set\_fact to set “version\_number” fact on each node.
2. Loop through the facts for each node, and keep appending a set (using union with the “version\_number” fact
3. If the final set is greater than 1 there is a mistmach in version, if not I can display that version\_number.

This is how I attempted to do it :

`

---

<div class="post-metadata">

**Author:** ![Raghu\_Udiyar](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Raghu\_Udiyar](https://forum.ansible.com/u/Raghu_Udiyar)\
**Post date:** [May 9, 2015, 4:31pm UTC](https://forum.ansible.com/t/collecting-and-filtering-remote-facts/18036/2 "2015-05-09T16:31:57Z")

</div>

For someone with this same problem, this is how I solved it :

1. First play, set\_fact the link target on all hosts
2. Second play, use a template and generate a list of link targets using the facts set above. This is done using hostvars in jinja.
3. Use include\_vars to include the generated template

Example playbook : [https://gist.github.com/raags/0f2089ec1208617b86d8](https://gist.github.com/raags/0f2089ec1208617b86d8)
