【问题标题】:Ansible AWS Modules Error -> ec2-vpc-route-tableAnsible AWS 模块错误 -> ec2-vpc-route-table
【发布时间】:2020-09-23 19:04:12
【问题描述】:

我在调试 Ansible 中的错误原因时遇到了问题。

我在下面发布所有内容。任何帮助都感激不尽!如果需要更多详细信息,请随时询问。

我已经尝试在另一台机器上使用此代码,并且我还尝试使用不同的 Ansible 和 Python 版本。

提前谢谢你!


Ansible 版本:

$ ansible --version
ansible 2.10.1
  config file = /home/eduardo/packer-eduardo/2/ansible/ansible.cfg
  configured module search path = ['/home/eduardo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

代码:

- name: " setting up public route table.. "
  ec2_vpc_route_table:
    lookup: "tag"
    region: "{{ vpc_region }}"
    routes:
      - dest: "0.0.0.0/0"
        gateway_id: "{{ igw_details }}"
    state: "present"
    subnets: "{{ subnets_pub_list }}"
    tags:
      Name: "rtable-main-ireland-eduardo"
    vpc_id: "{{ vpc_details.vpc.id }}"
  register: pub_route_table_details

错误信息:

 ___________________________________________________________
/ TASK [provision-network : setting up public route table.. \
\ }}]                                                       /
 -----------------------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

task path: /home/eduardo/packer-eduardo/2/ansible/roles/provision-network/tasks/main.yml:59
The full traceback is:
Traceback (most recent call last):
  File "/home/eduardo/.ansible/tmp/ansible-tmp-1600886979.1953619-43130-117149728572740/AnsiballZ_ec2_vpc_route_table.py", line 102, in <module>
    _ansiballz_main()
  File "/home/eduardo/.ansible/tmp/ansible-tmp-1600886979.1953619-43130-117149728572740/AnsiballZ_ec2_vpc_route_table.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/eduardo/.ansible/tmp/ansible-tmp-1600886979.1953619-43130-117149728572740/AnsiballZ_ec2_vpc_route_table.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.ec2_vpc_route_table', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_ec2_vpc_route_table_payload_7wcn68x2/ansible_ec2_vpc_route_table_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_
route_table.py", line 744, in <module>
  File "/tmp/ansible_ec2_vpc_route_table_payload_7wcn68x2/ansible_ec2_vpc_route_table_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_route_table.py", line 736, in main
  File "/tmp/ansible_ec2_vpc_route_table_payload_7wcn68x2/ansible_ec2_vpc_route_table_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_route_table.py", line 642, in ensure_route_table_present
  File "/tmp/ansible_ec2_vpc_route_table_payload_7wcn68x2/ansible_ec2_vpc_route_table_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_route_table.py", line 622, in create_route_spec
AttributeError: 'dict' object has no attribute 'lower'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/eduardo/.ansible/tmp/ansible-tmp-1600886979.1953619-43130-117149728572740/AnsiballZ_ec2_vpc_route_table.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/eduardo/.ansible/tmp/ansible-tmp-1600886979.1953619-43130-117149728572740/AnsiballZ_ec2_vpc_route_table.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/eduardo/.ansible/tmp/ansible-tmp-1600886979.1953619-43130-117149728572740/AnsiballZ_ec2_vpc_route_table.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.ec2_vpc_route_table', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_ec2_vpc_route_table_payload_7wcn68x2/ansible_ec2_vpc_route_table_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_route_table.py\", line 744, in <module>\n  File \"/tmp/ansible_ec2_vpc_route_table_payload_7wcn68x2/ansible_ec2_vpc_route_table_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_route_table.py\", line 736, in main\n  File \"/tmp/ansible_ec2_vpc_route_table_payload_7wcn68x2/ansible_ec2_vpc_route_table_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_route_table.py\", line 642, in ensure_route_table_present\n  File \"/tmp/ansible_ec2_vpc_route_table_payload_7wcn68x2/ansible_ec2_vpc_route_table_payload.zip/ansible_collections/community/aws/plugins/modules/ec2_vpc_route_table.py\", line 622, in create_route_spec\nAttributeError: 'dict' object has no attribute 'lower'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

【问题讨论】:

    标签: python amazon-web-services amazon-ec2 ansible


    【解决方案1】:

    子网应该是列表类型变量吗?

    - name: " setting up public route table.. "
      ec2_vpc_route_table:
        region: "{{ vpc_region }}"
        vpc_id: "{{ vpc_details.vpc.id }}"
        lookup: "tag"
        state: "present"
        tags:
          Name: "rtable-main-ireland-eduardo"    
        subnets: 
          - "{{ subnets_pub_list }}"
        routes:
          - dest: "0.0.0.0/0"
            gateway_id: "{{ igw_details }}"
      register: pub_route_table_details
    

    【讨论】:

    • 变量定义为:``` subnets_pub_list: - "10.0.1.0/26" - "10.0.1.64/26" - "10.0.1.128/26" ``` 不管怎样,我'我还尝试将值硬编码为字符串列表,但错误是相同的:|
    • 我想我无法真正格式化 cmets 中的文本,但我相信问题不存在。
    猜你喜欢
    • 2020-12-17
    • 2021-05-01
    • 2019-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多