From 3e4413ec311ad6aea04bb1a04caf1eae44ef6953 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Thu, 20 May 2021 18:43:59 +0200 Subject: [PATCH] Switch auth module to OpenStackModule Change-Id: I6e81a6a8171f62651dce0a4b3cc794b045a5a453 --- plugins/modules/auth.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/plugins/modules/auth.py b/plugins/modules/auth.py index 0b356217..1f2c516e 100644 --- a/plugins/modules/auth.py +++ b/plugins/modules/auth.py @@ -38,29 +38,24 @@ service_catalog: type: dict ''' -import traceback +from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (openstack_full_argument_spec, - openstack_module_kwargs, - openstack_cloud_from_module) + +class AuthModule(OpenStackModule): + argument_spec = dict() + module_kwargs = dict() + + def run(self): + self.exit_json( + changed=False, + ansible_facts=dict( + auth_token=self.conn.auth_token, + service_catalog=self.conn.service_catalog)) def main(): - - argument_spec = openstack_full_argument_spec() - module_kwargs = openstack_module_kwargs() - module = AnsibleModule(argument_spec, **module_kwargs) - - sdk, cloud = openstack_cloud_from_module(module) - try: - module.exit_json( - changed=False, - ansible_facts=dict( - auth_token=cloud.auth_token, - service_catalog=cloud.service_catalog)) - except Exception as e: - module.fail_json(msg=str(e), exception=traceback.format_exc()) + module = AuthModule() + module() if __name__ == '__main__':