Skip to content

Latest commit

 

History

History
318 lines (282 loc) · 11.9 KB

community.missing_collection.cron_info_module.rst

File metadata and controls

318 lines (282 loc) · 11.9 KB

community.missing_collection.cron_info

Get Information from Crontab.

Version added: 0.4.0

The below requirements are needed on the host that executes this module.

  • python-crontab
  • re
Parameter Choices/Defaults Comments
get_crons_by_command
boolean
    Choices:
  • no
  • yes
get list of cron which matches to match_string command and given user/tabfile.
get_crons_by_comment
boolean
    Choices:
  • no
  • yes
get list of cron which matches to match_string comment and given user/tabfile.
get_crons_by_time
boolean
    Choices:
  • no
  • yes
get list of cron which matches to match_string time and given user/tabfile.
list_all_crons
boolean
    Choices:
  • no
  • yes
get list of all crons for given user/tabfile.
match_string
string
it can be a string.
it can be regex when use_regex.
schedule
string
cron schedule pattern and used when validate_cron_time.
example 4 16 * * *
tabfile
string
crontab file location on system.
mutually exclusive to user.
use_regex
string
filter crons based on python regex.
can be used when get_crons_by_command and get_crons_by_comment.
user
string
Default:
"dpal"
crontab user.
mutually exclusive to tabfile.
validate_cron_time
boolean
    Choices:
  • no
  • yes
validate cron schedule or time format?

- name: get all crons for dpal user
  community.missing_collection.cron_info:
    list_all_crons: true
    user: 'dpal'

- name: get all crons by command for dpal user (python command)
  community.missing_collection.cron_info:
    get_crons_by_command: true
    user: 'dpal'
    match_string: '.py'

- name: get all crons by comment for dpal user
  community.missing_collection.cron_info:
    get_crons_by_comment: true
    user: 'dpal'
    match_string: 'python'

- name: get all crons by time for dpal user
  community.missing_collection.cron_info:
    get_crons_by_time: true
    user: 'dpal'
    match_string: '4 16 * * *'

- name: check if given crontime is valid or not
  community.missing_collection.cron_info:
    validate_cron_time: true
    schedule: '2 14 * * *'

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
cron
list
when success and not validate_cron_time.
list of the cron jobs

Sample:
[{'command': 'ls -alh > /dev/null', 'comment': 'check dirs', 'enabled': True, 'marker': 'Ansible', 'slices': '0 2,5 * * *', 'special': False, 'user': 'None', 'valid': True}]
valid
boolean
when validate_cron_time and success.
validate given cron schedule/time.

Sample:
True


Authors