Escaping double curly braces in Ansible

前端 未结 10 1158
我寻月下人不归
我寻月下人不归 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:11

    I managed to work around my issue using a small script:

    #!/usr/bin/env bash
    
    docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$1"
    

    And the following Ansible play

    - copy:
        src: files/get_docker_ip.sh
        dest: /usr/local/bin/get_docker_ip.sh
        owner: root
        group: root
        mode: 0770
    
    - shell: "/usr/local/bin/get_docker_ip.sh {{ SWIFT_ACCOUNT_HOSTNAME }}"
      register: swift_account_info
    

    Nevertheless, it's very surprising that Ansible doesn't allow escaping double curly braces!

提交回复
热议问题