Pulp.squeezer.rpm_repository module not creating cache JSON file - probably SSL issue?

I’m getting the following error when trying to create an RPM repository via the Ansible module, pulp.squeezer.rpm_repository:

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_prql7ynb/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py", line 79, in load_api
FileNotFoundError: [Errno 2] No such file or directory: '/home/lexampe_user/.cache/squeezer/localhost/api.json'

The first problem was that ~/.cache didn’t exist so I created it.
Next, ~./squeezer didn’t exist so I created that directory.
The next problem was that ~/.cache/squeezer/ didn’t exist so I created that directory, too.

The squeezer module relies on ~/.cache being created. ~/.cache didn’t get created when I installed the squeezer collection. Neither did it get created when I installed Ansible community.general collection. The squeezer module(s) don’t create ~/.cache.

Here’s my play:

  - name:  Read list of RPM repositories from Pulp API server.
    pulp.squeezer.rpm_repository:
      pulp_url:  "https://localhost:8080"
      username: admin
      password: asfasfasfasf
      validate_certs: false
    register: repo_status

Before I submit an issue on Github, can anyone see anything that I’m doing wrong?

  {
            "component": "core",
            "version": "3.43.1",
            "package": "pulpcore",
            "domain_compatible": true
        },

Ansible collection squeezer version 0.0.14.

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py", line 79, in load_api
FileNotFoundError: [Errno 2] No such file or directory: '/home/example/.cache/squeezer/https___localhost_8080/api.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/urllib/request.py", line 1349, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib64/python3.6/http/client.py", line 1273, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1319, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1268, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1044, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 982, in send
    self.connect()
  File "/usr/lib64/python3.6/http/client.py", line 1441, in connect
    server_hostname=server_hostname)
  File "/usr/lib64/python3.6/ssl.py", line 365, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib64/python3.6/ssl.py", line 810, in __init__
    self.do_handshake()
  File "/usr/lib64/python3.6/ssl.py", line 1070, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib64/python3.6/ssl.py", line 648, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:897)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/example/.ansible/tmp/ansible-tmp-1702998457.7981946-3023163-265382180876333/AnsiballZ_rpm_repository.py", line 107, in <module>
    _ansiballz_main()
  File "/home/example/.ansible/tmp/ansible-tmp-1702998457.7981946-3023163-265382180876333/AnsiballZ_rpm_repository.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/example/.ansible/tmp/ansible-tmp-1702998457.7981946-3023163-265382180876333/AnsiballZ_rpm_repository.py", line 48, in invoke_module
    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_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/modules/rpm_repository.py", line 110, in <module>
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/modules/rpm_repository.py", line 95, in main
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/pulp.py", line 78, in __enter__
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py", line 65, in __init__
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py", line 84, in load_api
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py", line 108, in _download_api
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible/module_utils/urls.py", line 1578, in open
  File "/usr/lib64/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib64/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible/module_utils/urls.py", line 605, in https_open
  File "/usr/lib64/python3.6/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:897)>
fatal: [example.com]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "module_stderr": "Shared connection to example.com closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py\", line 79, in load_api\r\nFileNotFoundError: [Errno 2] No such file or directory: '/home/example/.cache/squeezer/https___localhost_8080/api.json'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 1349, in do_open\r\n    encode_chunked=req.has_header('Transfer-encoding'))\r\n  File \"/usr/lib64/python3.6/http/client.py\", line 1273, in request\r\n    self._send_request(method, url, body, headers, encode_chunked)\r\n  File \"/usr/lib64/python3.6/http/client.py\", line 1319, in _send_request\r\n    self.endheaders(body, encode_chunked=encode_chunked)\r\n  File \"/usr/lib64/python3.6/http/client.py\", line 1268, in endheaders\r\n    self._send_output(message_body, encode_chunked=encode_chunked)\r\n  File \"/usr/lib64/python3.6/http/client.py\", line 1044, in _send_output\r\n    self.send(msg)\r\n  File \"/usr/lib64/python3.6/http/client.py\", line 982, in send\r\n    self.connect()\r\n  File \"/usr/lib64/python3.6/http/client.py\", line 1441, in connect\r\n    server_hostname=server_hostname)\r\n  File \"/usr/lib64/python3.6/ssl.py\", line 365, in wrap_socket\r\n    _context=self, _session=session)\r\n  File \"/usr/lib64/python3.6/ssl.py\", line 810, in __init__\r\n    self.do_handshake()\r\n  File \"/usr/lib64/python3.6/ssl.py\", line 1070, in do_handshake\r\n    self._sslobj.do_handshake()\r\n  File \"/usr/lib64/python3.6/ssl.py\", line 648, in do_handshake\r\n    self._sslobj.do_handshake()\r\nssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:897)\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/example/.ansible/tmp/ansible-tmp-1702998457.7981946-3023163-265382180876333/AnsiballZ_rpm_repository.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/example/.ansible/tmp/ansible-tmp-1702998457.7981946-3023163-265382180876333/AnsiballZ_rpm_repository.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/example/.ansible/tmp/ansible-tmp-1702998457.7981946-3023163-265382180876333/AnsiballZ_rpm_repository.py\", line 48, in invoke_module\r\n    run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/modules/rpm_repository.py\", line 110, in <module>\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/modules/rpm_repository.py\", line 95, in main\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/pulp.py\", line 78, in __enter__\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py\", line 65, in __init__\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py\", line 84, in load_api\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible_collections/pulp/squeezer/plugins/module_utils/openapi.py\", line 108, in _download_api\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible/module_utils/urls.py\", line 1578, in open\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 223, in urlopen\r\n    return opener.open(url, data, timeout)\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 526, in open\r\n    response = self._open(req, data)\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 544, in _open\r\n    '_open', req)\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 504, in _call_chain\r\n    result = func(*args)\r\n  File \"/tmp/ansible_pulp.squeezer.rpm_repository_payload_m1mbrreg/ansible_pulp.squeezer.rpm_repository_payload.zip/ansible/module_utils/urls.py\", line 605, in https_open\r\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 1351, in do_open\r\n    raise URLError(err)\r\nurllib.error.URLError: <urlopen error [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:897)>\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

PLAY RECAP ***************************************************************************************************************************************************************************************
example.com             : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Quite possibly a bug in Python3 URLLIB

I changed my pulp_url from “https://” to “http://” and it’s working.