Ansible filter with a few tools to handle with crontab string. Those tools are:
- aws_standard_cron
- standard_aws_cron
- aws_local_aws_utc_crons
- standard_local_utc_crons
- standard_local_utc_cron
Probably the filter will be only compatible with Python3.8 runtime due to dependecies.
- Add current year:
'10 10 * 10 2' | standard_aws_cron
'10 10 * 10 2 2021' # result
- 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
'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 * *"
]
'39 1 5 * *' | standard_local_utc_cron('Europe/Rome')
"39 23 4 * *" # result
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
This repo is part of my Cron-Converter projects group. Its related repositories: