Use debug statements so that you know what is in " existing_nat_gateways.result" and "public_subnets_to_az".
It looks to me as if there is no element called "subnet-0facefaceface9" in the dictionary "public_subnets_to_az" (that is a very cool subnet ID by the way). Regards, K. On Tue, Jan 22, 2019 at 10:51 PM Steve Button <[email protected]> wrote: > I have a previously working piece of Ansible that I've inherited for a > previous contractor, and I'm getting an error message that doesn't lead me > in the right direction. I have tried searching for a few days now, with no > joy, and my colleagues can't figure it out either. > > > The Ansible in question is :- > > > - name: Routes | Set up NAT-protected route table > ec2_vpc_route_table: > vpc_id: "{{ ec2_vpc_net_reg.vpc.id }}" > region: "{{ vpc_region }}" > tags: > Name: "Internal {{ item.subnet_id }}" > subnets: > - "{{ az_to_private_sub[public_subnets_to_az[item.subnet_id]] }}" > - "{{ az_to_private_data_sub[public_subnets_to_az[item.subnet_id]] }}" > routes: > - dest: 0.0.0.0/0 > gateway_id: "{{ item.nat_gateway_id }}" > loop: "{{ existing_nat_gateways.result|flatten(levels=1) }}" > #with_items: "{{ existing_nat_gateways.result }}" > register: nat_route_table > retry: 2 > delay: 10 > > > And the error message is :- > > > fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an > undefined variable. The error was: 'dict object' has no attribute > u'subnet-0facefaceface9'\n\n > > The error appears to have been in > '/cup/core-kubernetes-linux/ansible/roles/aws_vpc/tasks/routes.yml': line 62, > column 3, but may\n > > be elsewhere in the file depending on the exact syntax problem.\n\n > > The offending line appears to be:\n\n\n > > - name: Routes | Set up NAT-protected route table\n > > ^ here\n > > "} > > > I have added some carriage returns to make it a bit more readable. > > > I have tried adding extra debug, for az_to_private_sub and > public_subnet_to_az, and these look OK. I've tried reading the docs > <https://docs.ansible.com/ansible/2.5/user_guide/playbooks_loops.html#using-register-with-a-loop> > > Can anyone suggest where I should look next? > > > Thanks! > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/e1bd8cda-ae5a-4a3b-bcf3-13293d72c5b3%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/e1bd8cda-ae5a-4a3b-bcf3-13293d72c5b3%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Karl Auer Email : [email protected] Website: http://2pisoftware.com GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816 Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08TQHN2jMKoMjci8xSY0wQ5x1QCCi1_sdos%2B%3DtKOLWC2%2Bw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
