The vmware_guest_file_operation module

This module was introduced in Ansible 2.5; it allows you to add and fetch files from a VM without the need for the VM to be on a network. It also allows you to create folders within the VM. The following example creates a directory within the VM:

- name: create a directory on a vm
vmware_guest_file_operation:
hostname: "{{ vsphere_host }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: "no"
datacenter: "my-datacenter"
vm_id: "yet_another_example_vm"
vm_username: "root"
vm_password: "supersecretpassword"
directory:
path: "/tmp/imported/files"
operation: "create"
recurse: "yes"
delegate_to: localhost

The following example copies a file called config.zip from our Ansible host to the directory created previously:

- name: copy file to vm
vmware_guest_file_operation:
hostname: "{{ vsphere_host }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: "no"
datacenter: "my-datacenter"
vm_id: "yet_another_example_vm"
vm_username: "root"
vm_password: "supersecretpassword"
copy:
src: "files/config.zip"
dest: "/tmp/imported/files/config.zip"
overwrite: "False"
delegate_to: localhost
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.205.123