[英]Unable to connect to a Windows Instance using Ansible Playbook
每次嘗試運行劇本以自動執行Windows Server中的某些安裝時,Windows Remote Host似乎都無法訪問 。
在這里,我正在嘗試安裝IIS服務器,而我的劇本看起來像這樣:
---
- 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的劇本,我需要在控制節點上安裝winrm 。
我已經完成以下工作:
pip install "pywinrm>=0.1.1"
我添加了Windows實例的公共IP,我的主機文件如下所示:
[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
請讓我知道我要去哪里了。
(很可能是因為您沒有提到它)
您需要在Windows實例上的PowerShell中配置遠程命令(如Windows系統准備部分中所述)。 執行以下操作(具有管理員權限):
iwr https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -UseBasicParsing | iex
之前,根據您的設置,您可能還需要啟用PowerShell執行策略,將網絡接口設置為專用網絡(請注意下面的InterfaceAlias
值),然后啟用PowerShell遠程處理。
Set-ExecutionPolicy Unrestricted -Force
Set-NetConnectionProfile -InterfaceAlias Ethernet0 -NetworkCategory Private
Enable-PSRemoting
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.