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

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.