每次我尝试运行一个剧本来自动化 Windows Server 中的某些安装时,我的Windows远程主机似乎都是 unreachable .
在这里,我正在尝试安装IIS服务器,我的 playbook 看起来像这样:
---
- hosts : windows
tasks :
- name : Install Microsoft IIS
win_feature :
name : Web-Server
state : present
error 是:
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的Playbooks,我需要在我的控制节点上安装 winrm .
我做了以下事情:
pip install "pywinrm>=0.1.1"
我添加了Windows实例的公共IP,我的 hosts file 看起来像:
[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
请让我知道我哪里出错了 .
1 回答
(很有可能,因为你没有提到它)
您需要在Windows实例上的PowerShell中配置远程命令(如Windows system prep部分中所述) . 执行以下操作(具有管理员权限):
之前,根据您的设置,您可能还需要启用PowerShell执行策略,将网络接口设置为专用网络(请注意下面的
InterfaceAlias
值)并启用PowerShell远程处理 .