community.vmware.vsphere_file – Manage files on a vCenter datastore

Note

This plugin is part of the community.vmware collection.

To install it use: ansible-galaxy collection install community.vmware.

To use it in a playbook, specify: community.vmware.vsphere_file.

Synopsis

  • Manage files on a vCenter datastore.

Parameters

Parameter Choices/Defaults Comments
datacenter
string / required
The datacenter on the vCenter server that holds the datastore.
datastore
string / required
The datastore on the vCenter server to push files to.
host
string / required
The vCenter server on which the datastore is available.

aliases: hostname
password
string / required
The password to authenticate on the vCenter server.
path
string / required
The file or directory on the datastore on the vCenter server.

aliases: dest
state
string
    Choices:
  • absent
  • directory
  • file ←
  • touch
The state of or the action on the provided path.
If absent, the file will be removed.
If directory, the directory will be created.
If file, more information of the (existing) file will be returned.
If touch, an empty file will be created if the path does not exist.
timeout
integer
Default:
10
The timeout in seconds for the upload to the datastore.
username
string / required
The user name to authenticate on the vCenter server.
validate_certs
boolean
    Choices:
  • no
  • yes ←
If no, SSL certificates will not be validated. This should only be set to no when no other option exists.

Notes

Note

  • The vSphere folder API does not allow to remove directory objects.

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: touch
  delegate_to: localhost
  ignore_errors: yes

- 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)