# Can't proceed with\_items and register

**URL:** <https://forum.ansible.com/t/cant-proceed-with-items-and-register/35652>\
**Category:** Ansible Project\
**Created:** [August 20, 2021, 1:09pm UTC](https://forum.ansible.com/t/cant-proceed-with-items-and-register/35652 "2021-08-20T13:09:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user62](https://avatars.discourse-cdn.com/v4/letter/u/e47774/32.png) [@user62](https://forum.ansible.com/u/user62)\
**Post date:** [August 20, 2021, 1:09pm UTC](https://forum.ansible.com/t/cant-proceed-with-items-and-register/35652/1 "2021-08-20T13:09:43Z")

</div>

Hello!

Here is the problem:

- name: Check for RSA-Key existence  
stat:  
path: /opt/cert/{{item.username}}.key  
with\_items: “{{roles}}”  
register: rsa

- name: debug  
debug:  
var: item.stat.exists  
loop: “{{rsa.results}}”

- name: Generate RSA-Key  
community.crypto.openssl\_privatekey:  
path: /opt/cert/{{item.username}}.key  
size: 2048  
when: item.stat.exists == False  
with\_items:

- “{{roles}}”

- “{{rsa.results}}”

The error that i received - The error was: error while evaluating conditional (item.stat.exists == False): ‘dict object’ has no attribute ‘stat’

Debug task goes just well - “item.stat.exists”: true

I am beating around this about 2 days already… What am i dooing wrong and how to make this work?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [August 20, 2021, 1:35pm UTC](https://forum.ansible.com/t/cant-proceed-with-items-and-register/35652/2 "2021-08-20T13:35:19Z")

</div>

I assume what you want is `with_together` for your last task:

- name: Generate RSA-Key  
community.crypto.openssl\_privatekey:  
path: /opt/cert/{{item.0.username}}.key  
size: 2048  
when: item.1.stat.exists == False  
with\_together:
- “{{roles}}”
- “{{rsa.results}}”

Notice the use of `item.1.stat.exists` and `item.0.username`

---

<div class="post-metadata">

**Author:** ![user62](https://avatars.discourse-cdn.com/v4/letter/u/e47774/32.png) [@user62](https://forum.ansible.com/u/user62)\
**Post date:** [August 20, 2021, 4:07pm UTC](https://forum.ansible.com/t/cant-proceed-with-items-and-register/35652/3 "2021-08-20T16:07:53Z")

</div>

Thank you, Matt! Now it works as it should be, thanks again)

пятница, 20 августа 2021 г. в 16:36:08 UTC+3, Matt Martz:
