Ansible uri 模块 "urlopen error [Errno -2] Name or service not known"

Ansible uri module "urlopen error [Errno -2] Name or service not known"

我想使用 Ansible Tower 和剧本向互联网发出 API 请求,但出现错误。 在这个例子中,我尝试请求https://www.google.com,但结果与其他网站相同。 在这里你可以看到我的剧本 :

---
- name: API call
  environment:
    http_proxy: 'http://{{ username_proxy }}:{{ password_proxy }}@{{ url_proxy }}:8080'
    https_proxy: 'http://{{ username_proxy }}:{{ password_proxy }}@{{ url_proxy }}:8080'
    
  block:
    - name: "Launch API call"
      uri:
        url: "https://www.google.com/"
        return_content: yes
        method: GET
        validate_certs: no
      register: webpage
    
    - name: debug
      debug:
        var: webpage.content    

在这里您可以看到带有错误信息的结果:

{
    "status": -1,
    "_ansible_no_log": false,
    "url": "https://www.google.com/",
    "changed": false,
    "elapsed": 0,
    "content": "",
    "invocation": {
        "module_args": {
            "directory_mode": null,
            "force": false,
            "remote_src": null,
            "status_code": [
                200
            ],
            "follow": false,
            "owner": null,
            "body_format": "raw",
            "client_key": null,
            "group": null,
            "use_proxy": true,
            "unix_socket": null,
            "unsafe_writes": null,
            "serole": null,
            "content": null,
            "setype": null,
            "follow_redirects": "safe",
            "return_content": true,
            "method": "GET",
            "body": null,
            "url_username": null,
            "url_password": null,
            "dest": null,
            "selevel": null,
            "force_basic_auth": false,
            "removes": null,
            "http_agent": "ansible-httpget",
            "regexp": null,
            "src": null,
            "url": "https://www.google.com/",
            "backup": null,
            "seuser": null,
            "client_cert": null,
            "creates": null,
            "headers": {},
            "delimiter": null,
            "mode": null,
            "timeout": 30,
            "attributes": null,
            "validate_certs": false
        }
    },
    "redirected": false,
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "msg": "Status code was -1 and not [200]: Request failed: <urlopen error [Errno -2] Name or service not known>"
}

请问您知道错误的来源吗?

感谢您的宝贵时间。

我想结束我的问题,我把端口写在变量 {{ url_proxy }} 之后,它是一个双胞胎。