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
目标vCenter Server是Windows 2012R2,
我可以成功使用这些ansible模块(通过NTLM传输协议):
win_ping
vmware_vm_facts
vmware_guest_facts
验证连接后,我正在尝试使用 vsphere_guest 模块运行一个剧本。
在启动剧本的30-40秒内,我获得了此超时消息并中止播放:
[警告]:文件传输期间的致命错误:回溯(最近一次调用最后一次):文件" /usr/lib/python2.7/site- packages / ansible / plugins / connection / winrm.py",第273行,在_winrm_exec self._winrm_send_input(self.protocol,self.shell_id,command_id,data, eof = is_last)文件" /usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py",第253行,在_winrm_send_input中 protocol.send_message(xmltodict.unparse(rq))file" /usr/lib/python2.7/site-packages/winrm/protocol.py" ;,第207行,在send_message中返回 self.transport.send_message(message)文件" /usr/lib/python2.7/site-packages/winrm/transport.py" ;,第202行,在send_message中 WinRMTransportError(' http',error_message)WinRMTransportError :(你' http',u'从服务器返回错误的HTTP响应。代码500')
致命:[ndctc1-vcntr01.mso.mci.com]:失败了! => { "失败":是的, " msg":" winrm send_input失败" }
到目前为止我做了什么:
修改:/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
没有修复错误,只是让它稍后出现......
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 }}"
注意:我不确定要为&#34; template_src&#34;提供什么价值? 我有一个名为&#34; mybuild-template&#34;的虚拟机模板。命名正确吗?
谢谢。
答案 0 :(得分:0)
感谢康斯坦丁的精彩提示,我学到了两个解决问题的方法:
库存只需要一行: localhost ansible_connection = local 因为VMware拥有自己的API和通信协议。 今天我学会了......
而且,我正在尝试在启动时使用vCenter模板。 一旦我关闭它,它就有效了!