Skip to content

HTTP 401 Unauthorized when uploading SSH key #57

@jackhodgkiss

Description

@jackhodgkiss

If you provide an SSH key to assign to user it will fail with HTTP 401 Unauthorized.

TASK [stackhpc.openstack.os_projects : Ensure SSH keypairs are registered] ***************************************************************************************************************************************************************************************************************************
Friday 22 August 2025  12:53:56 +0000 (0:00:00.091)       0:00:20.321 *********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: keystoneauth1.exceptions.http.Unauthorized: The request you have made requires authentication. (HTTP 401) (Request-ID: req-430ec8e6-8f20-483c-a0c8-1a791189b211)
failed: [localhost] (item=demo: id_ed25519) => changed=false
  ansible_loop_var: item
  item:
  - description: OpenStack demo project
    name: demo
    project_domain: Default
    quotas:
      backup_gigabytes: -1
      backups: -1
      cores: -1
      floatingip: -1
      gigabytes: -1
      injected_file_size: -1
      injected_files: -1
      instances: -1
      key_pairs: -1
      per_volume_gigabytes: -1
      ram: -1
      security_group: -1
      security_group_rule: -1
      snapshots: -1
      volumes: -1
    user_domain: Default
    users:
    - description: StackHPC Demo user
      email: [email protected]
      name: demo
      password: *****
      roles:
      - member
      - reader
  - name: id_ed25519
    public_key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICKx4TMa8vtpOe3qHeMX4Z7JZyucBcqlfv8iFY6dZkzB
  module_stderr: |-
    Traceback (most recent call last):
      File "/home/stack/.ansible/tmp/ansible-tmp-1755867236.4199255-709459-103411628663297/AnsiballZ_keypair.py", line 107, in <module>
        _ansiballz_main()
      File "/home/stack/.ansible/tmp/ansible-tmp-1755867236.4199255-709459-103411628663297/AnsiballZ_keypair.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/stack/.ansible/tmp/ansible-tmp-1755867236.4199255-709459-103411628663297/AnsiballZ_keypair.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.openstack.cloud.plugins.modules.keypair', init_globals=dict(_module_fqn='ansible_collections.openstack.cloud.plugins.modules.keypair', _modlib_path=modlib_path),
      File "/usr/lib64/python3.9/runpy.py", line 225, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib64/python3.9/runpy.py", line 97, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_openstack.cloud.keypair_payload_ve79l7iy/ansible_openstack.cloud.keypair_payload.zip/ansible_collections/openstack/cloud/plugins/modules/keypair.py", line 178, in <module>
      File "/tmp/ansible_openstack.cloud.keypair_payload_ve79l7iy/ansible_openstack.cloud.keypair_payload.zip/ansible_collections/openstack/cloud/plugins/modules/keypair.py", line 174, in main
      File "/tmp/ansible_openstack.cloud.keypair_payload_ve79l7iy/ansible_openstack.cloud.keypair_payload.zip/ansible_collections/openstack/cloud/plugins/module_utils/openstack.py", line 417, in __call__
      File "/tmp/ansible_openstack.cloud.keypair_payload_ve79l7iy/ansible_openstack.cloud.keypair_payload.zip/ansible_collections/openstack/cloud/plugins/modules/keypair.py", line 140, in run
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/openstack/service_description.py", line 89, in __get__
        proxy = self._make_proxy(instance)
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/openstack/service_description.py", line 289, in _make_proxy
        found_version = temp_adapter.get_api_major_version()
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/adapter.py", line 352, in get_api_major_version
        return self.session.get_api_major_version(auth or self.auth, **kwargs)
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/session.py", line 1289, in get_api_major_version
        return auth.get_api_major_version(self, **kwargs)
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/identity/base.py", line 497, in get_api_major_version
        data = get_endpoint_data(discover_versions=discover_versions)
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/identity/base.py", line 268, in get_endpoint_data
        service_catalog = self.get_access(session).service_catalog
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/identity/base.py", line 131, in get_access
        self.auth_ref = self.get_auth_ref(session)
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/identity/generic/base.py", line 205, in get_auth_ref
        return self._plugin.get_auth_ref(session, **kwargs)
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/identity/v3/base.py", line 185, in get_auth_ref
        resp = session.post(token_url, json=body, headers=headers,
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/session.py", line 1162, in post
        return self.request(url, 'POST', **kwargs)
      File "/home/stack/openstack-config/ansible/openstack-config-venv/lib64/python3.9/site-packages/keystoneauth1/session.py", line 985, in request
        raise exceptions.from_response(resp, method, url)
    keystoneauth1.exceptions.http.Unauthorized: The request you have made requires authentication. (HTTP 401) (Request-ID: req-430ec8e6-8f20-483c-a0c8-1a791189b211)
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions