user parameter shouldn't be required when adding a variable with cron_file set on cron module
Author: mhalanoCreated Jul 29, 2024Updated Sep 6, 2026
LabelsmodulebugP3affects_2.17
Summary
Using the cron module, when I try to add an environment variable to a file under /etc/cron.d, it requires me to set user parameter, even user isn't present in the added line.
Set user makes sense in the jobs because under /etc/cron.d the user that will execute couldn't be the same as root, but since when adding an environment variable the user doesn't matter, shouldn't be mandatory.
Issue Type
Bug Report
Component Name
cron
Ansible Version
ansible [core 2.17.1]
config file = None
configured module search path = ['/Users/marcos.alano/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/10.1.0/libexec/lib/python3.12/site-packages/ansible
ansible collection location = /Users/marcos.alano/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.12.4 (main, Jun 6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/Cellar/ansible/10.1.0/libexec/bin/python)
jinja version = 3.1.4
libyaml = True
Configuration
CONFIG_FILE() = None
PAGER(env: PAGER) = less
OS / Environment
Target OS: Ubuntu 20.04.5
Steps to Reproduce
- name: Add path for ansible-pull entry
ansible.builtin.cron:
name: PATH
env: true
job: /usr/local/bin:$PATH
cron_file: ansible-pull
Expected Results
No errors.
Actual Results
TASK [Add path for ansible-pull entry] *****************************************
FAILED! => {"changed": false, "msg": "To use cron_file=... parameter you must specify user=... as well"}
Code of Conduct
- I agree to follow the Ansible Code of Conduct
Source: ansible/ansible