gpt4 book ai didi

ansible - 模板模块可以处理多个模板/目录吗?

转载 作者:行者123 更新时间:2023-12-04 16:15:56 25 4
gpt4 key购买 nike

我相信 Ansible copy module可以获取一大堆"file"并一次复制它们。我相信这可以通过递归复制目录来实现。

可以 Ansible template module获取一大堆"template"并一次性部署它们?是否存在部署模板文件夹并递归应用它们的事情?

最佳答案

template模块本身对单个文件运行操作,但您可以使用 with_filetree在指定路径上递归循环:

- name: Ensure directory structure exists
file:
path: '{{ templates_destination }}/{{ item.path }}'
state: directory
with_filetree: '{{ templates_source }}'
when: item.state == 'directory'

- name: Ensure files are populated from templates
template:
src: '{{ item.src }}'
dest: '{{ templates_destination }}/{{ item.path }}'
with_filetree: '{{ templates_source }}'
when: item.state == 'file'

对于单个目录中的模板,您可以使用 with_fileglob .

关于ansible - 模板模块可以处理多个模板/目录吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41667864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com