使用echo模块时的Ansible映射值问题

问题描述 投票:0回答:1

我正在学习ansible,我正在起诉shell命令在LDAP配置文件中添加参数。

echo -e "dn: cn=default, ou=policy, dc=com, dc=com \n changetype: modify \n replace: pwdMaxAge \n pwdMaxAge: 0\n" > /tmp/age.txt

但ansible抛出错误说

ERROR! Syntax Error while loading YAML.
  mapping values are not allowed here

 shell:  echo -e "dn:    cn=default,
                    ^

任何帮助,将不胜感激。

ansible ansible-2.x ansible-inventory ansible-facts
1个回答
0
投票

你需要单引号包装它,

shell: 'echo -e "dn: cn=default, ou=policy, dc=com, dc=com \n changetype: modify \n replace: pwdMaxAge \n pwdMaxAge: 0\n" > /tmp/age.txt'

此外,由于您正在学习,您可能希望部署templatecopy文件,而不是使用shell和文本重定向。

© www.soinside.com 2019 - 2024. All rights reserved.