# facts from set\_fact aren't working

**URL:** <https://forum.ansible.com/t/facts-from-set-fact-arent-working/22893>\
**Category:** Ansible Project\
**Created:** [October 26, 2016, 4:06pm UTC](https://forum.ansible.com/t/facts-from-set-fact-arent-working/22893 "2016-10-26T16:06:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dayton\_Jones](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@Dayton\_Jones](https://forum.ansible.com/u/Dayton_Jones)\
**Post date:** [October 26, 2016, 4:06pm UTC](https://forum.ansible.com/t/facts-from-set-fact-arent-working/22893/1 "2016-10-26T16:06:51Z")

</div>

I’m setting 2 facts from a custom filter, which appears to be working, but when I go to use those facts in the playbook they aren’t there…

set\_fact:  
ilom\_gw: “{{ ilom\_ip | ilom\_net(item.gateway,item.mask) }}”  
ilom\_mask: “{{ ilom\_ip | ilom\_net(item.gateway,item.mask, return\_value=‘mask’) }}”  
with\_items: iloms

here’s the output of that task:

> > ```auto
> > {
> > 
> > ```
> 
> > ```auto
> > "changed": false,
> > 
> > ```
> 
> > ```auto
> > "msg": "All items completed",
> > 
> > ```
> 
> > ```auto
> > "results": [
> > 
> > ```
> 
> > ```auto
> > {
> > 
> > ```
> 
> > ```auto
> > "_ansible_no_log": false,
> > 
> > ```
> 
> > ```auto
> > "ansible_facts": {
> > 
> > ```
> 
> > ```auto
> > **"ilom_gw": "10.224.64.1",**
> > 
> > ```
> 
> > ```auto
> > **"ilom_mask": "255.255.248.0"**
> > 
> > ```
> 
> > ```auto
> > },
> > 
> > ```

> ```auto
> 
> ```

as you can see both ilom\_gw and ilom\_mask are set here, but then:

debug: var=ilom\_gw

> > ```auto
> > [mgmt_port:debug] ilom_gw
> > 
> > ```
> 
> > ```auto
> > 2016-10-26 15:31:29+00:00 (0:01:05)
> > 
> > ```
> 
> > ```auto
> > Changed = False
> > 
> > ```
> 
> > ```auto
> > JSON : {
> > 
> > ```
> 
> > ```auto
> > "_ansible_no_log": false,
> > 
> > ```
> 
> > ```auto
> > "_ansible_verbose_always": true,
> > 
> > ```
> 
> > ```auto
> > "changed": false, 
> > 
> > ```

> > ```auto
> > **"ilom_gw": false**
> > 
> > ```

> ```auto
> }
> 
> ```

```auto

```

```auto

```

> ```auto
> debug: var=ilom_mask
> 
> ```
> 
> > ```auto
> > [mgmt_port:debug] ilom_mask
> > 
> > ```
> 
> > ```auto
> > 2016-10-26 15:31:30+00:00 (0:01:06)
> > 
> > ```
> 
> > ```auto
> > Changed = False
> > 
> > ```
> 
> > ```auto
> > JSON : {
> > 
> > ```
> 
> > ```auto
> > "_ansible_no_log": false,
> > 
> > ```
> 
> > ```auto
> > "_ansible_verbose_always": true,
> > 
> > ```
> 
> > ```auto
> > "changed": false,
> > 
> > ```
> 
> > ```auto
> > **"ilom_mask": false**
> > 
> > ```

> ```auto
> }
> 
> ```

And I swear when I tested this yesterday it worked as expected, but then today it’s broken… what am I missing?

```auto

```

```auto

```

```auto

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Dayton\_Jones](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@Dayton\_Jones](https://forum.ansible.com/u/Dayton_Jones)\
**Post date:** [October 31, 2016, 2:05pm UTC](https://forum.ansible.com/t/facts-from-set-fact-arent-working/22893/2 "2016-10-31T14:05:54Z")

</div>

Ok…found why, but I’m unsure how to fix. So iloms as defined in my group\_vars is:

> iloms:
> 
> - gateway: 10.224.64.1
> 
> mask: 255.255.248.0
> 
> - gateway: 10.85.0.1
> 
> mask: 255.255.254.0
> 
> - gateway: 10.234.50.161
> 
> mask: 255.255.255.224

if the ilom.gateway/ilom.mask pair is the last in list, then ilom\_gw and ilom\_mask get set and are usable. If the pair is _not_ last then they get set to false (because they did not match the filter) how can I specify a “found first” and exit the loop when a match is made?

---

<div class="post-metadata">

**Author:** ![Dayton\_Jones](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@Dayton\_Jones](https://forum.ansible.com/u/Dayton_Jones)\
**Post date:** [November 3, 2016, 5:44pm UTC](https://forum.ansible.com/t/facts-from-set-fact-arent-working/22893/3 "2016-11-03T17:44:21Z")

</div>

and got it working…

replaced the  
iloms:  
-gateway: xxxx  
mask: xxxxx

format with  
iloms: [‘10.85.0.1/255.255.254.0’,‘10.234.50.161/255.255.255.224’,‘10.224.64.1/255.255.248.0’]

where each element is the gw/mask pair and got rid of the “with\_items” the filter was modified to parse all the elements, check to see which set matched and return only the correct pairing

So, instead of looping through the list items, I pass them all at once and the filter does all the heavy lifting.
