Jinja2: format + join the items of a list

前端 未结 4 2254
無奈伤痛
無奈伤痛 2021-02-12 12:42

play_hosts is a list of all machines for a play. I want to take these and use something like format() to rewrite them like rabbitmq@%s and

4条回答
  •  借酒劲吻你
    2021-02-12 13:47

    In ansible you can use regex_replace filter:

    {{ play_hosts | map('regex_replace', '^(.*)$', 'rabbitmq@\\1') | list }}
    

提交回复
热议问题