Ansible ec2_vpc_route_table Playbook错误为:“ dict对象”没有属性子网

时间:2019-01-22 09:58:22

标签: amazon-web-services ansible

我有一个以前为Ansible承包的Ansible作品,并且收到了一条错误消息,提示我没有朝着正确的方向发展。我已经尝试搜索了几天,没有任何乐趣,而我的同事也无法弄清楚。

有问题的Ansible是:-

- 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

错误消息是:-

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\nThe error appears to have been in '/cup/core-kubernetes-linux/ansible/roles/aws_vpc/tasks/routes.yml': line 62, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Routes | Set up NAT-protected route table\n  ^ here\n"}

我尝试为az_to_private_sub和public_subnet_to_az添加额外的调试,这些看起来不错。我尝试阅读docs

有人可以建议我下一步去哪里吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

与其他同事交谈后,他们指出可以使用的版本使用Ansible 2.5.5,而我尝试使用2.5.1时,boto python库也需要使用正确的版本。