esxi/datastore-mappings¶
Defines any additional command line options to pass to ansible for playbooks
This data structure defines a set of Datastores to create in a single set of mappings. Multiple datastore types can be created in one task run.
This Param data structure defines the configurations of each of the described
datastores to be created. In addition, you must add the Param
esxi/datastore-memberships
to each vSphere ESXi node with the name of the
datastores to add to that node.
The datastore mappings are performed via the Context system, which means the actions are implemented as an API call to the ESXi host directly or via the vCenter instance that manages the node.
Required datastore configuration values are as follows:
name
= the name of the datastore to createtype
= eitherget_first_available
,nfs
,nfs41
,cifs
,vmfs
, orlocal
Note
The get_first_available
simulates the orignal datastore create
pattern in the mappings data structure. Provided only for legacy use.
The following additional values can be specified, and are type dependent (either nfs/nfs41, vmfs, or local type):
disk
= Canonical name of disk (VMFS only)force
= Ignore DuplicateName error if datastore is already mounted on a host (false
by default)host
= Host systemmode
= Access mode for the mount point (readOnly|readWrite)path
= Local directory path for the datastore (local only)remote-host
= Remote hostname of the NAS datastore (NFS/CIFS)remote-path
= Remote path of the NFS mount point (NFS/CIFS)username
= Username to use when connecting (CIFS only)password
= Password to use when connecting (CIFS only)version
= VMFS major versiontool
= empty, set toparted
(*), or set togovc
Note
If set to parted
, the data mapping will only be processed by the
Task esxi-datastore-create
and will not be processed by govc-datastore-manage
.
Digital Rebar Golang templating constructs can be used in the datastructures and will be filled in when the template is evaluted. This is useful for Datastores that are created bound to specific Node information. A further example; creating a local datastore with the ESXi node name in the name construct. When these are rolled up under vCenter management, it allows datastore uniqueness.
The general data structure follows the below pattern:
The Datastore Reference is different than the actual datastore name to create, as in many cases, the Datastore Name may be based on the specific ESXi node name or other unique reference for that node. This allows for golang templatization structures to dynamically reference the Datastore name value, but use a generic Reference for the configuration structure.
Example in YAML:
yaml
esxi/datastore-mappings:
nfs1-datastore:
name: "nfs-1-{{.Machine.Name}}"
type: "nfs"
mode: "readWrite"
remote-host: "nfs1.example.com"
remote-path: "/hosts/{{ .Machine.Name }}"
vmfs-datastore:
name: "vmfsDatastore"
type: "vmfs"
disk: "mpx.vmhba0:C0:T0:L0"
local1-datastore:
name: "localDatastore"
type: "local"
path: "/var/datastore"
Example in JSON:
{
"nfs1-datastore": {
"name": "nfs-1-{{.Machine.Name}}",
"type": "nfs",
"mode": "readWrite",
"remote-host": "nfs1.example.com",
"remote-path": "/hosts/{{ .Machine.Name }}"
},
"vmfs-datastore": {
"name": "vmfsDatastore"
"type": "vmfs"
"disk": "mpx.vmhba0:C0:T0:L0"
},
"local1-datastore": {
"name": "localDatastore"
"type": "local"
"path": "/var/datastore"
}
}
In the above examples, three separate Datastores will be created on the systems
based on their membership mappings. The membership mappings are managed by adding
the Param esxi/datastore-memberships
with a list of the datastore references
to be added to that machine.
For example, on the machine named esxi-01
, we add the param with the following
values:
In this scenario, the machine will be added with the NFS datastore named nfs-1-esxi-01
which maps to the share nfs1.example.com:/hosts/esxi-01
. This happens because the
Params are expanded to the Machine name, mapping a custom NFS share under the common
reference name nfs1-datastore.
The second datastore (local1-datastore) is mapped on the machine as well. However, the VMFS datastore is not mapped on this machine.