# Ansible Playbook error - Dict object has no attribute.

**URL:** <https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [October 22, 2018, 12:17pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843 "2018-10-22T12:17:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [October 22, 2018, 12:17pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/1 "2018-10-22T12:17:31Z")

</div>

Hi,

I am trying to create a Direct connect Gateway in AWS account using ansible. I have the main playbook and an account config yaml template. When I run the playbook I am getting an error

fatal: [infrastructure]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘stacks’\n\nThe error appears to have been in ‘/home/ec2-user/environment/aws-rxgt-mgmt-platform/ansible/rxgt-ps-rxgtmgmt-playbook.yaml’: line 10, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n tasks:\n - name: create rxgt-ps-mgmt-direct-connect-gateway stack\n ^ here\n”}

I have attached the code for reference and error. can someone please help?

Thanks

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [October 22, 2018, 12:20pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/2 "2018-10-22T12:20:20Z")

</div>

main playbook code

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [October 22, 2018, 1:32pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/3 "2018-10-22T13:32:27Z")

</div>

The indentation is wrong (line 10, column 5). Should be:

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [October 22, 2018, 1:37pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/4 "2018-10-22T13:37:27Z")

</div>

I have corrected that. I am concerned if line 17 is correct

Thanks

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [October 22, 2018, 1:37pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/5 "2018-10-22T13:37:50Z")

</div>

I think the indentation appears wrong just in the preview. I downloaded the file and the indentation is fine on line 10.  
It seems this line is the issue: combine(rxgt\_mgmt\_account.account\_config.stacks[‘rxgt-ps-mgmt-direct-connect-gateway’].override\_tags, recursive=True) }}"  
It says that dictionary has no key named stacks. Maybe try just printing that dict or do -vvv to see what keys that it actually has.

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [October 22, 2018, 3:09pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/6 "2018-10-22T15:09:37Z")

</div>

I did -vvv and I don’t see anything different. Same error and it gathered the facts. Not sure if my debug stack task is correct.

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [October 22, 2018, 4:06pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/7 "2018-10-22T16:06:42Z")

</div>

It seems there is one level between account\_config and stack.  
Maybe try account\_config.xxxxxx.stacks instead?

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [October 22, 2018, 5:38pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/8 "2018-10-22T17:38:02Z")

</div>

ok, I used the below

template\_parameters: “{{ rxgt\_mgmt\_account.account\_config.rxgtmgmt.stacks[‘rxgt-ps-mgmt-direct-connect-gateway’].params }}”  
tags: “{{ global\_tags | combine(rxgt\_mgmt\_account.account\_config.rxgtmgmt.stacks[‘rxgt-ps-mgmt-direct-connect-gateway’].override\_tags, recursive=True) }}”

TASK [create rxgt-ps-mgmt-direct-connect-gateway stack] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [infrastructure]: FAILED! =\> {“msg”: “|combine expects dictionaries, got Undefined”}  
to retry, use: --limit @/home/ec2-user/.ansible-retry/site.retry

---

<div class="post-metadata">

**Author:** ![Kishore\_Ponniah](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kishore\_Ponniah](https://forum.ansible.com/u/Kishore_Ponniah)\
**Post date:** [October 22, 2018, 6:04pm UTC](https://forum.ansible.com/t/ansible-playbook-error-dict-object-has-no-attribute/28843/9 "2018-10-22T18:04:18Z")

</div>

I managed to sort out, there is no parameter called “template\_parameter”

- name: create rxgt-ps-mgmt-direct-connect-gateway stack  
aws\_direct\_connect\_gateway:  
state: present  
region: “”  
aws\_access\_key: “”  
aws\_secret\_key: “”  
security\_token: “”  
name: “{{ rxgt\_mgmt\_account.account\_config.rxgtmgmt.stacks[‘rxgt-ps-mgmt-direct-connect-gateway’].params.name }}”  
amazon\_asn: “{{ rxgt\_mgmt\_account.account\_config.rxgtmgmt.stacks[‘rxgt-ps-mgmt-direct-connect-gateway’].params.amazon\_asn }}”  
register: created\_aws\_direct\_connect\_gateway  
tags:  
rxgt-ps-mgmt-dxgw-deploy
