【发布时间】:2016-08-20 17:24:09
【问题描述】:
每次我尝试在 Windows Server 中运行 playbook 以自动执行某些安装时,我的 Windows 远程主机似乎无法访问。
在这里,我正在尝试安装 IIS 服务器,而我的 playbook 看起来像这样:
---
- hosts : windows
tasks :
- name : Install Microsoft IIS
win_feature :
name : Web-Server
state : present
错误是:
fatal: [ec2-54-197-197-91.compute-1.amazonaws.com]: UNREACHABLE! => {
"changed": false,
"msg": "ssl: HTTPSConnectionPool(host='ec2-54-197-197-91.compute-1.amazonaws.com', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x1b11310>, 'Connection to ec2-54-197-197-91.compute-1.amazonaws.com timed out. (connect timeout=30)'))",
"unreachable": true
}
但是,现在我知道,要运行适用于 Windows 的 playbook,我需要在我的控制节点上安装 winrm。
我做了以下事情:
pip install "pywinrm>=0.1.1"
我已经添加了 Windows 实例的公共 ip,我的 hosts 文件看起来像:
[local]
127.0.0.1
[aws]
ec2-54-152-85-197.compute-1.amazonaws.com
[windows]
ec2-54-197-197-91.compute-1.amazonaws.com
然后,我在 /etc/ansible 中创建了一个目录 "group_vars",并在其中创建了一个文件 windows.yml,内容如下:
ansible_user: Administrator
ansible_password: SecretPasswordGoesHere
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
请告诉我哪里出错了。
【问题讨论】: