Think before you speak, read before you think.

ansible-fetch获取服务器上的文件

by

in

目标是获取两台服务器下root,www用户的crontab文件,并保存在本地的fetched目录。

main.yml文件如下

– hosts: all
tasks:
– fetch: src=/var/spool/cron/www dest=fetched/cron-www-{{ ansible_hostname }} flat=yes

– fetch: src=/var/spool/cron/root dest=fetched/cron-root-{{ ansible_hostname }} flat=yes

执行完之后的目录结构如下

[root@jpuyy.com fetch-crontab]# tree
.
├── fetched
│   ├── cron-root-2.jpuyy.com
│   └── cron-www-1.jpuyy.com
├── hosts
└── main.yml


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *