Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 lineinfile 在文件中添加多个主机详细信息,但某些详细信息相同,只是主机不同。我正在寻找一种方法来防止 lineinfile 跳过同一行。那可能吗 ?
如果您希望在添加之前验证是否存在线条,也许这会起作用。正则表达式是要搜索的字符串,如果该行已经存在,则将状态设置为不存在以删除。
--- - hosts: localhost tasks: - name: Check if it is the file become: yes tags: example lineinfile: path: /path/to/file regexp: "Hello World" state: absent backup: yes