community.vmware.vmware_host_datastore (4.2.0) — module

Manage a datastore on ESXi host

Authors: Ludovic Rivallain (@lrivallain) <ludovic.rivallain@gmail.com>, Christian Kotte (@ckotte) <christian.kotte@gmx.de>, Eugenio Grosso (@genegr) <eugenio.grosso@purestorage.com>

Install collection

Install with ansible-galaxy collection install community.vmware:==4.2.0


Add to requirements.yml

  collections:
    - name: community.vmware
      version: 4.2.0

Description

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.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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: false
      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'}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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: false
      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'}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Mount vVols datastore to ESXi
  community.vmware.vmware_host_datastore:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_username }}'
      password: '{{ vcenter_password }}'
      datastore_name: myvvolds
      datastore_type: vvol
      vasa_provider: pure-X90a
      esxi_hostname: esxi-1
      state: absent
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Mount unresolved VMFS datastores to ESXi
  community.vmware.vmware_host_datastore:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_username }}'
      password: '{{ vcenter_password }}'
      datastore_name: mydatastore01
      vmfs_device_name: 'naa.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
      vmfs_version: 6
      esxi_hostname:  esxi01
      resignature: true
      state: present
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

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 E(VMWARE_PORT)
      will be used instead.
    type: int

state:
    choices:
    - present
    - absent
    default: present
    description:
    - 'present: Mount datastore on host if datastore is absent else do nothing.'
    - 'absent: Umount datastore if datastore is present else do nothing.'
    type: str

nfs_ro:
    default: false
    description:
    - ReadOnly or ReadWrite mount.
    - Unused if datastore type is not set to O(datastore_type=nfs) / O(datastore_type=nfs41)
      and not O(state=present).
    type: bool

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 E(VMWARE_HOST)
      will be used instead.
    type: str

nfs_path:
    description:
    - Resource path on NFS host.
    - Required if O(datastore_type=nfs) / O(datastore_type=nfs41) and O(state=present),
      else unused.
    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 E(VMWARE_PASSWORD)
      will be used instead.
    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 E(VMWARE_USER)
      will be used instead.
    type: str

nfs_server:
    description:
    - NFS host serving nfs datastore.
    - Required if O(datastore_type=nfs) / O(datastore_type=nfs41) and O(state=present),
      else unused.
    - Two or more servers can be defined if O(datastore_type=nfs41)
    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 E(VMWARE_PROXY_HOST)
      will be used instead.
    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 E(VMWARE_PROXY_PORT)
      will be used instead.
    required: false
    type: int

auto_expand:
    default: true
    description:
    - Expand a datastore capacity to full if it has free capacity.
    - This parameter can't be extend using another datastore.
    - Can be used to expand a datastore capacity after increasing LUN volume.
    type: bool

resignature:
    default: false
    description:
    - Allows forcing resignature of unresolved VMFS datastore that already exists on the
      specified disk device.
    - Unused if not O(datastore_type=vmfs) and not O(state=present).
    type: bool
    version_added: 3.9.0
    version_added_collection: community.vmware

vmfs_version:
    description:
    - VMFS version to use for datastore creation.
    - Unused if not O(datastore_type=vmfs) and not O(state=present).
    type: int

esxi_hostname:
    description:
    - ESXi hostname to manage the datastore.
    - Required when used with a vcenter
    required: false
    type: str

vasa_provider:
    description:
    - hostname or ipaddress of the VASA provider to use for vVols provisioning
    required: false
    type: str
    version_added: 3.9.0
    version_added_collection: community.vmware

datastore_name:
    description:
    - Name of the datastore to add/remove.
    required: true
    type: str

datastore_type:
    choices:
    - nfs
    - nfs41
    - vmfs
    - vvol
    description:
    - Type of the datastore to configure (nfs/nfs41/vmfs/vvol).
    type: str

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid. Set to V(false) when certificates
      are not trusted.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_VALIDATE_CERTS)
      will be used instead.
    type: bool

vmfs_device_name:
    description:
    - Name of the device to be used as VMFS datastore.
    - Required for VMFS datastore type and O(state=present), else unused.
    type: str