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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to