我知道Ansible fetch-module可以将文件从远程复制到本地,但是如果我只需要将内容(在我的例子中是保存IP地址的tmp文件)附加到本地文件中,该怎么办?
获取模块执行以下操作:
- name: Store file into /tmp/fetched/
ansible.builtin.fetch:
src: /tmp/somefile
dest: /tmp/fetched
我需要它来做这样的事情:
- name: Store file into /tmp/fetched/
ansible.builtin.fetch:
src: /tmp/somefile.txt
dest: cat src >> /tmp/fetched.txt
1条答案
按热度按时间50few1ms1#
简而言之:
注:
shell
来执行第二个任务:或者,您可以一次性写入从所有目标获取的所有文件的所有内容,以避免并发问题并节省一些时间。