Proper way to concatenate variable strings

后端 未结 3 955
夕颜
夕颜 2021-02-01 01:36

I need to create new variable from contents of other variables. Currently I\'m using something like this:

- command: echo \"{{ var1 }}-{{ var2 }}-{{ var3 }}\"
           


        
3条回答
  •  迷失自我
    2021-02-01 01:51

    Good question. But I think there is no good answer which fits your criteria. The best I can think of is to use an extra vars file.

    A task like this:

    - include_vars: concat.yml
    

    And in concat.yml you have your definition:

    newvar: "{{ var1 }}-{{ var2 }}-{{ var3 }}"
    

提交回复
热议问题