ansible.builtin.vcenter_folder (v2.9.24) — module

Manage folders on given datacenter

| "added in version" 2.5 of ansible.builtin"

Authors: Abhijeet Kasurde (@Akasurde), Christian Kotte (@ckotte) <christian.kotte@gmx.de>

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.9.24

Description

This module can be used to create, delete, move and rename folder on then given datacenter.

This module is only supported for vCenter.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a VM folder on given datacenter
  vcenter_folder:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter_name: datacenter_name
    folder_name: sample_vm_folder
    folder_type: vm
    state: present
  register: vm_folder_creation_result
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a datastore folder on given datacenter
  vcenter_folder:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter_name: datacenter_name
    folder_name: sample_datastore_folder
    folder_type: datastore
    state: present
  register: datastore_folder_creation_result
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a sub folder under VM folder on given datacenter
  vcenter_folder:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter_name: datacenter_name
    folder_name: sample_sub_folder
    parent_folder: vm_folder
    state: present
  register: sub_folder_creation_result
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a VM folder on given datacenter
  vcenter_folder:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter_name: datacenter_name
    folder_name: sample_vm_folder
    folder_type: vm
    state: absent
  register: vm_folder_deletion_result
  delegate_to: localhost

Inputs

    
port:
    default: 443
    description:
    - The port number of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable C(VMWARE_PORT)
      will be used instead.
    - Environment variable support added in Ansible 2.6.
    type: int

state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of folder.
    - If set to C(present) without parent folder parameter, then folder with C(folder_type)
      is created.
    - If set to C(present) with parent folder parameter,  then folder in created under
      parent folder. C(folder_type) is ignored.
    - If set to C(absent), then folder is unregistered and destroyed.
    type: str

hostname:
    description:
    - The hostname or IP address of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable C(VMWARE_HOST)
      will be used instead.
    - Environment variable support added in Ansible 2.6.
    type: str

password:
    aliases:
    - pass
    - pwd
    description:
    - The password of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable C(VMWARE_PASSWORD)
      will be used instead.
    - Environment variable support added in Ansible 2.6.
    type: str

username:
    aliases:
    - admin
    - user
    description:
    - The username of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable C(VMWARE_USER)
      will be used instead.
    - Environment variable support added in Ansible 2.6.
    type: str

datacenter:
    aliases:
    - datacenter_name
    description:
    - Name of the datacenter.
    required: true
    type: str

proxy_host:
    description:
    - Address of a proxy that will receive all HTTPS requests and relay them.
    - The format is a hostname or a IP.
    - If the value is not specified in the task, the value of environment variable C(VMWARE_PROXY_HOST)
      will be used instead.
    - This feature depends on a version of pyvmomi greater than v6.7.1.2018.12
    required: false
    type: str

proxy_port:
    description:
    - Port of the HTTP proxy that will receive all HTTPS requests and relay them.
    - If the value is not specified in the task, the value of environment variable C(VMWARE_PROXY_PORT)
      will be used instead.
    required: false
    type: int

folder_name:
    description:
    - Name of folder to be managed.
    - This is case sensitive parameter.
    - Folder name should be under 80 characters. This is a VMware restriction.
    required: true
    type: str

folder_type:
    choices:
    - datastore
    - host
    - network
    - vm
    default: vm
    description:
    - This is type of folder.
    - If set to C(vm), then 'VM and Template Folder' is created under datacenter.
    - If set to C(host), then 'Host and Cluster Folder' is created under datacenter.
    - If set to C(datastore), then 'Storage Folder' is created under datacenter.
    - If set to C(network), then 'Network Folder' is created under datacenter.
    - This parameter is required, if C(state) is set to C(present) and parent_folder is
      absent.
    - This option is ignored, if C(parent_folder) is set.
    required: false
    type: str

parent_folder:
    description:
    - Name of the parent folder under which new folder needs to be created.
    - This is case sensitive parameter.
    - Please specify unique folder name as there is no way to detect duplicate names.
    - If user wants to create a folder under '/DC0/vm/vm_folder', this value will be 'vm_folder'.
    required: false
    type: str

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid. Set to C(false) when certificates
      are not trusted.
    - If the value is not specified in the task, the value of environment variable C(VMWARE_VALIDATE_CERTS)
      will be used instead.
    - Environment variable support added in Ansible 2.6.
    - If set to C(true), please make sure Python >= 2.7.9 is installed on the given machine.
    type: bool

Outputs

result:
  contains:
    msg:
      description: string stating about result
      type: str
    path:
      description: the full path of the new folder
      type: str
  description: The detail about the new folder
  returned: On success
  type: complex