community.vmware.vmware_guest_file_operation – Files operation in a VMware guest operating system without network¶
Note
This plugin is part of the community.vmware collection (version 1.9.0).
To install it use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vmware_guest_file_operation
.
Synopsis¶
Module to copy a file to a VM, fetch a file from a VM and create or delete a directory in the guest OS.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.6
PyVmomi
requests
Parameters¶
Notes¶
Note
Tested on vSphere 6
Only the first match against vm_id is used, even if there are multiple matches
Examples¶
- name: Create directory inside a vm
community.vmware.vmware_guest_file_operation:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
vm_id: "{{ guest_name }}"
vm_username: "{{ guest_username }}"
vm_password: "{{ guest_userpassword }}"
directory:
path: "/test"
operation: create
recurse: no
delegate_to: localhost
- name: copy file to vm
community.vmware.vmware_guest_file_operation:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
vm_id: "{{ guest_name }}"
vm_username: "{{ guest_username }}"
vm_password: "{{ guest_userpassword }}"
copy:
src: "files/test.zip"
dest: "/root/test.zip"
overwrite: False
delegate_to: localhost
- name: fetch file from vm
community.vmware.vmware_guest_file_operation:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
vm_id: "{{ guest_name }}"
vm_username: "{{ guest_username }}"
vm_password: "{{ guest_userpassword }}"
fetch:
src: "/root/test.zip"
dest: "files/test.zip"
delegate_to: localhost
Authors¶
Stéphane Travassac (@stravassac)