首页 > 解决方案 > Ansible:无法 ping Windows VM,抛出 SSLError

问题描述

Ansible 服务器:Ubuntu 7.3.0-16ubuntu3

IP: 10.aa.bb.2

Windows 虚拟机:Windows Server 2016

IP: 10.aa.bb.1

用这个来ping:

ansible windows -m win_ping

抛出错误:

10.aa.bb.1 | UNREACHABLE! => {
    "changed": false,
    "msg": "ssl: HTTPSConnectionPool(host='10.aa.bb.1', port=5986): Max retries exceeded with url: /wsman (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)'),))",
    "unreachable": true
}

我在 /etc/ansible/hosts 中配置了 windows vars,如下所示:

[windows]
10.aa.bb.1

[windows:vars]
ansible_user=username
ansible_password=password_for_windows
ansible_port=5986
ansible_connection=winrm
ansible_winrm_cert_validation=ignore

在 Windows VM 上,我为端口 5986 设置了入站规则,并且还运行了ConfiguringRemotingForAnsible.ps1 进行配置。结果winrm e winrm/config/listener是:

Listener 
Address = *                                                          
Transport = HTTP                                                     
Port = 5985                                                          
Hostname                                                             
Enabled = true                                                       
URLPrefix = wsman                                                    
CertificateThumbprint                                                
ListeningOn = 10.aa.bb.1, 127.0.0.1, ::1                                                                                              
Listener                                                                 
Address = *                                                          
Transport = HTTPS                                                    
Port = 5986                                                          
Hostname = hostname                                             
Enabled = true                                                       
URLPrefix = wsman                                                    
CertificateThumbprint = 036F429259C04211xxxxxxxxxxxxxxxxxxxxD5     
ListeningOn = 10.aa.bb.1, 127.0.0.1, ::1

我不知道我是否遗漏了配置中的某些内容,因为如果我使用的 VM 都是在 Azure 中创建的,则不会有任何错误。

标签: windowsansiblessl-certificate

解决方案


尝试将此添加到您的库存文件中:

[tag_Name_Alican_Windows_Deneme]
[windows:children]
tag_Name_Alican_Windows_Deneme

这解决了我的类似问题。

否则没有ssl的连接是否有效?


推荐阅读