community.general.accumulate 过滤器 – 生成输入列表内容的累积和列表
注意
此过滤器插件是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了这个集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。
要在 playbook 中使用它,请指定:community.general.accumulate
。
community.general 10.1.0 中的新增功能
概要
将输入列表转换为将加法应用于输入列表元素的累积结果列表。
加法表示输入列表元素类型的默认 Python 实现
+
。
输入
这描述了过滤器的输入,即 | community.general.accumulate
前面的值。
参数 |
注释 |
---|---|
一个列表。 |
示例
- name: Enumerate parent directories of some path
ansible.builtin.debug:
var: >
"/some/path/to/my/file"
| split('/') | map('split', '/')
| community.general.accumulate | map('join', '/')
# Produces: ['', '/some', '/some/path', '/some/path/to', '/some/path/to/my', '/some/path/to/my/file']
- name: Growing string
ansible.builtin.debug:
var: "'abc' | community.general.accumulate"
# Produces ['a', 'ab', 'abc']
返回值
键 |
描述 |
---|---|
输入列表元素的累积和列表。 返回: 成功 |