# List of list and variables

**URL:** <https://forum.ansible.com/t/list-of-list-and-variables/18829>\
**Category:** Ansible Project\
**Created:** [July 23, 2015, 8:36am UTC](https://forum.ansible.com/t/list-of-list-and-variables/18829 "2015-07-23T08:36:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [July 23, 2015, 8:36am UTC](https://forum.ansible.com/t/list-of-list-and-variables/18829/1 "2015-07-23T08:36:10Z")

</div>

i am not sure it is possible to do so, but i would like to have a list of list. it would look like this:

my\_files:  
path: /data/ansible/testing1/

- {name: ‘test1.reg’, ext: ‘.reg’}

- {name: ‘test1.lst’, ext: ‘.lst’}

- {name: ‘test1.sql’, ext: ‘.sql’}

path: /data/ansible/testing2/

- {name: ‘test2.reg’, ext: ‘.reg’}

- {name: ‘test2.lst’, ext: ‘.lst’}

- {name: ‘test2.xsl’, ext: ‘.xsl’}

and most important, how can i access to those vairables in a playbook?

Note: i absolutely need to keep this kind of hierarchy with the path and then the files in this path.

Thank you!

---

<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:** [July 28, 2015, 11:23pm UTC](https://forum.ansible.com/t/list-of-list-and-variables/18829/2 "2015-07-28T23:23:46Z")

</div>

first this is a list of dictionaries in mixed list/dictionaries which  
are part of a dictionary (my\_files), access to list is via index [0]  
for first item or [1] for second, for dictionaries just use keys. But  
I'm not sure this is a proper construct at all.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [July 29, 2015, 5:30am UTC](https://forum.ansible.com/t/list-of-list-and-variables/18829/3 "2015-07-29T05:30:55Z")

</div>

That’s a complicated structure, and you seem to be storing some redundant information.  
Just wondering if you can simplify the structure and use filters to derive the ext from the name  
See [http://docs.ansible.com/ansible/playbooks\_filters.html#other-useful-filters](http://docs.ansible.com/ansible/playbooks_filters.html#other-useful-filters) - there’s a splitext filter which looks appropriate.

Hope that helps,

Jon

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [July 29, 2015, 8:28am UTC](https://forum.ansible.com/t/list-of-list-and-variables/18829/4 "2015-07-29T08:28:15Z")

</div>

thank you for all your replies. i changed the way i am organizing my file. now i do:  
my\_files:

- {path: ‘/data/ansible/testing1’, name: ‘test1.reg’, ext: ‘.reg’}
- {path: ‘/data/ansible/testing1’, name: ‘test1.lst’, ext: ‘.lst’}

so it is less readable but easier to access to a variable (item.path, item.name, …).

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [July 29, 2015, 11:41am UTC](https://forum.ansible.com/t/list-of-list-and-variables/18829/5 "2015-07-29T11:41:40Z")

</div>

Not really what it is you are trying to achieve, but perhaps you can have a simple structure and use filters to fetch the parts of the full path that you need.

Something like this:

`
