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