Jeff_S
(Jeff S)
June 15, 2022, 11:07am
1
Hello
I am currently preparing a playbook for installing and configuring HAProxy on a vmware VM, everything works so far, but i have a problem for managing the VM via ssh, as i cant turn up the network interface eth0 , there must be an error in my yaml-code, or may the usage of ip link set eth0 up is not supported for vmware_vm_shell module .
Please, can anyone give me some advice on solving this issue?
Task:
name: activate eth0
vmware_vm_shell :
hostname: “{{ vsphere_host }}”
username: “{{ vsphere_username }}”
password: “{{ vsphere_password }}”
validate_certs: “no”
datacenter: “{{ datacenter_name }}”
folder: “{{ to_infra }}”
vm_id: “{{ nam }}”
vm_username: “{{ common_user }}”
vm_password: “{{ common_pw }}”
vm_shell: “/sbin/ip ”
vm_shell_args: “link set eth0 up ”
Note, the VM is running Ubuntu
Akasurde
(Abhijeet Kasurde)
June 15, 2022, 11:47am
2
vmware_vm_shell supports all commands which OS supports.
Try debugging using vm_shell_args: link set eth0 up > /tmp/$$.txt 2>&1
which might reveal the error behind.
Jeff_S
(Jeff S)
June 15, 2022, 1:07pm
3
Thx for the assist, works now!
Solution:
name: activate eth0
vmware_vm_shell:
hostname: “{{ vsphere_host }}”
username: “{{ vsphere_username }}”
password: “{{ vsphere_password }}”
validate_certs: “no”
datacenter: “{{ datacenter_name }}”
folder: “{{ to_infra }}”
vm_id: “{{ nam }}”
vm_username: “{{ common_user }}”
vm_password: “{{ common_pw }}”
vm_shell: “/usr/bin/sudo ”
vm_shell_args: “ip link set eth0 up > /tmp/debug.txt 2>&1”
Note, can be used to run any command with root-permissions on remote VMware-hosts, with no internet-connection setup!
Akasurde
(Abhijeet Kasurde)
June 15, 2022, 1:19pm
4
Would you be interested in raising a documentation update pull request against vmware_vm_shell
with your findings? If you need a help, let me know.
Akasurde
(Abhijeet Kasurde)
June 15, 2022, 1:54pm
6