Using variable in default filter in Ansible Jinja2 template

前端 未结 1 2060
忘了有多久
忘了有多久 2021-01-03 06:46

Inside a an Ansible Jinja2 template I\'m trying to set a \"default\" value which also has a variable in it but it\'s printing out the literal rather than interpolating it.

1条回答
  •  太阳男子
    2021-01-03 07:09

    Inside Jinja2 expression use Jinja2 syntax. You should concatenate strings to a variable value:

    homedir = {{ hostvars[inventory_hostname]['instances'][app_instance]['homedir'] | default("/home/" + app_instance + "/airflow") }}
    

    0 讨论(0)
提交回复
热议问题