【发布时间】:2018-12-06 12:57:09
【问题描述】:
当我尝试通过 WinRM 模块连接到我的 Windows 主机时,我在 Ansible 中得到执行“连接被拒绝”。
有ansible目录的结构:
命令:
user@ansible:~/git/ansible-test$ ansible-playbook test.yml -i inventories/hosts
PLAY [install vm] ***************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************
fatal: [10.10.10.10]: UNREACHABLE! => {"changed": false, "msg": "ssl: HTTPSConnectionPool(host='10.10.10.10', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f6298184d50>: Failed to establish a new connection: [Errno 111] Connection refused',))", "unreachable": true}
to retry, use: --limit @/home/user/git/ansible-test/test.retry
PLAY RECAP ***********************************************************************************************************************************************************************************
10.10.10.10 : ok=0 changed=0 unreachable=1 failed=0
ansible-test 直接层次结构:
ansible-test$ tree
.
├── group_vars
│ └── all
├── inventories
│ └── hosts
└── test.yml
2 directories, 3 files
test.yaml:
- name: test
hosts: vm
tasks:
- name: get ipconfig information
raw: ipconfg
register: ipconfig_out
- name: print stdout
debug: var=ipconfig_out.stdout_lines
库存/主机
[vm]
10.10.10.10
group_vars/all
ansible_connection: winrm
ansible_user: Administrator
ansible_password: password
但如果我通过 WinRM 从其他 Windows 主机连接到目标 10.10.10.10:
Set-Item wsman:\localhost\Client\TrustedHosts -value 10.10.10.10
Enter-PSSession -ComputerName 10.10.10.10 -Credential (Get-Credential -UserName Administrator)
一切正常!
我在 Ansible 中做错了什么?
附: 目标主机是 Windows Server 2012
【问题讨论】:
-
您好 user3265618,欢迎来到 SO!看来您还没有设置
ansible_winrm_transport:。我同意连接被拒绝是一个奇怪的消息,但首先设置正确的传输,看看是否有帮助。祝你好运!