My enviroment: RHEL 7.4 ansible host
ansible-playbook 2.4.0.0-0.5.rc5.el7
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.5 (default, May 3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]
pysphere==0.1.7
Target vCenter server is Windows 2012R2,
I can successfully use these ansible modules (via NTLM transport protocol):
win_ping
vmware_vm_facts
vmware_guest_facts
Having verifed the connectivity, I am attempting to run a playbook with module vsphere_guest.
Within 30-40 seconds of initiating the playbook, I'm getting this timeout msg and abort of the play:
[WARNING]: FATAL ERROR DURING FILE TRANSFER: Traceback (most recent call last): File "/usr/lib/python2.7/site- packages/ansible/plugins/connection/winrm.py", line 273, in _winrm_exec self._winrm_send_input(self.protocol, self.shell_id, command_id, data, eof=is_last) File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py", line 253, in _winrm_send_input protocol.send_message(xmltodict.unparse(rq)) File "/usr/lib/python2.7/site-packages/winrm/protocol.py", line 207, in send_message return self.transport.send_message(message) File "/usr/lib/python2.7/site-packages/winrm/transport.py", line 202, in send_message raise WinRMTransportError('http', error_message) WinRMTransportError: (u'http', u'Bad HTTP response returned from server. Code 500')
fatal: [ndctc1-vcntr01.mso.mci.com]: FAILED! => { "failed": true, "msg": "winrm send_input failed" }
What I have done so far:
Modified: /usr/lib/python2.7/site-packages/winrm/protocol.py
Changing these variables:
DEFAULT_READ_TIMEOUT_SEC = 300 <-- was 30 (seconds)
DEFAULT_OPERATION_TIMEOUT_SEC = 200 <-- was 20 (seconds)
DEFAULT_MAX_ENV_SIZE = 353600 <-- 153600
Did not fix the error, it only made it show up later...
Playbook:
- hosts: all
gather_facts: false
connection: local
vars_prompt:
- name: "vcenter_hostname"
prompt: "Enter vcenter hostname"
private: no
default: "vcsa"
- name: "vcenter_user"
prompt: "Enter vcenter username"
private: no
- name: "new_hostname"
prompt: "Enter new hostname"
private: no
- name: "vcenter_pass"
prompt: "Enter vcenter password"
private: yes
vars:
datacenter: mydatacenter
cluster: mycluster
notes: 'Created by Ansible'
tasks:
- vsphere_guest:
vcenter_hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: no
power_on_after_clone: no
guest: "{{ new_hostname }}"
from_template: yes
template_src: mybuild-template
cluster: "{{ cluster }}"
vm_extra_config:
notes: "{{ notes }}"
Note: I was not sure about what value to put in for "template_src" I have a VM template, named "mybuild-template" Is naming it correct?
Thank you.
winrmconnection. - Konstantin Suvorov