目标是获取两台服务器下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
执行完之后的目录结构如下
[[email protected] fetch-crontab]# tree
.
├── fetched
│ ├── cron-root-2.jpuyy.com
│ └── cron-www-1.jpuyy.com
├── hosts
└── main.yml
Leave a Reply