0
這似乎是一個錯誤。但在將問題發佈到安全的github項目之前,我在這裏問。查找模塊無法使用regex_replace過濾器計算模板的值
劇本:
- hosts: localhost
tasks:
- template: >
dest=/tmp/test.xml
src=test.xml.j2
- debug: msg="{{ lookup('template', 'test.xml.j2') }}"
vars:
- command: 'echo "word1 word2"'
test.xml.j2
<command>ssh {{ command| regex_replace('"(.*)"', '"\\"\1\\""') }} #1</command>
<command>ssh {{ command| regex_replace('"(.*)"', '"\\"\\1\\""') }} #2</command>
測試命令
ansible-playbook test.yml -D -C
預期的結果:在這兩個任務
實際結果相同的結果( ansible 2 .3.1.0):
- 逸出一次時,模板模塊無法顯示第一參考
- 逸出兩次時,查找模塊無法提領第二參考