diff --git a/changelogs/fragments/49938-vcenter_folder-restrict_folder.yml b/changelogs/fragments/49938-vcenter_folder-restrict_folder.yml new file mode 100644 index 00000000000..11300ba923d --- /dev/null +++ b/changelogs/fragments/49938-vcenter_folder-restrict_folder.yml @@ -0,0 +1,2 @@ +minor_changes: +- Restrict vcenter_folder to vCenter only, since folder creation api is not supported on ESXi hostsystem (https://github.com/ansible/ansible/issues/49938). diff --git a/lib/ansible/modules/cloud/vmware/vcenter_folder.py b/lib/ansible/modules/cloud/vmware/vcenter_folder.py index ea738ec0e75..eef1a1b2353 100644 --- a/lib/ansible/modules/cloud/vmware/vcenter_folder.py +++ b/lib/ansible/modules/cloud/vmware/vcenter_folder.py @@ -19,6 +19,7 @@ module: vcenter_folder short_description: Manage folders on given datacenter description: - This module can be used to create, delete, move and rename folder on then given datacenter. +- This module is only supported for vCenter. version_added: '2.5' author: - Abhijeet Kasurde (@Akasurde) @@ -330,6 +331,9 @@ def main(): module.fail_json(msg="Failed to manage folder as folder_name can only contain 80 characters.") vcenter_folder_mgr = VmwareFolderManager(module) + if not vcenter_folder_mgr.is_vcenter(): + module.fail_json(msg="Module vcenter_folder is meant for vCenter, hostname %s " + "is not vCenter server." % module.params.get('hostname')) vcenter_folder_mgr.ensure()