I have created a playbook to create VM in a vmware Vcenter. It worked fine. I have used my localhost as host to create a vm on this vcenter. Now, I am trying to execute a command on that newly created vm but I am getting a connection error. The error message shown by my ansible playbook tries to login from the ESX host on which the new vm is deployed. Please help me to resolve this. my playbook:
---
- name : do opearation on vm
hosts : rhel66
vars_files :
- "playbook_vars.yml"
tasks :
- name : Run command inside a vm
vmware_vm_shell :
hostname: "{{ vcenter_name }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ vcenter_datacenter }}"
#folder: AutomationDevelopment/vm/Environments/Env07/rhel66_testvm
vm_id: "{{ vm_name }}"
validate_certs : false
vm_username: root
vm_password: *******
vm_shell: /bin/echo
vm_shell_args: " $var >> myFile "
vm_shell_env:
- "PATH=/bin"
- "VAR=test"
vm_shell_cwd: "/tmp"
register: shell_command_output
playbook output:
____________________________
< PLAY [do opearation on vm] >
----------------------------
________________________
< TASK [Gathering Facts] >
------------------------|
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: requests.exceptions.ProxyError: HTTPSConnectionPool(host='YY.YY.YY.YY', port=443): Max retries exceeded with url: /guestFile?id=235&token=52009a00-3927-ee12-8e82-bb795a2332c5235 (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f4d69e0c0f0>: Failed to establish a new connection: [Errno 113] No route to host',)))
fatal: [XX.XX.XX.XX]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}
____________
< PLAY RECAP >
------------
In above error: XX.XX.XX.XX -> my new vm IP and YY.YY.YY.YY is my ESX host on which this new vm is deployed