vmware.vmware_rest.vcenter_vm_guest_filesystem_directories module – Manage directories in the guest operating system of a virtual machine.
Note
This module is part of the vmware.vmware_rest collection (version 5.0.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install vmware.vmware_rest.
To use it in a playbook, specify: vmware.vmware_rest.vcenter_vm_guest_filesystem_directories.
New in vmware.vmware_rest 5.0.0
DEPRECATED
- Removed in:
version 6.0.0
- Why:
This functionality has been replaced by ansible.builtin.file.
- Alternative:
Use ansible.builtin.file instead.
Synopsis
Create, delete, or move directories within the guest operating system of a running virtual machine.
Operations are performed through VMware Tools, so VMware Tools must be installed and running in the guest, and valid guest credentials must be supplied for every action.
Use
state=createto create a directory,state=createTemporaryto create a uniquely named temporary directory,state=deleteto remove a directory, andstate=moveto move or rename a directory.None of the actions are idempotent; each call performs the requested guest operation directly.
Parameters
Parameter |
Comments |
|---|---|
Whether to create any missing parent directories along the path. If a failure occurs, some parent directories may be left behind. When omitted, parent directories are not created. Used when Choices:
|
|
The guest operating system credentials used to authenticate and run the requested operation inside the virtual machine. Required for every action. |
|
If Only supported when Choices:
|
|
The password for the guest account named in Only relevant when |
|
The SAML bearer token used to authenticate within the guest. Only relevant when |
|
The type of guest credentials being supplied.
Choices:
|
|
The guest username to authenticate as. When When |
|
The complete path, in the guest filesystem, to move the directory to, or its new name. It must not point to an existing directory or an existing file. Required when |
|
The complete path, in the guest filesystem, of the directory in which to create the new temporary directory. When omitted, a guest-specific default location is used. Used when |
|
The complete path, in the guest filesystem, of the directory to act on. When When When Required when |
|
The prefix for the name of the new temporary directory. Required when |
|
If When omitted, directory contents are not deleted. Used when Choices:
|
|
Timeout in seconds for the whole operation including connection establishment, request sending, and response. Default: |
|
The desired state of the resource. Use Use Use Use This module does not support idempotence. Choices:
|
|
The suffix for the name of the new temporary directory. Required when |
|
The hostname or IP address of the vSphere vCenter. If the value is not specified in the task, the value of environment variable |
|
The vSphere vCenter password. If the value is not specified in the task, the value of environment variable |
|
The port number of the vSphere vCenter. If the value is not specified in the task, the value of environment variable |
|
Optional path to a log file for HTTP REST interaction. If the value is not specified in the task, the value of environment variable |
|
The vSphere vCenter username. If the value is not specified in the task, the value of environment variable |
|
Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Choices:
|
|
Identifier of the vm to manage. Must be an identifier (MOID) for a |
Notes
Note
Generated from vSphere API spec 9.1.0.
Compatible with vSphere API 7.0.3.
Compatible with vSphere API 8.0.2.
Examples
- name: Create a directory in the guest
vmware.vmware_rest.vcenter_vm_guest_filesystem_directories:
vm: vm-1234
state: create
path: /tmp/ansible_app
credentials:
type: USERNAME_PASSWORD
user_name: root
password: guest_password
- name: Create a directory and any missing parent directories
vmware.vmware_rest.vcenter_vm_guest_filesystem_directories:
vm: vm-1234
state: create
path: /opt/app/config/nested
create_parents: true
credentials:
type: USERNAME_PASSWORD
user_name: root
password: guest_password
- name: Create a uniquely named temporary directory
vmware.vmware_rest.vcenter_vm_guest_filesystem_directories:
vm: vm-1234
state: createTemporary
prefix: ansible_
suffix: _tmp
parent_path: /tmp
credentials:
type: USERNAME_PASSWORD
user_name: root
password: guest_password
register: temp_dir
- name: Move or rename a directory
vmware.vmware_rest.vcenter_vm_guest_filesystem_directories:
vm: vm-1234
state: move
path: /tmp/ansible_app
new_path: /opt/ansible_app
credentials:
type: USERNAME_PASSWORD
user_name: root
password: guest_password
- name: Delete a directory and all of its contents
vmware.vmware_rest.vcenter_vm_guest_filesystem_directories:
vm: vm-1234
state: delete
path: /opt/ansible_app
recursive: true
credentials:
type: USERNAME_PASSWORD
user_name: root
password: guest_password
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The raw API response body from the vCenter operation. When For Returned: On success Sample: |
Status
This module will be removed in version 6.0.0. [deprecated]
For more information see DEPRECATED.