gpt4 book ai didi

windows - 使用 Windows 节点的 Ansible - 如何创建目录

转载 作者:可可西里 更新时间:2023-11-01 11:16:31 27 4
gpt4 key购买 nike

我需要创建 C:\MSI 文件夹来放置 msi 文件。这是我的任务:

tasks:
- name: Copy *.msi files from ./MSI to C:\MSI
file: path=C:\MSI state=directory

但是我得到了错误:

TASK [Copy *.msi files from ./MSI to C:\MSI] ***********************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: + ~~~~~~~~~~~~~~~
fatal: [agentsmith]: FAILED! => {"changed": false, "failed": true, "msg": "The term '/usr/bin/python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."}

在详细模式下,我看到文件模块出于某种原因将 /usr/bin/python 放入 Powershell 脚本:

TASK [Copy *.msi files from ./MSI to C:\MSI] ***********************************
task path: /home/qaexpert/ansible-lab/tcagent.yml:8
<agentsmith> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO agentsmith
<agentsmith> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1477410445.62-187863101456896").FullName | Write-Host -Separator '';
<agentsmith> PUT "/tmp/tmpqOJYen" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1477410445.62-187863101456896\file.ps1"
<agentsmith> EXEC Set-StrictMode -Version Latest
Try
{
/usr/bin/python 'C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1477410445.62-187863101456896\file.ps1'
}
Catch
...

最佳答案

Ansible 寻找 /usr/bin/python 因为 file 模块需要在目标系统上安装 Python。无法为 Windows 目标使用普通 Ansible 模块。

查看Ansible Windows documentation了解详情。在 Windows 主机上,只有 “windows” subcategory of the Ansible module index 中列出的模块可用。

要替换常规的 file 模块,请使用 win_file 模块。

关于windows - 使用 Windows 节点的 Ansible - 如何创建目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40245209/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com