我无法将正确的路径传递给win_package
模块,Ansible不断添加转义符。
- name: Install package
win_package:
path: C:folderpackagename
FAILED! => {"changed": false, "msg": "the file at the local path C:\folder\package cannot be reached"
相同错误:
- name: Install package
win_package:
path: "C:\folder\packagename"
单个反斜杠导致ERROR! Syntax Error while loading YAML. found unknown escape character
文件上说,但第一种方法应该是有效的,但并不是这样
- name: Install 7zip and use a file version for the installation check
win_package:
path: C:temp7z.exe
是否有某种意想不到的方式可以传递此参数?是我的错误还是令人困惑的日志消息?
Ansible的默认stdout回调在输出过程中转义字符串,该值尚未修改。您的问题不是由此输出转义引起的。
ec2-user@pandora ~ $ ansible-playbook test.yml
PLAY [localhost] ***************************************************************
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "C:\foo\bar"
}
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ec2-user@pandora ~ $ ANSIBLE_STDOUT_CALLBACK=community.general.yaml ansible-playbook test.yml
PLAY [localhost] ***************************************************************
TASK [debug] *******************************************************************
ok: [localhost] =>
msg: C:foobar
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0