summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Mellado <dmellado@redhat.com>2018-01-15 14:19:02 +0100
committerRicardo Carrillo Cruz <ricardo.carrillo.cruz@gmail.com>2018-01-15 14:19:02 +0100
commited806f0feeef1e7c70e13a40e4f1edd4e71e9a25 (patch)
tree8e72ea1a2c146b888a716a56c704e4c8f95e581a /lib
parent9851a0540f55b1440b73058805e638786928205e (diff)
downloadansible-ed806f0feeef1e7c70e13a40e4f1edd4e71e9a25.tar.gz
Add support for heat stack metadata (#34573)
This commit adds support for heat tag metadata when creating a new stack.
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/modules/cloud/openstack/os_stack.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/ansible/modules/cloud/openstack/os_stack.py b/lib/ansible/modules/cloud/openstack/os_stack.py
index e250b5bde8..cfde6c0800 100644
--- a/lib/ansible/modules/cloud/openstack/os_stack.py
+++ b/lib/ansible/modules/cloud/openstack/os_stack.py
@@ -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']