1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add support for heat stack metadata (#34573)

This commit adds support for heat tag metadata when creating a new
stack.
This commit is contained in:
Daniel Mellado 2018-01-15 14:19:02 +01:00 committed by Ricardo Carrillo Cruz
parent 9851a0540f
commit ed806f0fee

View file

@ -34,6 +34,12 @@ options:
description:
- Name of the stack that should be created, name could be char and digit, no space
required: true
tag:
description:
- Tag for the stack that should be created, name could be char and digit, no space
required: false
default: None
version_added: "2.5"
template:
description:
- Path of the template file to use for the stack creation
@ -74,6 +80,7 @@ EXAMPLES = '''
register: stack_create
os_stack:
name: "{{ stack_name }}"
tag: "{{ tag_name }}"
state: present
template: "/path/to/my_stack.yaml"
environment:
@ -166,6 +173,7 @@ from ansible.module_utils.openstack import openstack_full_argument_spec, opensta
def _create_stack(module, stack, cloud):
try:
stack = cloud.create_stack(module.params['name'],
tags=module.params['tag'],
template_file=module.params['template'],
environment_files=module.params['environment'],
timeout=module.params['timeout'],
@ -216,6 +224,7 @@ def main():
argument_spec = openstack_full_argument_spec(
name=dict(required=True),
tag=dict(required=False, default=None),
template=dict(default=None),
environment=dict(default=None, type='list'),
parameters=dict(default={}, type='dict'),
@ -229,9 +238,15 @@ def main():
supports_check_mode=True,
**module_kwargs)
# stack API introduced in 1.8.0
if not HAS_SHADE or (StrictVersion(shade.__version__) < StrictVersion('1.8.0')):
module.fail_json(msg='shade 1.8.0 or higher is required for this module')
tag = module.params['tag']
if tag is not None:
# stack tag API was introduced in 1.26.0
if not HAS_SHADE or (StrictVersion(shade.__version__) < StrictVersion('1.26.0')):
module.fail_json(msg='shade 1.26.0 or higher is required for this module')
else:
# stack API introduced in 1.8.0
if not HAS_SHADE or (StrictVersion(shade.__version__) < StrictVersion('1.8.0')):
module.fail_json(msg='shade 1.8.0 or higher is required for this module')
state = module.params['state']
name = module.params['name']