2017-07-26 10 views
0

で連結するには、私がansibleの配列があるとします。変数をループし、文字列

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

私は、変数concatenatemeでリストからリストと、連結値を反復するにはどうすればよいですか?

私はsomesingconstantsomeothersingconstantを得て、結果をタスクのフィールドに入れますか?おそらくジンジャと?

あなたはあなたのリストのすべての要素に regex_replaceフィルタを適用する mapを使用して、定数を「文字列の末尾に」( $)を置き換えることができ

答えて

2


- hosts: localhost 
    gather_facts: no 
    vars: 
    loopme: ['somesing', 'someothersing'] 
    concatenateme: 'constant' 
    tasks: 
    - debug: 
     msg: "{{ loopme | map('regex_replace','$',concatenateme) | list }}" 
+0

これは配列になりますか? – 4c74356b41

+1

はい、それはリストになります: '' somesingconstant "、" someothersingconstant "]' –

関連する問題