【发布时间】:2019-08-21 23:06:44
【问题描述】:
我目前成功地使用 Ansible 在 AWS 的私有子网中的主机上运行任务,下面的 group_vars 正在设置:
ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -W %h:%p -q ec2-user@bastionhost@example.com"'
这工作正常。
对于不在私有子网中的 Windows 实例,以下group_vars 有效:
---
ansible_user: "AnsibleUser"
ansible_password: "Password"
ansible_port: 5986
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
现在,尝试仅使用 ProxyCommand 将 Ansible 部署到堡垒后面的 Windows 服务器是行不通的 - 我明白这一点。
我相信虽然我可以使用一个名为 psrp 的新协议/模块。
我想我的 Windows 主机的group_vars 需要更改为如下内容:
---
ansible_user: "AnsibleUser"
ansible_password: "Password"
ansible_port: 5986
ansible_connection: psrp
ansible_psrp_cert_validation: ignore
如果我只对公开可用的实例进行上述更改(而不是尝试通过堡垒连接),我的任务似乎可以正常工作:
Using module file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/modules/windows/win_shell.ps1
<10.100.11.14> ESTABLISH PSRP CONNECTION FOR USER: Administrator ON PORT 5986 TO 10.100.11.14
PSRP: EXEC (via pipeline wrapper)
我知道必须进行更多更改才能在堡垒后面的 Windows 服务器上尝试此操作,但无论如何运行它以查看我遇到的错误,以便为我提供下一步操作的线索。这是在堡垒服务器后面的实例上运行时的结果:
Using module file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ansible/modules/windows/setup.ps1
<10.100.11.14> ESTABLISH PSRP CONNECTION FOR USER: Administrator ON PORT 5986 TO 10.100.11.14
The full traceback is:
.
.
.
.
ConnectTimeout: HTTPSConnectionPool(host='10.100.11.14', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x110bbfbd0>, 'Connection to 10.100.11.14 timed out. (connect timeout=30)'))
似乎 Ansible 忽略了我的 group_vars 的 ProxyCommand - 我不确定这是否是预期的。
我也不确定下一步如何让 Ansible 部署到堡垒后面的 Windows 服务器。
我缺少什么配置?
【问题讨论】:
-
@error404 该文档是指根据我的问题在堡垒后面的 linux 主机上部署 - 我正在尝试部署到 Windows 主机
-
Pouyan提供的url明确指向解决方案。
标签: amazon-web-services ansible