# Problems with a variable list in a loop

**URL:** <https://forum.ansible.com/t/problems-with-a-variable-list-in-a-loop/19664>\
**Category:** Ansible Project\
**Created:** [October 31, 2015, 5:14am UTC](https://forum.ansible.com/t/problems-with-a-variable-list-in-a-loop/19664 "2015-10-31T05:14:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Huddleston](https://avatars.discourse-cdn.com/v4/letter/b/2bfe46/32.png) [@Brian\_Huddleston](https://forum.ansible.com/u/Brian_Huddleston)\
**Post date:** [October 31, 2015, 5:14am UTC](https://forum.ansible.com/t/problems-with-a-variable-list-in-a-loop/19664/1 "2015-10-31T05:14:58Z")

</div>

I have a odd problem iterating through a list, I’m trying to define a role that will install multiple SSH keys from GitHub.

---

<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:** [October 31, 2015, 11:15pm UTC](https://forum.ansible.com/t/problems-with-a-variable-list-in-a-loop/19664/2 "2015-10-31T23:15:03Z")

</div>

I think the big difference to note is that you are using “with\_items” in your playbook example, but not in your role. Is there a reason for that?

Your task in the role should look just like the play, however since you defined a variable you can just use “with\_items: ssh\_key\_list”

Such as:

(tasks/main.yml)

- name: Add SSH Keys to the common login user  
authorized\_key: user={{ ubuntu\_common\_login\_user }} key=“{{ item }}”

with\_items: ssh\_key\_list
