Why do Playbooks Using Openstack Modules in Ansible Tower Result in Errors "Cloud <some_cloud> Was Not Found"?

Solution In Progress - Updated -

Environment

  • Ansible Tower >=3.0.x

Issue

Playbooks using openstack modules ran from Ansible Tower using Tower's built in Openstack credentials fail with unable to locate cloud

Resolution

Change the "cloud" attribute to value "devstack" in your playbook.

Root Cause

Ansible Tower dynamically generates a temporary openstack.yml file and points to it with $OS_CLIENT_CONFIG_FILE in the job runtime env. The "cloud" name is always set to devstack and cannot be customized at this time.

Diagnostic Steps

Playbook task example:

    - name: Creating project
      os_project:
        cloud: "some_cloud"
        state: present
        name: "some_name"
        verify: false
        wait: yes

stderr from Tower:

Traceback (most recent call last):
  File \"/tmp/ansible_cIBvWR/ansible_module_os_project.py\", line 237, in <module>
    main()
  File \"/tmp/ansible_cIBvWR/ansible_module_os_project.py\", line 195, in main
    cloud = shade.openstack_cloud(**module.params)
  File \"/home/stack/.local.bak/lib/python2.7/site-packages/shade/__init__.py\", line 109, in openstack_cloud
    cloud_config = config.get_one_cloud(**kwargs)
  File \"/home/stack/.local.bak/lib/python2.7/site-packages/os_client_config/config.py\", line 1041, in get_one_cloud
    config = self._get_base_cloud_config(cloud)
  File \"/home/stack/.local.bak/lib/python2.7/site-packages/os_client_config/config.py\", line 460, in _get_base_cloud_config
    name=name))
os_client_config.exceptions.OpenStackConfigException: Cloud some_cloud was not found.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.