Running playbook from a cron jobs fails

252 views
Skip to first unread message

Uwe Kruse

unread,
Jan 26, 2016, 9:35:13 AM1/26/16
to Ansible Project, uwe....@oediv.de
Hello, i try to run an ansible playbook every day and i use cron. 
i get the following error:

+ sshpass -p xxxxxxxxx ansible-playbook -i all_actual_sp3_hosts.txt uk_key.yml --ask-pass -c paramiko
Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 323, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/bin/ansible-playbook", line 112, in main
    utils.check_mutually_exclusive_privilege(options, parser)
AttributeError: 'module' object has no attribute 'check_mutually_exclusive_privilege'
+ ansible-playbook -i all_actual_sp3_hosts.txt paketliste.yml
Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 323, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/bin/ansible-playbook", line 112, in main
    utils.check_mutually_exclusive_privilege(options, parser)
AttributeError: 'module' object has no attribute 'check_mutually_exclusive_privilege'
+ ansible alle -i all_actual_sp3_hosts.txt -m setup --tree /home/kruseu/setup
Traceback (most recent call last):
  File "/usr/bin/ansible", line 195, in <module>
    (options, args) = cli.parse()
  File "/usr/bin/ansible", line 86, in parse
    utils.check_mutually_exclusive_privilege(options, parser)
AttributeError: 'module' object has no attribute 'check_mutually_exclusive_privilege'
?

When i run it in a ssh-session everything works fine.

What can i do to run the playbook inside a cron job?

Ansible runs in a Ubuntu 14.04 system. The ansible version is 1.9.0.1-1.

Greetings Uwe Kruse



Message has been deleted

Abhishek R.

unread,
Jan 26, 2016, 1:55:27 PM1/26/16
to Ansible Project, uwe....@oediv.de
Perhaps you should provide the details of the playbook as well here. There are many possibilities. For example, this can happen due to the ssh user in the cron. When you run the playbook in a ssh session, you are running with you as the logged-in user. The cron user must have similar privileges on the remote host (if you are using passwordless ssh setup, for instance) for it to succeed.

Regards

Uwe Kruse

unread,
Jan 27, 2016, 2:25:30 AM1/27/16
to Ansible Project, uwe....@oediv.de
Hello,  i tried some playbook runs with an without paramiko. There ist always the same problem and i think that the module ansible-playbook has th root cause. I use the same user in the ssh and the cron session so the privileges on the remote host are the same. May be my local environment is not the same in an cron session. Which parameter of my online environment can be so important?
Regards Uwe

Brian Coca

unread,
Jan 27, 2016, 2:35:50 PM1/27/16
to Ansible Project, uwe....@oediv.de
check the python path
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d031bcc8-84eb-4208-a4ac-67419b68738f%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Uwe Kruse

unread,
Feb 1, 2016, 7:18:35 AM2/1/16
to Ansible Project, uwe....@oediv.de
Hello, the problem was that i had different Versions of ansible installed on the system. One with python pip and one with apt. I removed all ansible packages and did a fresh install.
Then everything was ok. Thank you, Uwe
Reply all
Reply to author
Forward
0 new messages