From b89a1264184311fe15770d4f1327ab5cec683421 Mon Sep 17 00:00:00 2001 From: Mike Morency Date: Tue, 8 Oct 2024 11:34:51 -0400 Subject: [PATCH] move datacenter out of auth vars for manage_folder --- .../fragments/106-fix-variable-docs-in-manage-folder.yml | 4 ++++ roles/manage_folder/README.md | 7 ++++--- roles/manage_folder/tasks/main.yml | 7 ++++++- .../targets/vmware_ops_manage_folder_test/tasks/main.yml | 2 +- .../targets/vmware_ops_manage_folder_test/vars.yml | 2 +- .../targets/vmware_ops_manage_folder_test/vars/main.yml | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/106-fix-variable-docs-in-manage-folder.yml diff --git a/changelogs/fragments/106-fix-variable-docs-in-manage-folder.yml b/changelogs/fragments/106-fix-variable-docs-in-manage-folder.yml new file mode 100644 index 00000000..5628ab96 --- /dev/null +++ b/changelogs/fragments/106-fix-variable-docs-in-manage-folder.yml @@ -0,0 +1,4 @@ +--- +bugfixes: + - manage_folder - Fixed the location of variables in docs to match other roles + - manage_folder - Updated datacenter var name to match other roles while keeping backwards compat diff --git a/roles/manage_folder/README.md b/roles/manage_folder/README.md index 342b0807..01ec1e7a 100644 --- a/roles/manage_folder/README.md +++ b/roles/manage_folder/README.md @@ -20,13 +20,14 @@ N/A - **manage_folder_validate_certs** - Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted. -- **manage_folder_datacenter_name**: - - The name of the datacenter in vSphere vCenter which contains the cluster to configure. - - **manage_folder_port**: - str or int, The port used to authenticate to the vSphere vCenter that contains the cluster to configure. ### Other +- **manage_folder_datacenter**: + - The name of the datacenter in vSphere vCenter which contains the cluster to configure. + - Aliases: [manage_folder_datacenter] + - **manage_folder_folder_name**: - str, required, The name of folder to manage. It can be a single name like `foo` or a path like `foo/bar/buzz`. diff --git a/roles/manage_folder/tasks/main.yml b/roles/manage_folder/tasks/main.yml index df75320b..8c6d6250 100644 --- a/roles/manage_folder/tasks/main.yml +++ b/roles/manage_folder/tasks/main.yml @@ -2,7 +2,7 @@ - name: Check Mandatory Variables Are Defined ansible.builtin.assert: that: - - manage_folder_datacenter_name is defined + - manage_folder_datacenter is defined or manage_folder_datacenter_name is defined - manage_folder_folder_name is defined and ((manage_folder_folder_name | length) > 0) - manage_folder_hostname is defined - manage_folder_username is defined @@ -15,6 +15,11 @@ msg: Folder name should not be absolute. It should be relative to // when: manage_folder_folder_name[0] == '/' +- name: Map Variable Aliases to Documented Names + ansible.builtin.set_fact: + manage_folder_datacenter: "{{ manage_folder_datacenter_name }}" + when: manage_folder_datacenter_name is defined + - name: Manage Full Folder Path when: manage_folder_parse_name_as_path block: diff --git a/tests/integration/targets/vmware_ops_manage_folder_test/tasks/main.yml b/tests/integration/targets/vmware_ops_manage_folder_test/tasks/main.yml index 8321f048..6ec45dfd 100644 --- a/tests/integration/targets/vmware_ops_manage_folder_test/tasks/main.yml +++ b/tests/integration/targets/vmware_ops_manage_folder_test/tasks/main.yml @@ -41,7 +41,7 @@ hostname: "{{ manage_folder_hostname }}" username: "{{ manage_folder_username }}" password: "{{ manage_folder_password }}" - datacenter: "{{ manage_folder_datacenter_name }}" + datacenter: "{{ manage_folder_datacenter }}" port: "{{ manage_folder_port }}" validate_certs: false delegate_to: localhost diff --git a/tests/integration/targets/vmware_ops_manage_folder_test/vars.yml b/tests/integration/targets/vmware_ops_manage_folder_test/vars.yml index 8aa1085b..9bf337be 100644 --- a/tests/integration/targets/vmware_ops_manage_folder_test/vars.yml +++ b/tests/integration/targets/vmware_ops_manage_folder_test/vars.yml @@ -7,6 +7,6 @@ manage_folder_username: "test" manage_folder_password: "test" manage_folder_validate_certs: false manage_folder_port: "8989" -manage_folder_datacenter_name: DC0 +manage_folder_datacenter: DC0 folder_types: - host diff --git a/tests/integration/targets/vmware_ops_manage_folder_test/vars/main.yml b/tests/integration/targets/vmware_ops_manage_folder_test/vars/main.yml index d12fc57c..60e471a6 100644 --- a/tests/integration/targets/vmware_ops_manage_folder_test/vars/main.yml +++ b/tests/integration/targets/vmware_ops_manage_folder_test/vars/main.yml @@ -7,7 +7,7 @@ manage_folder_username: "{{ vcenter_username }}" manage_folder_password: "{{ vcenter_password }}" manage_folder_validate_certs: false manage_folder_port: "{{ vcenter_port }}" -manage_folder_datacenter_name: "{{ vcenter_datacenter }}" +manage_folder_datacenter: "{{ vcenter_datacenter }}" folder_types: - host - vm