Loop over variable and concatenate with string

后端 未结 1 1596
无人及你
无人及你 2020-12-22 09:04

Suppose I have an array in ansible:

vars:
  loopme: [\'somesing\', \'someothersing\']
  concatenateme: \'constant\'

How do i iterate over t

相关标签:
1条回答
  • 2020-12-22 10:09

    You can use map to apply regex_replace filter to every element of your list and replace "end of string" ($) with your constant:


    - hosts: localhost
      gather_facts: no
      vars:
        loopme: ['somesing', 'someothersing']
        concatenateme: 'constant'
      tasks:
        - debug:
            msg: "{{ loopme | map('regex_replace','$',concatenateme) | list }}"
    
    0 讨论(0)
提交回复
热议问题