当我尝试使用 ping 我的 Windows 实例ansible windows -i hosts.ini -m win_ping
时,出现以下错误:
54.197.197.91 | UNREACHABLE! => {
"changed": false,
"msg": "plaintext: the specified credentials were rejected by the server",
"unreachable": true
}
我的hosts.ini
文件看起来像:
[windows]
54.197.197.91
[windows:vars]
ansible_ssh_user=Administrator
ansible_ssh_pass=MyPassword123!
ansible_ssh_port=5985
ansible_connection=winrm
为了解决这个问题,我这样做了:
ansible-vault create secret.yml
并在那里输入我的密码:
win_initial_password: MyPassword123!
然后,我的hosts.ini
文件看起来像:
[windows]
54.197.197.91
[windows:vars]
ansible_ssh_user=Administrator
ansible_ssh_pass={{ win_initial_password }}
ansible_ssh_port=5985
ansible_connection=winrm
当我尝试 ping 时,出现以下错误:
54.197.197.91 | FAILED! => {
"failed": true,
"msg": "the field 'password' has an invalid value, which appears to include a variable that is undefined. The error was: 'win_initial_password' is undefined"
}
我哪里错了?