【发布时间】:2021-07-12 11:43:44
【问题描述】:
如何找到给定文件,然后在其末尾添加几行?现在我有类似的东西
---
- name: Ansible find file and add some lines
hosts: localhost
tasks:
- name: find file
find:
paths: /etc
patterns: 'somefile.conf'
Ansible 找到了那个文件。下一步是什么?
【问题讨论】:
-
既然已经有了路径,为什么还要找文件呢?只需使用lineinfile。如果您有问题edit 提出问题并提出minimal reproducible example。
-
这个playbook要经过很多服务器,不知道路径会不会像“/etc/thisFile”一样