Os_client_config module does not set facts

I’m using the os_client_config openstack module. this is the piece of code where I’m using which comes from OpenStack tenks.

- name: Set ironic_url for os_ironic module
  when: lookup('env', 'OS_CLOUD') | length > 0
  block:
    - name: Query clouds.yaml
      os_client_config:
        clouds: "{{ lookup('env', 'OS_CLOUD') }}"
      delegate_to: localhost
      vars:
        ansible_python_interpreter: >-
          {{ lookup('env', 'VIRTUAL_ENV') | default('/usr', true) ~ '/bin/python' }}

    - name: Fail if the cloud was not found
      fail:
        msg: >
          Cloud {{ lookup('env', 'OS_CLOUD') }} was not found in clouds.yaml
      when: >-
        openstack.clouds | length == 0 or
        not openstack.clouds[0].get('auth', {}).get('endpoint')

    - name: Set a fact about the ironic API endpoint
      set_fact:
        ironic_url: "{{ openstack.clouds[0].auth.endpoint }}"

I’ve debug and the os_client_config find successfully the cloud

ok: [localhost] => {
    "changed": false,
    "clouds": [
        {
            "config": {
                "api_timeout": null,
                "auth": {
                    "endpoint": "https://192.168.170.3:6385",
                    "password": "[redacted]",
                    "username": "bifrost_user"
                },
                "auth_type": "http_basic",
                "baremetal_introspection_endpoint_override": "https://192.168.170.3:5050",
                "baremetal_introspection_status_code_retries": "5",
                "baremetal_status_code_retries": "5",
                "cacert": "/home/salvatoremazz/.config/openstack/bifrost.crt",
                "cert": null,
                "disable_vendor_agent": {},
                "floating_ip_source": "neutron",
                "image_api_use_tasks": false,
                "image_format": "qcow2",
                "image_status_code_retries": "5",
                "interface": "public",
                "key": null,
                "message": "",
                "network_api_version": "2",
                "networks": [],
                "object_store_api_version": "1",
                "region_name": "",
                "secgroup_source": "neutron",
                "status": "active",
                "verify": true
            },
            "name": "bifrost"
        }
    ],
    "invocation": {
        "module_args": {
            "clouds": [
                "bifrost"
            ]
        }
    }
}

Then the next task fails because openstack.clouds is not defined. Looking at the os_client_config module documentation os_client_config – Get OpenStack Client config — Ansible Documentation the facts should be set but they are not

these are the versions of the dependencies installed.

 pip list
Package            Version
------------------ -----------
ansible            5.10.0
ansible-core       2.12.10

You are looking at a very old version of the os_client_config documentation. (Ansible 2.7 is End of Life for over four years by now.) The current documentation can be found here (and the module is now called openstack.cloud.config): openstack.cloud.config module – Get OpenStack Client config — Ansible Community Documentation

You need to register the output of the openstack.cloud.config task, like this:

    - name: Query clouds.yaml
      openstack.cloud.config:
        clouds: "{{ lookup('env', 'OS_CLOUD') }}"
      delegate_to: localhost
      vars:
        ansible_python_interpreter: >-
          {{ lookup('env', 'VIRTUAL_ENV') | default('/usr', true) ~ '/bin/python' }}
      register: openstack

Then you can use openstack.clouds. (You should probably use a more expressive variable name than openstack.)

Thank you.

The code there is from upstream openstack Tenks tenks/ansible/roles/ironic-enrolment/tasks/main.yml at 2ca88097dcd3f3f9ce4f158ed487e7444859c782 · openstack/tenks · GitHub

I tought it would be legit since it was updated recently.