使用1.5.4的命令
lineinfile: dest=/etc/bash.bashrc line="bind '\"\e[B\"':history-search-forward"
添加了该行
bind '"\e[B"':history-search-forward
到/etc/bash.bashrc非常好。
在1.9.1中,相同的指令会产生下面一行,它会混淆我在lineinfile命令中转义的引号:
bind \e[B:history-search-forward
我如何修复报价,以便添加正确的行
通常可以通过使用多行inputforms避免一些乱七八糟的乱七八糟,特别是在input冒号时:
command: > curl -X POST -H 'Content-Type: application/json' --data '{"name": "{{ item.name }}", "comment": "{{ item.comment }}", "DefaultDistribution": "{{ item.default_distribution }}", "DefaultComponent": "{{ item.default_component }}" }' http://localhost:8080/api/repos
我写了一个Ansible的手册,我觉得你想做什么(尽pipetesting文件,而不是实际的bashrc。
--- - name: Example for serverfault.com hosts: all tasks: - name: Put line with quotes, backslash, and colon in a file lineinfile: dest: /home/vagrant/testfile.txt create: yes line: "bind '\"\\e[B\"':history-search-forward"
我已经运行了这个,并在testfile.txt中得到这一行:
bind '"\e[B"':history-search-forward
我正在使用Ansible 2.1.1.0。 我不知道这是否与1.9.1不同