# How to iterate over register variables?

**URL:** <https://forum.ansible.com/t/how-to-iterate-over-register-variables/15003>\
**Category:** Ansible Project\
**Created:** [April 11, 2014, 9:10pm UTC](https://forum.ansible.com/t/how-to-iterate-over-register-variables/15003 "2014-04-11T21:10:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_Dav](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@J\_Dav](https://forum.ansible.com/u/J_Dav)\
**Post date:** [April 11, 2014, 9:10pm UTC](https://forum.ansible.com/t/how-to-iterate-over-register-variables/15003/1 "2014-04-11T21:10:42Z")

</div>

I am trying to create an ansible play that

1. Establishes if a user exists on a host and records the stdout as a register variable. Referencing a dict file which contains what users should be on the host.
2. Creates a group for the user which will be created (with data from the dict) if the stdout == 0
3. Creates a user account (with data from the dict) if the stdout == 0
4. Copies over a sudoers.d template for a pre-existing ops group  
And I saw at [https://groups.google.com/forum/#!topic/ansible-project/htHzfr5HzQE](https://groups.google.com/forum/#!topic/ansible-project/htHzfr5HzQE) that the register is turn into a list when combine in with\_items. I can’t seem to figure out how to iterate over a register variable list. Essentially, I’d like for my OpsTeam.yaml variables to correlate with the register variables and use that to determine if action should be taken. Note: this play currently does not work

Here is my code:

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [April 14, 2014, 1:42pm UTC](https://forum.ansible.com/t/how-to-iterate-over-register-variables/15003/2 "2014-04-14T13:42:18Z")

</div>

​The list is within users\_exists.results​
