【发布时间】:2023-02-10 20:05:00
【问题描述】:
我知道有 ansible.builtin.blockinfile 存在。我可以用它在文件中插入一段文本,但文本应该作为任务中的“块”提供。是否可以使用文件作为“块”的来源? IE。:
- name: create/update somefile.config
ansible.builtin.blockinfile:
path: /home/user/something/configuration.yaml
insertbefore: "someline:"
block: something/configuration.yaml
something/configuration.yaml 是一个文件
【问题讨论】:
-
看来你明白你可以“插入一段文字”.你想从文件中插入一些东西配置.yaml.该文件的内容似乎是 YAML。 YAML 应该如何格式化为文本?发布文件的内容和预期的文本块。参见minimal reproducible example。
标签: ansible ansible-2.x