From 6df4796dcc1abbbec37e1888308cd1196dec8051 Mon Sep 17 00:00:00 2001 From: Orr Ben Galim Date: Tue, 24 Dec 2024 18:42:29 +0200 Subject: [PATCH] vm_name is required only if state is set to present --- changelogs/fragments/93-bugfix-vm_name-required | 2 +- plugins/modules/content_template.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changelogs/fragments/93-bugfix-vm_name-required b/changelogs/fragments/93-bugfix-vm_name-required index 005ffcac..68c42c6d 100644 --- a/changelogs/fragments/93-bugfix-vm_name-required +++ b/changelogs/fragments/93-bugfix-vm_name-required @@ -1,3 +1,3 @@ --- minor_changes: - - info - Made vm_name variable not required in content_template module \ No newline at end of file + - info - Made vm_name variable required only when state is set to present in content_template module \ No newline at end of file diff --git a/plugins/modules/content_template.py b/plugins/modules/content_template.py index 8ed9d9bc..4b811ef5 100644 --- a/plugins/modules/content_template.py +++ b/plugins/modules/content_template.py @@ -37,6 +37,7 @@ description: - The name of the VM to be used to create template. type: str + required: only if state is set to present host: description: - Host onto which the virtual machine template should be placed. @@ -205,7 +206,7 @@ def main(): argument_spec.update( template=dict(type='str', required=True), library=dict(type='str', required=True), - vm_name=dict(type='str'), + vm_name=dict(type='str', required=(argument_spec['state'] == 'present')), host=dict(type='str'), cluster=dict(type='str'), resource_pool=dict(type='str'),