2015-03-31 20:37:07 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
|
|
|
#
|
|
|
|
# This module is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This software is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-03-14 16:07:22 +00:00
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'community'}
|
|
|
|
|
2016-12-06 10:35:05 +00:00
|
|
|
|
2015-03-31 20:37:07 +00:00
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
module: os_auth
|
|
|
|
short_description: Retrieve an auth token
|
2015-04-03 01:07:41 +00:00
|
|
|
version_added: "2.0"
|
2015-06-15 18:41:22 +00:00
|
|
|
author: "Monty Taylor (@emonty)"
|
2015-03-31 20:37:07 +00:00
|
|
|
description:
|
2016-12-08 14:38:05 +00:00
|
|
|
- Retrieve an auth token from an OpenStack Cloud
|
2016-12-08 02:33:38 +00:00
|
|
|
requirements:
|
|
|
|
- "python >= 2.6"
|
|
|
|
- "shade"
|
2017-02-17 20:49:03 +00:00
|
|
|
options:
|
|
|
|
availability_zone:
|
|
|
|
description:
|
|
|
|
- Ignored. Present for backwards compatability
|
|
|
|
required: false
|
2015-04-03 01:07:41 +00:00
|
|
|
extends_documentation_fragment: openstack
|
2015-03-31 20:37:07 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
2016-11-16 17:24:21 +00:00
|
|
|
- name: Authenticate to the cloud and retrieve the service catalog
|
|
|
|
os_auth:
|
2015-03-31 20:37:07 +00:00
|
|
|
cloud: rax-dfw
|
2016-11-16 17:24:21 +00:00
|
|
|
|
|
|
|
- name: Show service catalog
|
|
|
|
debug:
|
|
|
|
var: service_catalog
|
2015-03-31 20:37:07 +00:00
|
|
|
'''
|
|
|
|
|
2017-02-02 19:45:22 +00:00
|
|
|
try:
|
|
|
|
import shade
|
|
|
|
from shade import meta
|
|
|
|
HAS_SHADE = True
|
|
|
|
except ImportError:
|
|
|
|
HAS_SHADE = False
|
|
|
|
|
|
|
|
|
2015-03-31 20:37:07 +00:00
|
|
|
def main():
|
|
|
|
|
|
|
|
argument_spec = openstack_full_argument_spec()
|
|
|
|
module_kwargs = openstack_module_kwargs()
|
|
|
|
module = AnsibleModule(argument_spec, **module_kwargs)
|
|
|
|
|
|
|
|
if not HAS_SHADE:
|
|
|
|
module.fail_json(msg='shade is required for this module')
|
|
|
|
|
|
|
|
try:
|
|
|
|
cloud = shade.openstack_cloud(**module.params)
|
|
|
|
module.exit_json(
|
|
|
|
changed=False,
|
|
|
|
ansible_facts=dict(
|
2017-01-29 07:28:53 +00:00
|
|
|
auth_token=cloud.auth_token,
|
|
|
|
service_catalog=cloud.service_catalog))
|
2017-02-23 11:04:43 +00:00
|
|
|
except Exception as e:
|
|
|
|
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
2015-03-31 20:37:07 +00:00
|
|
|
|
|
|
|
# this is magic, see lib/ansible/module_common.py
|
|
|
|
from ansible.module_utils.basic import *
|
|
|
|
from ansible.module_utils.openstack import *
|
2016-12-08 02:33:38 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|