我正在使用 Vagrant+Ansible 设置 Windows Server 2019 VM。
我的 Vagrant 文件:
Vagrant.configure("2") do |config|
config.vm.box = "StefanScherer/windows_2019"
config.vm.provision :ansible do |ansible|
ansible.playbook = "provisioners/ansible/ansible_playbook.yml"
ansible.config_file = "provisioners/ansible/ansible.cfg"
ansible.become_user = "Administrator"
ansible.raw_arguments = ["-e", "ansible_winrm_server_cert_validation=ignore"]
end
end
我在 vagrant up --provision
上收到此错误:Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'StefanScherer/windows_2019' version '2020.09.22' is up to date...
==> default: Running provisioner: ansible...
default: Running ansible-playbook...
PLAY [Jenkins node playbook]
***************************************************
TASK [Gathering Facts]
*********************************************************
Friday 29 January 2021 09:23:35 +0100 (0:00:00.023) 0:00:00.023 ********
fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "ssl:
HTTPSConnectionPool(host='127.0.0.1', port=55985): Max retries exceeded with
url: /wsman (Caused by SSLError(SSLError(\"bad handshake: Error([('SSL routines',
'ssl3_get_record', 'wrong version number')])\")))", "unreachable": true}
PLAY RECAP
*********************************************************************
default : ok=0 changed=0 unreachable=1 failed=0
skipped=0 rescued=0 ignored=0
Friday 29 January 2021 09:23:35 +0100 (0:00:00.135) 0:00:00.158 ********
===============================================================================
Gathering Facts --------------------------------------------------------- 0.14s
Playbook run took 0 days, 0 hours, 0 minutes, 0 seconds
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
如何修复此错误?我并不特别需要 SSL,这只是在本地机器上测试虚拟机。
最佳答案
这让我发疯了。使用 host_key_checking 关闭 ssl 验证什么也没做,并且错误消息并不能完全引导您朝着正确的方向前进。 Openssl 报告两台机器都支持最高 1.3 的 tls。
我了解到 official documentation建议使用 ssh 作为通信协议(protocol),并在 Windows 机器上设置 winrm。
细节
ansible_connection: winrm
这是possibly outdated .相反,我能够与ansible_connection: ssh
winrm create winrm/config/listener?Address=IP:**your ipv6**+Transport=HTTPS @{HostName="**your host**";CertificateThumbprint="**your thumbprint**";Port="5986"}
ipconfig /all
获得)为确保一切正常运行,您可以使用(从您的 ansible 机器)
openssl s_client -connect **Windows box IP**:5986
您不应收到“没有可用的对等证书”响应。注意:我没有尝试过信任来自我的 Linux 主机的自签名证书并使用 winrm 协议(protocol)。以上工作让我得到了我需要的东西。
为了完整起见,我的库存:
all:
hosts:
win_tower:
ansible_host: **my IP**
ansible_port: **my ssh port**
ansible_user: **my ssh user**
ansible_connection: ssh
ansible_shell_type: cmd
ansible_python_interpreter: C:\Git\usr\share\python\python-3.9.2x64\python
关于ssl - Vagrant,Ansible : SSLError bad handshake: Error SSL routines, ssl3_get_record,错误的版本号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65951104/