# Proposal with\_all\_found loop

**URL:** <https://forum.ansible.com/t/proposal-with-all-found-loop/18469>\
**Category:** Ansible Developer\
**Tags:** ubuntu\
**Created:** [June 11, 2015, 1:27pm UTC](https://forum.ansible.com/t/proposal-with-all-found-loop/18469 "2015-06-11T13:27:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark.kusch](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mark.kusch](https://forum.ansible.com/u/mark.kusch)\
**Post date:** [June 11, 2015, 1:27pm UTC](https://forum.ansible.com/t/proposal-with-all-found-loop/18469/1 "2015-06-11T13:27:52Z")

</div>

Hi list,

I'd like to discuss a proposal for a loop with\_all\_found.  
We have with\_first\_found, so implementation should be quite easy.

Target:

- name: Include OS specific variables  
&nbsp;&nbsp;with\_all\_found:  
&nbsp;&nbsp;&nbsp;&nbsp;- "{{ ansible\_os\_family }}.yml"  
&nbsp;&nbsp;&nbsp;&nbsp;- "{{ ansible\_distribution }}.yml"  
&nbsp;&nbsp;&nbsp;&nbsp;- "{{ ansible\_distribution }}-{{ ansible\_distribution\_major\_version }}.yml"  
&nbsp;&nbsp;include\_vars: "{{ item }}"

vars/Debian.yml:  
pkg\_list:  
&nbsp;&nbsp;- foo  
&nbsp;&nbsp;- bar  
&nbsp;&nbsp;- foobar  
pkg\_state: installed  
service\_management: systemd

vars/Ubuntu.yml  
service\_management: upstart

vars/Ubuntu-15.yml  
service\_management: systemd  
ubuntu\_15\_specific\_var: value

Result, running on Ubuntu 14.

pkg\_list:  
&nbsp;&nbsp;- foo  
&nbsp;&nbsp;- bar  
&nbsp;&nbsp;- foobar  
pkg\_state: installed  
service\_management: upstart

Running on Ubuntu-15:  
pkg\_list:  
&nbsp;&nbsp;- foo  
&nbsp;&nbsp;- bar  
&nbsp;&nbsp;- foobar  
pkg\_state: installed  
service\_management: systemd  
ubuntu\_15\_specific\_var: value

Running on Debian:  
see vars/Debian.yml

This might spare one task compared to what I'm doing right now and will  
ease to override variables for specific versions/distributions.

- name: Include OS family specific vars  
&nbsp;&nbsp;include\_vars: "{{ ansible\_os\_family }}.yml"

- name: Include distribution specific vars  
&nbsp;&nbsp;with\_first\_found:  
&nbsp;&nbsp;&nbsp;&nbsp;- "{{ ansible\_distribution }}-{{ ansible\_distribution\_major\_version }}.yml"  
&nbsp;&nbsp;&nbsp;&nbsp;- "{{ ansible\_distribution }}.yml"  
&nbsp;&nbsp;include\_vars: "{{ item }}"

What do you think?

# kraM

---

<div class="post-metadata">

**Author:** ![Hagai\_Kariti](https://avatars.discourse-cdn.com/v4/letter/h/4491bb/32.png) [@Hagai\_Kariti](https://forum.ansible.com/u/Hagai_Kariti)\
**Post date:** [June 11, 2015, 1:34pm UTC](https://forum.ansible.com/t/proposal-with-all-found-loop/18469/2 "2015-06-11T13:34:08Z")

</div>

i like it

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 11, 2015, 1:56pm UTC](https://forum.ansible.com/t/proposal-with-all-found-loop/18469/3 "2015-06-11T13:56:57Z")

</div>

it would be a lookup plugin 'all\_found'

---

<div class="post-metadata">

**Author:** ![mark.kusch](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mark.kusch](https://forum.ansible.com/u/mark.kusch)\
**Post date:** [June 11, 2015, 2:21pm UTC](https://forum.ansible.com/t/proposal-with-all-found-loop/18469/4 "2015-06-11T14:21:04Z")

</div>

Hey,

sure. I was more focused on the use case in Ansible Yaml.

# kraM
