How can I use default with variable in Ansible?

后端 未结 1 1318
不知归路
不知归路 2020-12-12 02:48

I know that I can use a simple hardcoded string in default but I am trying to do this:

myvar: \"{{ lookup(\'env\',\'var1\') | default(\"{{var2}}\",true) }}\"         


        
相关标签:
1条回答
  • 2020-12-12 03:45

    Once you opened a Jinja2 expression with {{ you don't need to open it again (especially quoted) and you can refer to the variables by their names:

    myvar: "{{ lookup('env','var1') | default(var2, true) }}"
    
    0 讨论(0)
提交回复
热议问题