0

I'm running the below uri module to find the status of jenkins page after a restart.But unfortunately i'n getting an error as Ansible ImportError: cannot import name 'prepare_multipart' Issue

module:

- 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 

output:

"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
}

Additional details:

Some of the blogs said it is due to multiple ansible installation(via yum,pip..etc).But here i have ansible controller which ansible was installed only using pip and the node where i'm running this module ,there is no ansible installed.Targets are provisioned using terraform.

Could you please guide me how to troubleshot this issue

JPNagarajan
  • 802
  • 1
  • 12
  • 32
  • 2
    Have you made any changes to your environment since it last ran correctly? – larsks Apr 29 '21 at 14:48
  • No.Even i provision a new server and run this,i'm getting the same error.Is it due to any module mismatch between ansible controller machine and this slave machine? – JPNagarajan Apr 29 '21 at 15:30
  • Please edit this question with [your new findings](https://stackoverflow.com/questions/68690031/anible-uri-module-importerror-cannot-import-name-prepare-multipart) (namely the different python version leading to the same result) rather than opening a new one with the same problem. This really looks like a screwed python installation on your target in both cases. Also, this is on the edge of being [off-topic](/help/on-topic) on SO. You might want to move it to https://superuser.com where you might get more chances to get a specific answer. – Zeitounator Aug 07 '21 at 08:57

0 Answers0