ansible / ansible.builtin / v2.9.3 / module / vsphere_file Manage files on a vCenter datastore | "added in version" 2.8 of ansible.builtin" Authors: Dag Wieers (@dagwieers) preview | supported by communityansible.builtin.vsphere_file (v2.9.3) — module
pip
Install with pip install ansible==2.9.3
Manage files on a vCenter datastore.
- name: Create an empty file on a datastore 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 vsphere_file: host: '{{ vhost }}' username: '{{ vuser }}' password: '{{ vpass }}' src: /other/local/file datacenter: DC2 Someplace datastore: datastore2 path: other/remote/file state: directory delegate_to: localhost
- name: Query a file on a datastore 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 vsphere_file: host: '{{ vhost }}' username: '{{ vuser }}' password: '{{ vpass }}' datacenter: DC2 Someplace datastore: datastore2 path: other/remote/file state: absent delegate_to: localhost
host: aliases: - hostname description: - The vCenter server on which the datastore is available. required: true type: str path: aliases: - dest description: - The file or directory on the datastore on the vCenter server. required: true type: str state: choices: - absent - directory - file - touch default: file description: - The state of or the action on the provided path. - If C(absent), the file will be removed. - If C(directory), the directory will be created. - If C(file), more information of the (existing) file will be returned. - If C(touch), an empty file will be created if the path does not exist. type: str timeout: default: 10 description: - The timeout in seconds for the upload to the datastore. type: int password: description: - The password to authenticate on the vCenter server. required: true type: str username: description: - The user name to authenticate on the vCenter server. required: true type: str datastore: description: - The datastore on the vCenter server to push files to. required: true type: str datacenter: description: - The datacenter on the vCenter server that holds the datastore. required: true type: str validate_certs: default: true description: - If C(no), SSL certificates will not be validated. This should only be set to C(no) when no other option exists. type: bool