# Help with loop and data extraction

**URL:** <https://forum.ansible.com/t/help-with-loop-and-data-extraction/21522>\
**Category:** Ansible Project\
**Created:** [May 23, 2016, 12:01pm UTC](https://forum.ansible.com/t/help-with-loop-and-data-extraction/21522 "2016-05-23T12:01:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jepper](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@jepper](https://forum.ansible.com/u/jepper)\
**Post date:** [May 23, 2016, 12:01pm UTC](https://forum.ansible.com/t/help-with-loop-and-data-extraction/21522/1 "2016-05-23T12:01:27Z")

</div>

Of this blob

TASK: [context\_deploy | debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [myserver] =\> {  
“msg”: “1 {‘msg’: ‘All items completed’, ‘changed’: False, ‘results’: [{‘invocation’: {‘module\_name’: u’include\_vars’, ‘module\_complex\_args’: {}, ‘module\_args’: u’/Users/jespermarkenstam/tmp/master/automation.ansible/group\_vars/context\_def’}, ‘item’: ‘def’, ‘ansible\_facts’: {‘application\_gavdeploy\_list’: [{‘endpoint’: ‘[http://localhost:8080/def-service-bot/health](http://localhost:8080/def-service-bot/health)’, ‘group’: ‘wildfly’, ‘dest’: ‘/opt/wildfly/standalone/deployments’, ‘version’: u’1’, ‘owner’: ‘wildfly’, ‘type’: ‘war’, ‘groupId’: ‘com.xyz.cpp.def.service’, ‘artifactId’: ‘def-bot-service’}, {‘endpoint’: ‘[http://localhost:8080/def-service-bot/health](http://localhost:8080/def-service-bot/health)’, ‘group’: ‘wildfly’, ‘dest’: ‘/opt/wildfly/standalone/deployments’, ‘version’: u’1’, ‘owner’: ‘wildfly’, ‘type’: ‘war’, ‘groupId’: ‘com.xyz.cpp.def.service’, ‘artifactId’: ‘def-bot-service2’}]}}, {‘invocation’: {‘module\_name’: u’include\_vars’, ‘module\_complex\_args’: {}, ‘module\_args’: u’/Users/jespermarkenstam/tmp/master/automation.ansible/group\_vars/context\_abc’}, ‘item’: ‘abc’, ‘ansible\_facts’: {‘application\_gavdeploy\_list’: [{‘endpoint’: ‘[http://localhost:8080/abc-write-dot/health](http://localhost:8080/abc-write-dot/health)’, ‘group’: ‘wildfly’, ‘dest’: ‘/opt/wildfly/standalone/deployments’, ‘version’: u’1’, ‘owner’: ‘wildfly’, ‘type’: ‘war’, ‘groupId’: ‘com.xyz.cpp.abc.write’, ‘artifactId’: ‘abc-dot-write’}]}}]}”  
}

I want to extract all the groupId, artifactId, version, endpoint, and so on.

so far, I register the output from several lists into one dynamic variable “contexts”

- include\_vars: “{{ playbook\_dir }}/group\_vars/context\_{{ item }}”  
register: contexts  
with\_items:
- “{{ wildfly\_context }}”

# this produces the blob above

- debug:  
msg: “1 {{ contexts }}”

I want to loop over it, but I appear to have nested loops, and this is where I struggle - here the first loop over results.

- debug:  
msg: “4 {% for gav in contexts[‘results’] %}{{ gav.ansible\_facts }} {% endfor %}”

How can I loop over ansible\_facts’: {‘application\_gavdeploy\_list’ to get all my artifactId’s for example?
