dict object has no attribute

71 views
Skip to first unread message

kki...@gmail.com

unread,
Jun 15, 2021, 8:52:16 AM6/15/21
to Ansible Project
Hi All,

I am trying to re-create the AWS Core infrastructure using ansible in another region. I am getting the following error

The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'vpc_endpoints'\n\nThe error appears to be in '/home/ec2-user/environment/aws-rxgt-b2b-platform/ansible/rxgt-ps-rxgtb2b-playbook.yaml': line 646, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: create rxgt-ps-b2b-app-vpc-endpoints changeset\n      ^ here\n"}

I tried to debug this by creating a debug statement before this task and it prints out everything. But running this task gives the above error message.

Could someone please help me identify the problem?

Thanks
Kishore


Prasanna Kumar

unread,
Jun 15, 2021, 8:59:23 AM6/15/21
to ansible...@googlegroups.com
Can you provide snapshot of what your task looks like?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/89c20198-3888-4e74-afcb-a52e76524c19n%40googlegroups.com.

kki...@gmail.com

unread,
Jun 15, 2021, 9:11:15 AM6/15/21
to Ansible Project
Below is the task

    - name: create rxgt-ps-b2b-app-vpc-endpoints changeset
      cloudformation_execute_changeset:
        stack_name: "rxgt-ps-b2b-app-vpc-endpoints"
        state: present
        region: "{{ stack_output_result.net_stack_output_result.account_config.1 }}"
        aws_access_key: "{{ stack_output_result.net_stack_output_result.account_config.0.sts_creds.access_key }}"
        aws_secret_key: "{{ stack_output_result.net_stack_output_result.account_config.0.sts_creds.secret_key }}"
        security_token: "{{ stack_output_result.net_stack_output_result.account_config.0.sts_creds.session_token }}"
        create_changeset: true
        execute_changeset: "{{ with_stack_deploy }}"
        changeset_name: "{{ cf_changeset_name }}"
        template_body: "{{ lookup('template', 'rxgt-ps-b2b-app-vpc-endpoints.yaml.j2') }}"
        template_parameters:
          VPC: "{{ stack_output_result.net_stack_output_result.ansible_facts.cloudformation['rxgt-ps-b2b-app-vpc'].stack_outputs['VPC'] }}"
          RouteTables: "{{ (stack_output_result.ansible_facts.cloudformation['rxgt-ps-b2b-app-networks'].stack_outputs['PublicRouteTable'], stack_output_result.ansible_facts.cloudformation['rxgt-ps-b2b-app-networks'].stack_outputs['PrivatePreprodPrivateRouteTable'], stack_output_result.ansible_facts.cloudformation['rxgt-ps-b2b-app-networks'].stack_outputs['PrivateProdPrivateRouteTable']) | join(',') }}"
          PublicSubnets: "{{ stack_output_result.net_stack_output_result.ansible_facts.cloudformation['rxgt-ps-b2b-app-vpc'].stack_outputs['PublicSubnets'] }}"
          SecurityGroupIds: "{{ stack_output_result.net_stack_output_result.account_config.0.account_config.vpcs[stack_output_result.net_stack_output_result.account_config.1].app.vpc_endpoints.security_group_ids|join(',') }}"
        termination_protection: no
        tags: "{{ global_tags | combine(stack_output_result.net_stack_output_result.account_config.0.account_config.stacks['rxgt-ps-b2b-app-vpc-endpoints'].override_tags, recursive=True) }}"
      loop: "{{ b2b_app_networks_stack_outputs.results }}"
      loop_control:
        loop_var: stack_output_result
        label: "{{ stack_output_result.net_stack_output_result.account_config.1 }}"
      register: stack_changeset_results
      tags:
        - rxgt-ps-b2b-vpc-stack-deploy
        - rxgt-ps-b2b-securitygroups

Prasanna Kumar

unread,
Jun 15, 2021, 10:12:41 AM6/15/21
to ansible...@googlegroups.com
From your mail , I can see vpc_endpoints is referenced from stack_output_result.

SecurityGroupIds: "{{ stack_output_result.net_stack_output_result.account_config.0.account_config.vpcs[stack_output_result.net_stack_output_result.account_config.1].app.vpc_endpoints.security_group_ids|join(',') }}"

And the error you have pinged in the first mail is..

The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'vpc_endpoints'\n\nThe error appears to be in '/home/ec2-user/environment/aws-rxgt-b2b-platform/ansible/rxgt-ps-rxgtb2b-playbook.yaml': line 646, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: create rxgt-ps-b2b-app-vpc-endpoints changeset\n ^ here\n"}

So, I would suggest you to add a Debug task prior to this one and print the variable stack_output_result and go through it to find whether the dict stack_output_result is having vpc_endpoints or not.



kki...@gmail.com

unread,
Jun 15, 2021, 10:27:42 AM6/15/21
to Ansible Project
Hi,

Thanks for coming back. Yes, I added the debug task before this task and it is printing correctly. 

Now I managed to fix this issue by supplying the endpoint SG on the config file which has the endpoints which is what it is expecting.

Thanks again.
Reply all
Reply to author
Forward
0 new messages