VMware VM Shell
5 min
Resumo
- O módulo permite que o usuário execute comandos comuns de administração do sistema no sistema operacional convidado.
Parâmetros
Parâmetro | Tipo | Escolhas | Valor Padrão | Comentários |
|---|---|---|---|
datacenter | string | |
|
cluster | bool |
|
|
folder | string | |
|
vm_id | bool | |
|
vm_id_type | string |
|
|
vm_username | string | |
|
vm_password | string | |
|
vm_shell | string | |
|
vm_shell_args | string |
|
|
vm_shell_env | list | |
|
vm_shell_cwd | string | |
|
wait_for_process | bool |
|
|
timeout | interger |
|
|
Estende fragmentos da documentação do módulo VMware Options.
Notas
Observação
- Testado em ESXi 7.0.2
- Todos os módulos requerem acesso de gravação API e, portanto, não são suportados em uma licença ESXi gratuita.
Exemplos
- name: Run command inside a virtual machine
community.vmware.vmware_vm_shell:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter }}"
folder: "/{{datacenter}}/vm"
vm_id: "{{ vm_name }}"
vm_username: root
vm_password: superSecret
vm_shell: /bin/echo
vm_shell_args: " $var >> myFile "
vm_shell_env:
- "PATH=/bin"
- "VAR=test"
vm_shell_cwd: "/tmp"
delegate_to: localhost
register: shell_command_output
- name: Run command inside a virtual machine with wait and timeout
community.vmware.vmware_vm_shell:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter }}"
folder: "/{{datacenter}}/vm"
vm_id: NameOfVM
vm_username: root
vm_password: superSecret
vm_shell: /bin/sleep
vm_shell_args: 100
wait_for_process: True
timeout: 2000
delegate_to: localhost
register: shell_command_with_wait_timeout
- name: Change user password in the guest machine
community.vmware.vmware_vm_shell:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter }}"
folder: "/{{datacenter}}/vm"
vm_id: "{{ vm_name }}"
vm_username: sample
vm_password: old_password
vm_shell: "/bin/echo"
vm_shell_args: "-e 'old_password\nnew_password\nnew_password' | passwd sample > /tmp/$$.txt 2>&1"
delegate_to: localhost
- name: Change hostname of guest machine
community.vmware.vmware_vm_shell:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter }}"
folder: "/{{datacenter}}/vm"
vm_id: "{{ vm_name }}"
vm_username: testUser
vm_password: SuperSecretPassword
vm_shell: "/usr/bin/hostnamectl"
vm_shell_args: "set-hostname new_hostname > /tmp/$$.txt 2>&1"
delegate_to: localhost
Valores Retornados
Chave | Tipo | Retornado quando | Descrição |
|---|---|---|---|
results | dict | sucesso | metadados sobre o novo processo após a conclusão com wait_for_process |