414 lines
18 KiB
ReStructuredText
414 lines
18 KiB
ReStructuredText
.. _community.vmware.vcenter_folder_module:
|
|
|
|
|
|
*******************************
|
|
community.vmware.vcenter_folder
|
|
*******************************
|
|
|
|
**Manage folders on given datacenter**
|
|
|
|
|
|
|
|
.. contents::
|
|
:local:
|
|
:depth: 1
|
|
|
|
|
|
Synopsis
|
|
--------
|
|
- This module can be used to create, delete, move and rename folder on then given datacenter.
|
|
- This module is only supported for vCenter.
|
|
|
|
|
|
|
|
Requirements
|
|
------------
|
|
The below requirements are needed on the host that executes this module.
|
|
|
|
- python >= 2.6
|
|
- PyVmomi
|
|
|
|
|
|
Parameters
|
|
----------
|
|
|
|
.. raw:: html
|
|
|
|
<table border=0 cellpadding=0 class="documentation-table">
|
|
<tr>
|
|
<th colspan="1">Parameter</th>
|
|
<th>Choices/<font color="blue">Defaults</font></th>
|
|
<th width="100%">Comments</th>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>datacenter</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
/ <span style="color: red">required</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Name of the datacenter.</div>
|
|
<div style="font-size: small; color: darkgreen"><br/>aliases: datacenter_name</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>folder_name</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
/ <span style="color: red">required</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Name of folder to be managed.</div>
|
|
<div>This is case sensitive parameter.</div>
|
|
<div>Folder name should be under 80 characters. This is a VMware restriction.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>folder_type</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
<li>datastore</li>
|
|
<li>host</li>
|
|
<li>network</li>
|
|
<li><div style="color: blue"><b>vm</b> ←</div></li>
|
|
</ul>
|
|
</td>
|
|
<td>
|
|
<div>This is type of folder.</div>
|
|
<div>If set to <code>vm</code>, then 'VM and Template Folder' is created under datacenter.</div>
|
|
<div>If set to <code>host</code>, then 'Host and Cluster Folder' is created under datacenter.</div>
|
|
<div>If set to <code>datastore</code>, then 'Storage Folder' is created under datacenter.</div>
|
|
<div>If set to <code>network</code>, then 'Network Folder' is created under datacenter.</div>
|
|
<div>This parameter is required, if <code>state</code> is set to <code>present</code> and parent_folder is absent.</div>
|
|
<div>This option is ignored, if <code>parent_folder</code> is set.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>hostname</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>The hostname or IP address of the vSphere vCenter or ESXi server.</div>
|
|
<div>If the value is not specified in the task, the value of environment variable <code>VMWARE_HOST</code> will be used instead.</div>
|
|
<div>Environment variable support added in Ansible 2.6.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>parent_folder</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Name of the parent folder under which new folder needs to be created.</div>
|
|
<div>This is case sensitive parameter.</div>
|
|
<div>If user wants to create a folder under '/DC0/vm/vm_folder', this value will be 'vm_folder'.</div>
|
|
<div>If user wants to create a folder under '/DC0/vm/folder1/folder2', this value will be 'folder1/folder2'.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>password</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>The password of the vSphere vCenter or ESXi server.</div>
|
|
<div>If the value is not specified in the task, the value of environment variable <code>VMWARE_PASSWORD</code> will be used instead.</div>
|
|
<div>Environment variable support added in Ansible 2.6.</div>
|
|
<div style="font-size: small; color: darkgreen"><br/>aliases: pass, pwd</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>port</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">integer</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<b>Default:</b><br/><div style="color: blue">443</div>
|
|
</td>
|
|
<td>
|
|
<div>The port number of the vSphere vCenter or ESXi server.</div>
|
|
<div>If the value is not specified in the task, the value of environment variable <code>VMWARE_PORT</code> will be used instead.</div>
|
|
<div>Environment variable support added in Ansible 2.6.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>proxy_host</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Address of a proxy that will receive all HTTPS requests and relay them.</div>
|
|
<div>The format is a hostname or a IP.</div>
|
|
<div>If the value is not specified in the task, the value of environment variable <code>VMWARE_PROXY_HOST</code> will be used instead.</div>
|
|
<div>This feature depends on a version of pyvmomi greater than v6.7.1.2018.12</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>proxy_port</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">integer</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Port of the HTTP proxy that will receive all HTTPS requests and relay them.</div>
|
|
<div>If the value is not specified in the task, the value of environment variable <code>VMWARE_PROXY_PORT</code> will be used instead.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>state</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
<li><div style="color: blue"><b>present</b> ←</div></li>
|
|
<li>absent</li>
|
|
</ul>
|
|
</td>
|
|
<td>
|
|
<div>State of folder.</div>
|
|
<div>If set to <code>present</code> without parent folder parameter, then folder with <code>folder_type</code> is created.</div>
|
|
<div>If set to <code>present</code> with parent folder parameter, then folder in created under parent folder. <code>folder_type</code> is ignored.</div>
|
|
<div>If set to <code>absent</code>, then folder is unregistered and destroyed.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>username</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>The username of the vSphere vCenter or ESXi server.</div>
|
|
<div>If the value is not specified in the task, the value of environment variable <code>VMWARE_USER</code> will be used instead.</div>
|
|
<div>Environment variable support added in Ansible 2.6.</div>
|
|
<div style="font-size: small; color: darkgreen"><br/>aliases: admin, user</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>validate_certs</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">boolean</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
<li>no</li>
|
|
<li><div style="color: blue"><b>yes</b> ←</div></li>
|
|
</ul>
|
|
</td>
|
|
<td>
|
|
<div>Allows connection when SSL certificates are not valid. Set to <code>false</code> when certificates are not trusted.</div>
|
|
<div>If the value is not specified in the task, the value of environment variable <code>VMWARE_VALIDATE_CERTS</code> will be used instead.</div>
|
|
<div>Environment variable support added in Ansible 2.6.</div>
|
|
<div>If set to <code>true</code>, please make sure Python >= 2.7.9 is installed on the given machine.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br/>
|
|
|
|
|
|
Notes
|
|
-----
|
|
|
|
.. note::
|
|
- Tested on vSphere 6.5
|
|
- All modules requires API write access and hence is not supported on a free ESXi license.
|
|
|
|
|
|
|
|
Examples
|
|
--------
|
|
|
|
.. code-block:: yaml
|
|
|
|
- name: Create a VM folder on given datacenter
|
|
community.vmware.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
|
|
|
|
- name: Create a datastore folder on given datacenter
|
|
community.vmware.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
|
|
|
|
- name: Create a sub folder under VM folder on given datacenter
|
|
community.vmware.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
|
|
|
|
- name: Delete a VM folder on given datacenter
|
|
community.vmware.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
|
|
|
|
|
|
|
|
Return Values
|
|
-------------
|
|
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
|
|
|
.. raw:: html
|
|
|
|
<table border=0 cellpadding=0 class="documentation-table">
|
|
<tr>
|
|
<th colspan="2">Key</th>
|
|
<th>Returned</th>
|
|
<th width="100%">Description</th>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2">
|
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
<b>result</b>
|
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">complex</span>
|
|
</div>
|
|
</td>
|
|
<td>On success</td>
|
|
<td>
|
|
<div>The detail about the new folder</div>
|
|
<br/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="elbow-placeholder"> </td>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
<b>msg</b>
|
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
<td>
|
|
<div>string stating about result</div>
|
|
<br/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="elbow-placeholder"> </td>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
<b>path</b>
|
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
<td>
|
|
<div>the full path of the new folder</div>
|
|
<br/>
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
<br/><br/>
|
|
|
|
|
|
Status
|
|
------
|
|
|
|
|
|
Authors
|
|
~~~~~~~
|
|
|
|
- Abhijeet Kasurde (@Akasurde)
|
|
- Christian Kotte (@ckotte) <christian.kotte@gmx.de>
|
|
- Jan Meerkamp (@meerkampdvv)
|