Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron module fails without error message #83223

Open
1 task done
jackfarzan opened this issue May 9, 2024 · 6 comments
Open
1 task done

Cron module fails without error message #83223

jackfarzan opened this issue May 9, 2024 · 6 comments
Labels
affects_2.16 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module.

Comments

@jackfarzan
Copy link

Summary

When I try to provision a cron job with the cron module, the task fails but doesn't give an error message.

Issue Type

Bug Report

Component Name

cron

Ansible Version

$ ansible --version                                                                                                                                                           
ansible [core 2.16.5]
  config file = None
  configured module search path = ['/home/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /home/jenkins/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

Configuration

$ ansible-config dump --only-changed -t all                                                                                                                                   
WARNING: terminal is not fully functional
Press RETURN to continue 
CONFIG_FILE() = None

OS / Environment

MacOS 13.2.1

Steps to Reproduce

    - name: "Implement daily tmp removal cron"
      ansible.builtin.cron:
        name: "rm tmp dirs"
        minute: "5"
        hour: "1"
        job: "rm -rf /Users/my-user/tmp-*"

Expected Results

I expect cron to be updated, or to return a useful error message.

Actual Results

fatal: [x.x.x.x]: FAILED! => changed=false 
  invocation:
    module_args:
      backup: false
      cron_file: null
      day: '*'
      disabled: false
      env: false
      hour: '1'
      insertafter: null
      insertbefore: null
      job: rm -rf /Users/my-user/tmp-*
      minute: '5'
      month: '*'
      name: rm tmp dirs
      special_time: null
      state: present
      user: null
      weekday: '*'
  msg: ''

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. affects_2.16 module This issue/PR relates to a module. labels May 9, 2024
@ansibot
Copy link
Contributor

ansibot commented May 9, 2024

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.

@flowerysong
Copy link
Contributor

flowerysong commented May 9, 2024

The only code path I see that could plausibly result in this is

if rc != 0:
self.module.fail_json(msg=err)

Does changing that line to self.module.fail_json(msg=err, stdout=out, rc=rc) provide any useful information?

@jackfarzan
Copy link
Author

Unfortunately not:

fatal: [10.32.239.40]: FAILED! => changed=false 
  invocation:
    module_args:
      backup: false
      cron_file: null
      day: '*'
      disabled: false
      env: false
      hour: '1'
      insertafter: null
      insertbefore: null
      job: rm -rf /Users/my-user/tmp-*
      minute: '5'
      month: '*'
      name: rm tmp dirs
      special_time: null
      state: present
      user: null
      weekday: '*'
  msg: ''
  rc: -9
  stdout: ''
  stdout_lines: <omitted>

I'm guessing it's crontab itself that isn't returning any useful error.

@jackfarzan
Copy link
Author

Having the rc is a little bit more useful than absolutely nothing though - can I make a PR?

@mkrizek
Copy link
Contributor

mkrizek commented May 14, 2024

Having the rc is a little bit more useful than absolutely nothing though - can I make a PR?

Sure, thanks!

@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label May 14, 2024
@jackfarzan
Copy link
Author

PR opened!

@ansibot ansibot added the has_pr This issue has an associated PR. label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.16 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module.
Projects
None yet
Development

No branches or pull requests

4 participants