Skip to content

Sonic0/local-crontab-ansible-filter

Repository files navigation

local-crontab-ansible-filter

Ansible filter with a few tools to handle with crontab string. Those tools are:

  1. aws_standard_cron
  2. standard_aws_cron
  3. aws_local_aws_utc_crons
  4. standard_local_utc_crons
  5. standard_local_utc_cron

Probably the filter will be only compatible with Python3.8 runtime due to dependecies.

Examples

standard_aws_cron

  1. Add current year:
    '10 10 * 10 2' | standard_aws_cron
    '10 10 * 10 2 2021' # result
  2. Add year and convert '*' in '?' in the right position, from aws_specific_details structure
       aws_specific_details:
          year: 2022
          question_parts: [ 'day' ] # minute, hours, day, etc..
    
       '10 10 * 10 2' | standard_aws_cron(aws_specific_details)
       '10 10 ? 10 2 2022' # result

aws_local_aws_utc_crons

'39 05 * * ? *' | aws_local_aws_utc_crons('Europe/Rome')
# result
[
    "39 4 * 1-2 * *",
    "39 4 1-27 3 ? *",
    "39 3 28-31 3 ? *",
    "39 3 * 4-9 * *",
    "39 3 1-30 10 ? *",
    "39 4 31 10 ? *",
    "39 4 * 11-12 * *"
]

standard_local_utc_cron

'39 1 5 * *' | standard_local_utc_cron('Europe/Rome')
"39 23 4 * *" # result

More examples in filter-example.yaml file.

Test filters

Look at the ansible playbook in the root project and run it! I have made my tests with Ansible 2.9.

ansible-playbook filter-examples.yaml

Other info

This repo is part of my Cron-Converter projects group. Its related repositories:

About

Ansible filter to convert localized cron to UTC.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages