Unexpected Behavior from Cron Module

I noticed that the following task always results in a ‘changed’ message from my plays:

  • name: remove cron
    cron: cron_file=mycronfile state=absent

This appears to be due to this line in the cron module:

https://github.com/ansible/ansible/blob/devel/library/system/cron#L468

This seems odd to me–why not only report changed if a file was actually unlinked? If this is intentional, could someone explain the reason? Just want to understand why the modules are written the way they are.

I just took at look at this-I rewrote the cron module back in July-and it does look like a bug. I agree that when removing a cron_file the module should only report changed if the file was unlinked.

Bugs should be filed on github at github.com/ansible/ansible – please go ahead and file one.

Should be an easy fix :slight_smile:

Done: https://github.com/ansible/ansible/issues/4795