с простыми фильтрами
$ cat filter_plugins/string_filters.py
def string_prefix(prefix, s):
return prefix + s
def string_postfix(postfix, s):
return s + postfix
class FilterModule(object):
''' Ansible filters. Python string operations.'''
def filters(self):
return {
'string_prefix' : string_prefix,
'string_postfix' : string_postfix
}
задачи ниже
- set_fact:
output: "{{ input|map('string_prefix', '-Z')|list }}"
- debug:
var: output
отдает:
"output": [
"a-Z",
"b-Z",
"c-Z"
]
Тот же вывод дает цикл ниже
- set_fact:
output: "{{ output|default([]) + [item + '-Z'] }}"
loop: "{{ input }}"
- debug:
var: output