community.vmware.vsphere_file module – Manage files on a vCenter datastore
Note
This module is part of the community.vmware collection (version 1.18.2).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vsphere_file
.
Parameters
Parameter |
Comments |
---|---|
The datacenter on the vCenter server that holds the datastore. |
|
The datastore on the vCenter server to push files to. |
|
The vCenter server on which the datastore is available. |
|
The password to authenticate on the vCenter server. |
|
The file or directory on the datastore on the vCenter server. |
|
The state of or the action on the provided path. If If If If Choices:
|
|
The timeout in seconds for the upload to the datastore. Default: 10 |
|
The user name to authenticate on the vCenter server. |
|
If Choices:
|
Examples
- name: Create an empty file on a datastore
community.vmware.vsphere_file:
host: '{{ vhost }}'
username: '{{ vuser }}'
password: '{{ vpass }}'
datacenter: DC1 Someplace
datastore: datastore1
path: some/remote/file
state: touch
delegate_to: localhost
- name: Create a directory on a datastore
community.vmware.vsphere_file:
host: '{{ vhost }}'
username: '{{ vuser }}'
password: '{{ vpass }}'
datacenter: DC2 Someplace
datastore: datastore2
path: other/remote/file
state: directory
delegate_to: localhost
- name: Query a file on a datastore
community.vmware.vsphere_file:
host: '{{ vhost }}'
username: '{{ vuser }}'
password: '{{ vpass }}'
datacenter: DC1 Someplace
datastore: datastore1
path: some/remote/file
state: file
delegate_to: localhost
ignore_errors: true
- name: Delete a file on a datastore
community.vmware.vsphere_file:
host: '{{ vhost }}'
username: '{{ vuser }}'
password: '{{ vpass }}'
datacenter: DC2 Someplace
datastore: datastore2
path: other/remote/file
state: absent
delegate_to: localhost
Authors
Dag Wieers (@dagwieers)