Ansible:无法ping Windows VM,抛出SSLError

时间:2019-03-07 08:33:29

标签: windows ansible ssl-certificate

Ansible服务器:Ubuntu 7.3.0-16ubuntu3

IP: 10.aa.bb.2

Windows VM: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 var,如下所示:

[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设置了入站规则,还运行了ConfigureRemotingForAnsible.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中创建的,那么就不会有错误。

1 个答案:

答案 0 :(得分:0)

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

import {MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS} from '@angular/material-moment-adapter';
import {DateAdapter, MAT_DATE_LOCALE} from '@angular/material/core';

@Component({
  providers: [
    {provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS]},
    {provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: {useUtc: true}}
  ]
})

这解决了我的类似问题。

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