community.vmware.vmware_host_datastore – Manage a datastore on ESXi host¶
Note
This plugin is part of the community.vmware collection (version 1.9.0).
To install it use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vmware_host_datastore
.
Synopsis¶
This module can be used to mount/umount datastore on ESXi host.
This module only supports NFS (NFS v3 or NFS v4.1) and VMFS datastores.
For VMFS datastore, available device must already be connected on ESXi host.
All parameters and VMware object names are case sensitive.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.6
PyVmomi
Parameters¶
Notes¶
Note
Tested on vSphere 6.0, 6.5 and ESXi 6.7
NFS v4.1 tested on vSphere 6.5
Kerberos authentication with NFS v4.1 isn’t implemented
Examples¶
- name: Mount VMFS datastores to ESXi
community.vmware.vmware_host_datastore:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datastore_name: '{{ item.name }}'
datastore_type: '{{ item.type }}'
vmfs_device_name: 'naa.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
vmfs_version: 6
esxi_hostname: '{{ inventory_hostname }}'
state: present
delegate_to: localhost
- name: Mount NFS datastores to ESXi
community.vmware.vmware_host_datastore:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datastore_name: '{{ item.name }}'
datastore_type: '{{ item.type }}'
nfs_server: '{{ item.server }}'
nfs_path: '{{ item.path }}'
nfs_ro: no
esxi_hostname: '{{ inventory_hostname }}'
state: present
delegate_to: localhost
loop:
- { 'name': 'NasDS_vol01', 'server': 'nas01', 'path': '/mnt/vol01', 'type': 'nfs'}
- { 'name': 'NasDS_vol02', 'server': 'nas01', 'path': '/mnt/vol02', 'type': 'nfs'}
- name: Mount NFS v4.1 datastores to ESXi
community.vmware.vmware_host_datastore:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datastore_name: '{{ item.name }}'
datastore_type: '{{ item.type }}'
nfs_server: '{{ item.server }}'
nfs_path: '{{ item.path }}'
nfs_ro: no
esxi_hostname: '{{ inventory_hostname }}'
state: present
delegate_to: localhost
loop:
- { 'name': 'NasDS_vol03', 'server': 'nas01,nas02', 'path': '/mnt/vol01', 'type': 'nfs41'}
- { 'name': 'NasDS_vol04', 'server': 'nas01,nas02', 'path': '/mnt/vol02', 'type': 'nfs41'}
- name: Remove/Umount Datastores from a ESXi
community.vmware.vmware_host_datastore:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
datastore_name: NasDS_vol01
state: absent
delegate_to: localhost
Authors¶
Ludovic Rivallain (@lrivallain) <ludovic.rivallain@gmail.com>
Christian Kotte (@ckotte) <christian.kotte@gmx.de>