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']