Escaping double curly braces in Ansible

前端 未结 10 1147
我寻月下人不归
我寻月下人不归 2020-12-13 05:19

How to escape double curly braces in Ansible 1.9.2?

For instance, how can I escape double curly braces in the following shell command?

- name: Test 
         


        
10条回答
  •  鱼传尺愫
    2020-12-13 06:13

    Tried on with ansible 2.1.1.0

    {%raw%}...{%endraw%} block seems the clear way

    - name: list container images and name date on the server
      shell: docker ps --format {%raw%}"{{.Image}} {{.Names}}"{%endraw%}
    

    Only need to escape leading '{{'

    tasks:
    - name: list container images and names
      shell: docker ps --format "{{'{{'}}.Image}} {{'{{'}}.Names}}"
    

    No harm to escap the tailing '}}', except more difficult to read.

    tasks:
    - name: list container images and names
      shell: docker ps --format "{{'{{'}}.Image{{'}}'}} {{'{{'}}.Names{{'}}'}}"
    

    Backslash '\' seems do not work

提交回复
热议问题