pyinfra
pyinfra copied to clipboard
Crontab fact can't handle same command in multiple entries
I noticed that Crontab uses the following data structure. If a command appears twice, the old entry will get overwritten. It may has something to do with #1189, but I'm not sure
class Crontab(FactBase[Dict[str, CrontabDict]]):
"""
Returns a dictionary of cron command -> execution time.
.. code:: python
{
"/path/to/command": {
"minute": "*",
"hour": "*",
"month": "*",
"day_of_month": "*",
"day_of_week": "*",
},
"echo another command": {
"special_time": "@daily",
},
}
"""
Proposal: use the new data structure
{
"entries": [
{
"env": "CRON_TZ",
"value": "UTC"
},
{
"command": "/path/to/command",
"minute": "*"
},
{
"command": "echo another command",
"special_time": "@daily",
},
],
"/path/to/command": {
"minute": "*",
"hour": "*",
"month": "*",
"day_of_month": "*",
"day_of_week": "*",
},
"echo another command": {
"special_time": "@daily",
},
}
and deprecate old structure