[root@master ~]# ansible all -m cron -a ‘name="date" minute=*/3 hour=* day=* month=*
weekday=* job="/usr/sbin/ntpdate 10.0.0.28"‘
paramiko: The authenticity of host ‘master.test.com‘ can‘t be established.
The ssh-rsa key fingerprint is 3d906ef1d450e4cc7031aef5e8c296f6.
Are you sure you want to continue connecting (yes/no)?
agent.test.com | SUCCESS => {
"changed": false,
"envs": [],
"jobs": [
"date"
]
}
client02 | SUCCESS => {
"changed": false,
"envs": [],
"jobs": [
"date"
]
}
master.test.com | UNREACHABLE! => {
"changed": false,
"msg": "Authentication failed.",
"unreachable": true
}
[root@client01 tmp]# crontab -l
#Ansible: date
*/3 * * * * /usr/sbin/ntpdate 10.0.0.28
[root@client02 tmp]# crontab -l
#Ansible: date
*/3 * * * * /usr/sbin/ntpdate 10.0.0.28
删除刚才新建的定时任务
ansible all -m cron -a ‘name="date" state=absent‘
原文:http://blog.51cto.com/wujianwei/2082892