Quotes in ansible lineinfile

前端 未结 4 733
灰色年华
灰色年华 2020-12-10 11:30

When I use lineinfile in ansible it is not writing \', \" characters lineinfile: \'dest=/home/xyz state=present line=\"CACHES=\"

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 12:27

    Just a follow up to this, above examples did not work for me when trying to create a batch file on a windows box using win_lineinfile. The file was being created, the line was being inserted, but the quotes and backslashes were formatted terribly. This was with ansible 2.4. What I finally ended up doing per a co workers suggestion was some inline jinja templating;

    - name: insert our batch file contents
      win_copy:
        dest: C:\QAAutomation\files\posauto.bat
        force: yes
        content: |
          {% raw %}"C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe" "C:\QAAutomation\files\1POS Automation\Application Files\Bin\Automation.dll" > "c:\QAAutomation\results\nunit-console-output.txt" {% endraw %}
    

提交回复
热议问题