How to use Auth token in Openstack Ansible Module

102 views Asked by At

I am running the ansible-playbook command for a playbook containing a task using Ansible's openstack.cloud collection, attempting to use the Auth token returned from a previous task:

- name: "Use Token for Retrieving SGs"
  openstack.cloud.security_group_info:
    auth: "{{api_token_response}}"
    auth_type: openstack.cloud.auth
    name: default
  register: security_group_results

The error returned is the following, and I am sure I've misunderstood this authentication plugin. Could I have put in the incorrect "auth_type"?

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin: The plugin openstack.cloud.auth could not be found
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):
  File \"/usr/local/lib/python3.10/dist-packages/keystoneauth1/loading/base.py\", line 78, in get_plugin_loader
    mgr = stevedore.DriverManager(namespace=PLUGIN_NAMESPACE,
  File \"/usr/local/lib/python3.10/dist-packages/stevedore/driver.py\", line 54, in __init__
    super(DriverManager, self).__init__(
  File \"/usr/local/lib/python3.10/dist-packages/stevedore/named.py\", line 89, in __init__
    self._init_plugins(extensions)
  File \"/usr/local/lib/python3.10/dist-packages/stevedore/driver.py\", line 113, in _init_plugins
    raise NoMatches('No %r driver found, looking for %r' %
stevedore.exception.NoMatches: No 'keystoneauth1.plugin' driver found, looking for 'openstack.cloud.auth'

During handling of the above exception, another exception occurred:
....
....
....
keystoneauth1.exceptions.auth_plugins.NoMatchingPlugin: The plugin openstack.cloud.auth could not be found

my api_token_response variable is a dict that looks like this:

{
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "auth_token": "asdf1234workssuccessfully",
    "changed": false,
    "failed": false
}
1

There are 1 answers

1
Alexander Pletnev On

You're passing the whole apo_token_response variable as an auth token. Most likely you want to pass a specific value from it like this:

- name: "Use Token for Retrieving SGs"
  openstack.cloud.security_group_info:
    auth: "{{ api_token_response.auth_token }}"
    auth_type: openstack.cloud.auth
    name: default
  register: security_group_results