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)_winrm_send_input中的文件“/usr/lib/python2.7/site-packages/ansible/plugins/connection/winrm.py”,第253行protocol.send_message(xmltodict.unparse(rq))文件“/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 :( u'http',u'Bad HTTP响应从服务器返回 . 代码500')
致命的:[ndctc1-vcntr01.mso.mci.com]:失败了! => {“失败”:true,“msg”:“winrm send_input failed”}
What I have done so far:
修改:/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 }}"
注意:我不确定为“template_src”输入什么值我有一个名为“mybuild-template”的VM模板命名正确吗?
谢谢 .
1 回答
感谢康斯坦丁的精彩提示,我学到了两个解决我问题的方法:
库存只需要一行:localhost ansible_connection = local因为VMware拥有自己的API和通信协议 . 今天我学会了......
而且,我试图在启动时使用vCenter模板 . 一旦我关闭它,它工作!