# Os\_client\_config module does not set facts

**URL:** <https://forum.ansible.com/t/os-client-config-module-does-not-set-facts/7922>\
**Category:** Get Help\
**Tags:** openstack, cloud\
**Created:** [August 18, 2024, 9:15pm UTC](https://forum.ansible.com/t/os-client-config-module-does-not-set-facts/7922 "2024-08-18T21:15:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salvatore\_Mazzarino](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/salvatore_mazzarino/32/4494_2.png) [@Salvatore\_Mazzarino](https://forum.ansible.com/u/Salvatore_Mazzarino)\
**Post date:** [August 18, 2024, 9:15pm UTC](https://forum.ansible.com/t/os-client-config-module-does-not-set-facts/7922/1 "2024-08-18T21:15:48Z")

</div>

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

```auto
- 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

```auto
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](https://docs.ansible.com/ansible/2.7/modules/os_client_config_module.html) the facts should be set but they are not

these are the versions of the dependencies installed.

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

```

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [August 19, 2024, 6:22am UTC](https://forum.ansible.com/t/os-client-config-module-does-not-set-facts/7922/2 "2024-08-19T06:22:16Z")

</div>

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](https://docs.ansible.com/ansible/latest/collections/openstack/cloud/config_module.html)

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

```yaml
    - 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`.)

---

<div class="post-metadata">

**Author:** ![Salvatore\_Mazzarino](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/salvatore_mazzarino/32/4494_2.png) [@Salvatore\_Mazzarino](https://forum.ansible.com/u/Salvatore_Mazzarino)\
**Post date:** [August 19, 2024, 6:42am UTC](https://forum.ansible.com/t/os-client-config-module-does-not-set-facts/7922/3 "2024-08-19T06:42:56Z")

</div>

Thank you.

The code there is from upstream openstack Tenks [tenks/ansible/roles/ironic-enrolment/tasks/main.yml at 2ca88097dcd3f3f9ce4f158ed487e7444859c782 · openstack/tenks · GitHub](https://github.com/openstack/tenks/blob/2ca88097dcd3f3f9ce4f158ed487e7444859c782/ansible/roles/ironic-enrolment/tasks/main.yml#L51)

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 18, 2024, 6:43am UTC](https://forum.ansible.com/t/os-client-config-module-does-not-set-facts/7922/4 "2024-09-18T06:43:55Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
