如何使用ansible创建目录,其中目录名称应来自其他文件
我尝试使用with_file命令并没有太大帮助
-bash-4.2$ cat main.yml
---
- name: It is a test yml
file:
dest: "/tmp/destination/{{ item }}"
state: directory
with_file:
- "/tmp/stuff.yml"
-bash-4.2$ cat /tmp/stuff.yml
test
hello
world
预期输出为-3个文件夹,如下创建
/tmp/destination/test
/tmp/destination/hello
/tmp/destination/world
但是我收到的输出是-仅创建了一个如下所示的文件夹
/tmp/destination/test?hello?world
答案 0 :(得分:0)
- name: It is a test yml
file:
dest: "/tmp/destination/{{ item }}"
state: directory
with_lines: cat /tmp/stuff.yml