Skip to content

user parameter shouldn't be required when adding a variable with cron_file set on cron module #83682

@mhalano

Description

@mhalano

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Priority 3 - Approved, No Time Limitationaffects_2.17bugThis issue/PR relates to a bug.has_prThis issue has an associated PR.moduleThis issue/PR relates to a module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions