0

My ansible task exec successfully in shell command line, but when I add it to crontab, it failed with error "No authentication methods available"

* * * * * root ansible all -i /tmp/host -f 10 -m ping 2&1 1>/dev/null

any ideas? thanks a lot.

Cans404
  • 3
  • 1
  • Does [how to get `cron` to call in the correct paths](https://stackoverflow.com/questions/2388087/) answer your question? According it you may try with /usr/bin/ansible as well with correct and full environment settings. – U880D Nov 02 '21 at 21:36

1 Answers1

0

Finally, I get this issue solved. It just works after "--private-key=/root/.ssh/id_rsa" added explicitly.

I haven't figure out why it's not essential in command line while on the other hand, it cannot be absent in crontab.

* * * * * root ansible all -i /tmp/host -f 10 -m ping --private-key=/root/.ssh/id_rsa 2&1 1>/dev/null
Cans404
  • 3
  • 1