如何使用 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
但是我收到的输出是 - 仅创建了 1 个文件夹,如下所示
/tmp/destination/test?hello?world
- name: It is a test yml
file:
dest: "/tmp/destination/{{ item }}"
state: directory
with_lines: cat /tmp/stuff.yml
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句