设置Ansible playbook时出现win_shell模块错误
我正在尝试设置一个包含设置Ansible playbook时出现win_shell模块错误,ansible,Ansible,我正在尝试设置一个包含win\u shell模块的剧本,但由于某些原因,它不起作用 --- - name: Installer hosts: localhost tasks: - name: Display tmp folder win_shell: echo %tmp% args: executable: cmd register: homedir_out - debug: var=homedir_out.stderr 我得到的错误是:
win\u shell
模块的剧本,但由于某些原因,它不起作用
---
- name: Installer
hosts: localhost
tasks:
- name: Display tmp folder
win_shell: echo %tmp%
args:
executable: cmd
register: homedir_out
- debug: var=homedir_out.stderr
我得到的错误是:
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "At <PathForAnsible>AnsiballZ_win_shell.ps1:151 char:1\r\n+ \u0000\u0000\u0000\u0000{\"module_entry\": \"IyFwb3dlcnNoZWxsCgojIENvcHlyaWdodDogKGMpIDIwMTc ...\r\n+ ~\r\nUnexpected token '\u0000' in expression or statement.\r\n + CategoryInfo : ParserError: (:) [], ParseException\r\n + FullyQualifiedErrorId : UnexpectedToken\r\n \r\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
fatal:[localhost]:失败!=>{
“更改”:错误,
“module\u stderr”:“At AnsiballZ\u win\u shell.ps1:151字符:1\r\n+\u0000\u0000\u0000\u0000{\“module\u entry\”:\“IYFWB3DLCNNOZWXSCGOJIENVCHLYAWDODOGKMPIDIWMTC…\r\n+~\r\n表达式或语句中的非预期标记“\u0000”。\r\n+类别信息:ParserError:(:)[],ParserException\r\n+FullyQualifiedErrorId:unexpected\r\n\r\r\n\r\n",
“模块”:“,
“msg”:“模块故障\n请参阅stdout/stderr以了解确切错误”,
“rc”:1
}
我希望看到从剧本中返回的tmp文件夹路径
非常感谢您的帮助
\u0000
是一个空字符。它可能隐藏在您的playbook中的某个位置。您是否尝试重新键入完整的playbook(而不是复制粘贴它)?@β.εηοιτ.βε是的,我试过这样做。没有任何帮助。出于好奇,你有localhost
,但我不相信;你是否在某个清单文件中覆盖localhost
以拥有ansible\u connection=winrm
?你能分享你的tmp目录的路径吗?我想,有“空间”导致此错误的临时目录路径中的字符是的,因为正如文档所述,您不能在Windows上运行ansible playbook
本身;您可以使用支持的操作系统运行playbook,它将通过winrm
连接到Windows以执行任务