Cron module does not properly set SELinux context for user crontabs

49 views
Skip to first unread message

Jeffrey Wen

unread,
Jan 19, 2017, 12:06:31 PM1/19/17
to Ansible Project
I am having the same issue inserting crons into the root user's crontab file according to this GitHub Issue

I am using ansible 2.3.0 ... so shouldn't my version include the commit that fixed this issue?

The exact error I am getting is:

fatal: [machine1]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 127.0.0.1 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File 
\"/tmp/ansible_TP4o_l/ansible_module_cron.py\", line 773, in <module>\r\n    main()\r\n  File \"/tmp/ansible_TP4o_l/ansible_module_cron.py\", line 741, in main\r\n    crontab.write()\r\n  Fil
e \"/tmp/ansible_TP4o_l/ansible_module_cron.py\", line 345, in write\r\n    selinux.selinux_lsetfilecon_default(self.cron_file)\r\nOSError: [Errno 14] Bad address\r\n", "msg": "MODULE FAILURE
"}

What is happening now
  1. The cron gets inserted into the root user's crontab & produces that error above
  2. I run the playbook again, and the error disappears (changes from fatal: to ok:)
  3. I check root user's crontab and the cron is there

Brian Coca

unread,
Jan 19, 2017, 3:48:19 PM1/19/17
to ansible...@googlegroups.com
2.3 has not been released yet, so it depends on which at commit your copy was pulled down from.


--
----------
Brian Coca

Jeffrey Wen

unread,
Jan 19, 2017, 4:46:04 PM1/19/17
to Ansible Project
Hi Brian,

I actually downgraded from 2.3.0 because my AUR repository did not have any newer updates.

I went to the stable release of 2.2.1 and my cron error is gone!
Reply all
Reply to author
Forward
0 new messages