ansible.builtin.vmware_host_datastore (v2.6.0) — module

Manage a datastore on ESXi host

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

Authors: Ludovic Rivallain (@lrivallain) <ludovic.rivallain@gmail.com>

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.6.0

Description

This module can be used to mount/umount datastore on ESXi host.

This module only support NFS/VMFS type of datastores.

For VMFS datastore, available device must already be connected on ESXi host.

All parameters and VMware object names are case sensitive.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Mount VMFS datastores to ESXi
  vmware_host_datastore:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_user }}'
      password: '{{ vcenter_pass }}'
      datacenter_name: '{{ datacenter }}'
      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
  vmware_host_datastore:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_user }}'
      password: '{{ vcenter_pass }}'
      datacenter_name: '{{ datacenter }}'
      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
  with_items:
      - { '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: Remove/Umount Datastores from ESXi
  vmware_host_datastore:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_user }}'
      password: '{{ vcenter_pass }}'
      datacenter_name: '{{ datacenter }}'
      datastore_name: NasDS_vol01
      esxi_hostname: '{{ inventory_hostname }}'
      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 C(VMWARE_PORT)
      will be used instead.
    - Environment variable support added in Ansible 2.6.
    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.'

nfs_ro:
    default: false
    description:
    - ReadOnly or ReadWrite mount.
    - Unused if datastore type is not set to C(nfs) and state is not set to C(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 C(VMWARE_HOST)
      will be used instead.
    - Environment variable support added in Ansible 2.6.
    type: str

nfs_path:
    description:
    - Resource path on NFS host.
    - Required if datastore type is set to C(nfs) and state is set to C(present), else
      unused.

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

nfs_server:
    description:
    - NFS host serving nfs datastore.
    - Required if datastore type is set to C(nfs) and state is set to C(present), else
      unused.

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

vmfs_version:
    description:
    - VMFS version to use for datastore creation.
    - Unused if datastore type is not set to C(vmfs) and state is not set to C(present).

esxi_hostname:
    description:
    - ESXi hostname to manage the datastore.
    required: true

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

datastore_type:
    choices:
    - nfs
    - vmfs
    description:
    - Type of the datastore to configure (nfs/vmfs).
    required: true

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(yes), please make sure Python >= 2.7.9 is installed on the given machine.
    type: bool

datacenter_name:
    description:
    - Name of the datacenter to add the datastore.
    required: true

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