# IAM Roles with Ansible

**URL:** <https://forum.ansible.com/t/iam-roles-with-ansible/23244>\
**Category:** Ansible Project\
**Created:** [December 12, 2016, 10:45pm UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244 "2016-12-12T22:45:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DG11](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@DG11](https://forum.ansible.com/u/DG11)\
**Post date:** [December 12, 2016, 10:45pm UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244/1 "2016-12-12T22:45:06Z")

</div>

# Example of role with custom trust policy for Lambda service

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [December 13, 2016, 6:19am UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244/2 "2016-12-13T06:19:56Z")

</div>

Hi,

I believe it is ‘tasks:’

Vincent

---

<div class="post-metadata">

**Author:** ![DG11](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@DG11](https://forum.ansible.com/u/DG11)\
**Post date:** [December 13, 2016, 12:31pm UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244/3 "2016-12-13T12:31:52Z")

</div>

Made the modification still no luck:

ansible-playbook -i /etc/ansible/local Dev-Test-IAM-pwr.yaml  
ERROR! playbooks must be a list of plays

The error appears to have been in /Dev-Test-IAM-pwr.yaml’: line 3, column 1, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---

<div class="post-metadata">

**Author:** ![Jeremy\_Young](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@Jeremy\_Young](https://forum.ansible.com/u/Jeremy_Young)\
**Post date:** [December 13, 2016, 1:05pm UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244/4 "2016-12-13T13:05:40Z")

</div>

Looks like a spacing issue. Your list of tasks needs to be indented two spaces.

---

<div class="post-metadata">

**Author:** ![DG11](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@DG11](https://forum.ansible.com/u/DG11)\
**Post date:** [December 13, 2016, 1:18pm UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244/5 "2016-12-13T13:18:24Z")

</div>

Ok I ran by using the command `ansible-playbook -i /etc/ansible/local Dev-Test-IAM.yml`

Is that the fault? Do I need to specifically call the module into play? Example: the EC2\_Group in the past the module was called out in the yml file. But I see that has changed.

`

---

<div class="post-metadata">

**Author:** ![DG11](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@DG11](https://forum.ansible.com/u/DG11)\
**Post date:** [December 13, 2016, 8:46pm UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244/6 "2016-12-13T20:46:40Z")

</div>

Spacing was changed and I am really at a loss.  
Python 2.7.12

ansible 2.3.0

Mac

If someone can create an example that works, I will be willing to try that, to be able to move forward.

Any help?

---

<div class="post-metadata">

**Author:** ![Josh\_Smift1](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Josh\_Smift1](https://forum.ansible.com/u/Josh_Smift1)\
**Post date:** [December 13, 2016, 9:02pm UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244/7 "2016-12-13T21:02:28Z")

</div>

Is the file that you're showing here a playbook, or a role file?

If it's a playbook, it needs more stuff than just the list of tasks. See  
[https://docs.ansible.com/ansible/playbooks\_intro.html](https://docs.ansible.com/ansible/playbooks_intro.html) for some basics.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

---

<div class="post-metadata">

**Author:** ![DG11](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@DG11](https://forum.ansible.com/u/DG11)\
**Post date:** [December 13, 2016, 9:18pm UTC](https://forum.ansible.com/t/iam-roles-with-ansible/23244/8 "2016-12-13T21:18:21Z")

</div>

Yep that was it, thanks for the pointer! This throws errors but this is the right direction.

`
