0

我正在运行以下 uri 模块以在重新启动后查找 jenkins 页面的状态。但不幸的是,我收到一个错误,因为 Ansible ImportError: cannot import name 'prepare_multipart' 问题

模块:

- name: result-test
  uri:
    url: "http://{{ jenkins_cm_hostname }}:{{ jenkins_http_port }}{{ jenkins_url_prefix }}"
    method: GET
    return_content: "yes"
    timeout: 5
    body_format: raw
    follow_redirects: "no"
    status_code: 200,403
  register: result 

输出:

"module_stdout": "/etc/bashrc: line 94: TMOUT: readonly variable\r\nTraceback (most recent call last):\r\n  File \"/home/ec2-user/.ansible/tmp/ansible-tmp-1628318438.5060062-180720-115929401717244/AnsiballZ_uri.py\", line 100, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ec2-user/.ansible/tmp/ansible-tmp-1628318438.5060062-180720-115929401717244/AnsiballZ_uri.py\", line 92, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/ec2-user/.ansible/tmp/ansible-tmp-1628318438.5060062-180720-115929401717244/AnsiballZ_uri.py\", line 41, in invoke_module\r\n    run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_ansible.legacy.uri_payload_bBh_2I/ansible_ansible.legacy.uri_payload.zip/ansible/modules/uri.py\", line 423, in <module>\r\nImportError: cannot import name prepare_multipart\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

额外细节:

一些博客说这是由于多个ansible安装(通过yum,pip ..等)。但是这里我有ansible控制器,它只使用pip和我运行这个模块的节点安装了ansible,没有ansible已安装。目标是使用 terraform 配置的。

你能指导我如何解决这个问题吗

4

0 回答 0