# Howto access 'exists' from a register: var which has results?

**URL:** <https://forum.ansible.com/t/howto-access-exists-from-a-register-var-which-has-results/16208>\
**Category:** Ansible Project\
**Created:** [September 13, 2014, 6:15am UTC](https://forum.ansible.com/t/howto-access-exists-from-a-register-var-which-has-results/16208 "2014-09-13T06:15:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Ansible-ML](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@Patrick\_Ansible-ML](https://forum.ansible.com/u/Patrick_Ansible-ML)\
**Post date:** [September 13, 2014, 6:15am UTC](https://forum.ansible.com/t/howto-access-exists-from-a-register-var-which-has-results/16208/1 "2014-09-13T06:15:57Z")

</div>

Hi,

I have a task which checks if some files exist and does a register. In the next task, how do I access the exists: [false|true] result for use in 'when:'? I tried variations of things like this: 'repos\_extra\_installed.results.stats.exists == false'  
but I always get an error.

group\_vars:

repos\_extra\_repos:  
&nbsp;&nbsp;&nbsp;- repos\_extra\_name: internal  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repos\_extra\_file: internal.repo  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repos\_extra\_key: RPM-GPG-KEY-internal

task:

- name: repos | Check if extra repos are already installed  
&nbsp;&nbsp;&nbsp;stat:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path: /etc/yum.repos.d/{{ item.repos\_extra\_file }}  
&nbsp;&nbsp;&nbsp;with\_items: repos\_extra\_repos  
&nbsp;&nbsp;&nbsp;register: repos\_extra\_installed

- debug: var=repos\_extra\_installed

Debug output:

TASK: [common | debug var=repos\_extra\_installed]

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [September 15, 2014, 2:02pm UTC](https://forum.ansible.com/t/howto-access-exists-from-a-register-var-which-has-results/16208/2 "2014-09-15T14:02:01Z")

</div>

It should be repos\_extra\_installed.results[0].stat.exists.

It's more complicated because you're doing a with\_items on the task  
that does the register. So each item in that list will have a separate  
entry in the repos\_extra\_installed.results list.

---

<div class="post-metadata">

**Author:** ![Patrick\_Ansible-ML](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@Patrick\_Ansible-ML](https://forum.ansible.com/u/Patrick_Ansible-ML)\
**Post date:** [September 15, 2014, 5:40pm UTC](https://forum.ansible.com/t/howto-access-exists-from-a-register-var-which-has-results/16208/3 "2014-09-15T17:40:54Z")

</div>

Thank you Michael.

Cheers,  
Patrick
