ansible - 在 Linux 控制器上使用 Ansible 通过 ssh 管理 Windows 主机?
问题描述
Ansible v2.11.1
我在我的 Windows 主机上安装了 OpenSSH,并且正确设置了我的 SSH 密钥。因此,我可以通过 ssh 从我的 Linux 节点连接到我的 Windows 10 节点,这意味着它可以在不提示输入密码的情况下工作。
$ ssh jenkins@10.123.45.67
我有以下库存和 group_var 文件
inventory/windows.yaml
----------------------
[windows10]
windows-10-os-only ansible_host=10.123.45.67
group_vars/windows10.yaml
-------------------------
---
ansible_user: "jenkins"
ansible_connection: "ssh"
我收到以下临时命令错误。我错过了什么?注意我可以使用 WinRM 完成这项工作,但我正在尝试使用 SSH,因此我不必存储用户名/密码凭据。
$ ansible -i inventory/windows.yaml windows-10-os-only -m win_ping -vvv
ansible [core 2.11.1]
config file = /home/jenkins/ansible-test/ansible.cfg
configured module search path = ['/home/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jenkins/.local/lib/python3.8/site-packages/ansible
ansible collection location = /home/jenkins/.ansible/collections:/usr/share/ansible/collections
executable location = /home/jenkins/.local/bin/ansible
python version = 3.8.0 (default, Feb 25 2021, 22:10:10) [GCC 8.4.0]
jinja version = 2.10
libyaml = False
Using /home/jenkins/ansible-test/ansible.cfg as config file
host_list declined parsing /home/jenkins/ansible-test/inventory/windows.yaml as it did not pass its verify_file() method
script declined parsing /home/jenkins/ansible-test/inventory/windows.yaml as it did not pass its verify_file() method
Parsed /home/jenkins/ansible-test/inventory/windows.yaml inventory source with ini plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
META: ran handlers
<10.227.26.78> ESTABLISH SSH CONNECTION FOR USER: jenkins
<10.227.26.78> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="jenkins"' -o ConnectTimeout=10 -o ControlPath=/home/jenkins/.ansible/cp/4d20c11b7a 10.227.26.78 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo c:\jenkins\tmp `"&& mkdir "` echo c:\jenkins\tmp/ansible-tmp-1622667580.5927646-3243-198782318105723 `" && echo ansible-tmp-1622667580.5927646-3243-198782318105723="` echo c:\jenkins\tmp/ansible-tmp-1622667580.5927646-3243-198782318105723 `" ) && sleep 0'"'"''
<10.227.26.78> (1, b'', b'The system cannot find the path specified.\r\n')
<10.227.26.78> Failed to connect to the host via ssh: The system cannot find the path specified.
windows-10-os-only | UNREACHABLE! => {
"changed": false,
"msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \"` echo c:\\jenkins\\tmp `\"&& mkdir \"` echo c:\\jenkins\\tmp/ansible-tmp-1622667580.5927646-3243-198782318105723 `\" && echo ansible-tmp-1622667580.5927646-3243-198782318105723=\"` echo c:\\jenkins\\tmp/ansible-tmp-1622667580.5927646-3243-198782318105723 `\" ), exited with result 1",
"unreachable": true
}
解决方案
推荐阅读
- android - 如何在 Android 9 上集成系统应用
- python - 类类型参数中的 Python 默认类型
- c# - 用于滑入/滑出页面的 WPF 帧动画无法与数据触发器一起正常工作
- google-bigquery - Bigquery 中 UTC 的 2 个日期时间之间的差异
- amazon-web-services - 错误:ffmpeg 在 AWS Lambda 上以代码 1 退出
- java - Spring的ThreadPoolTaskExecutor的工作
- php - 单击搜索按钮后,视图中的分页功能以 JSON 格式返回所有数据
- javascript - 反应材料表导出按钮未正确查看
- javascript - Firebase 读取安全规则
- google-cloud-platform - Google BigQuery ML 是否会自动使时间序列数据保持静止?