Open lucymhdavies opened 3 years ago
I'm actually doing this for the moment, so I can pre-populate crons based on one global cron file:
ok check "crontab -l"
if check_failed && satisfying; then
ok check "crontab ~/git_src/dev_utils/cron/crontab"
fi
I'll worry about per-box crons when it becomes a problem (and maybe submit a PR to Bork to add the feature)
Note to future self: look at the way Ansible does this. It puts a specific known-format comment above the cron line to keep track of it. Maybe bork could do something similar?
This works better than my version from https://github.com/borksh/bork/issues/20#issuecomment-817173654
ok check "diff -q <(crontab -l) $DEV_UTILS_DIR/cron/crontab"
if check_failed && satisfying; then
ok check "crontab $DEV_UTILS_DIR/cron/crontab"
fi
Actually does a proper diff of the current crontab and the crontab file.
Short term, I'm thinking combining a bunch of files, then doing a diff.
That's a good idea. For the actual type, though — for the purposes of keeping the types idempotent and stateless — I think we will just have to write out each individual crontab line as its own ok cron
assertion, and Bork can check if there is anything like it in your crontab (and add it if not). I believe you can pipe stuff into crontab -
so that might be the way (though would need to be careful about making sure we are appending to the crontab instead of replacing it wholesale…)
Something which would be useful:
I can do stuff myself with something like:
but given I probably want to merge a bunch of crons together... something within bork to handle this would be useful