Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ansible 将列表中每个路径的基本名称保存到新列表中_Ansible - Fatal编程技术网

Ansible 将列表中每个路径的基本名称保存到新列表中

Ansible 将列表中每个路径的基本名称保存到新列表中,ansible,Ansible,我有一个路径列表,要将其转换为新变量中的文件名列表,即: paths: - a/b/c/d.txt - e/f/g/h.txt 为此: filenames: - d.txt - h.txt 如何使用新变量将此调试打印设置为set\u fact指令 - name: "Show base name, but how to save the list?" debug: msg={{ item | basename }} loop: "{{ paths }}&q

我有一个路径列表,要将其转换为新变量中的文件名列表,即:

paths:
- a/b/c/d.txt
- e/f/g/h.txt
为此:

filenames:
- d.txt
- h.txt
如何使用新变量将此调试打印设置为
set\u fact
指令

- name: "Show base name, but how to save the list?"
  debug: msg={{ item | basename }}
  loop: "{{ paths }}"
我可以使用
map(regex\u replace)
,但我正在寻找一种不太老练的方法来实现这一点。谢谢

映射过滤器的基本名称。比如说

-设置事实:
文件:“{path | map('basename')| list}”
-调试:
var:文件
给予

文件:
-d.txt
-h.txt