An open API service indexing awesome lists of open source software.

https://github.com/springerpe/cron-script-repository-boshrelease

A BOSH release that is intended to be like a repository for your cronjob scripts
https://github.com/springerpe/cron-script-repository-boshrelease

Last synced: 7 months ago
JSON representation

A BOSH release that is intended to be like a repository for your cronjob scripts

Awesome Lists containing this project

README

          

# bosh-cron-script-repository
A BOSH release that is intended to be like a repository for your cronjob scripts

# Intro
This release gives the option to add scripts as cronjobs, each with its own schedules.

We are aware that there are other options (like https://github.com/cloudfoundry-community/cron-boshrelease), but they
don't allow to properly modularize the cron scripts.
This means that they are not made to manage cron scripts if the scripts are too long.

This release copies the scripts under `jobs/cronscript/templates/scripts` into the BOSH instance where it is being
deployed and adds an entry to a cron-schedule file so that they can be executed.

# How to use
In order to use this release, you will need to manually add the scripts into it.

For that, there are 3 steps:

1) Add the scripts to the `jobs/cronscript/templates/scripts` folder
2) Add the schedules to the `jobs/cronscript/templates/schedules` folder
3) Add a new property to the spec file.

## Adding the scripts
All you need to do is to copy your script into the `jobs/cronscript/templates/scripts` folder.
Then the release will copy the scripts into `$JOB_DIR/scripts` and make them executable.

## Scheduling the cron jobs
To add cron entry with your script, you will need to create a file under `jobs/cronscript/templates/schedules` with
*the same name* as your script. This file can only contain 1 line, which will be the cron schedule that you want for
that cron job.

If you want to make that configurable (which will probably will be a good idea), you need to add an entry to the spec
file with your chron schedule.
Then you can read that property in the schedule file, like:
`<%= p("schedules.hello") %>`

## Creating the new bosh release

After adding the scripts and the cron schedules to the release, you will need to create your own version of the release.

For that, all you need to do is:

* execute `bosh create-release --force` from within the release folder in order to create a new version of the release
* `bosh upload-release` to upload the release into BOSH. This is the step that allows you to use your own release
version

# Adding the release into your deployment
To add the release into your deployment, just create an operation file like
```
- type: replace
path: /releases/-
value:
name: cron-script-repository
version: YOUR CUSTOM VERSION
sha1: YOUR CUSTOM SHA1

- type: replace
path: /instance_groups/name=kibana?/jobs/-
value:
name: cronscript
release: cron-script-repository
properties:
schedules:
hello: '11 * * * *'
```