Rundeck - Optionally execute step depending on sql query result

Viewed 296

I'm very new to rundeck and I was asked to insert something (a step or I really don't know what) to check if the data for a job are up to date (a sql script can provide me a date or a parameter). Depending on this condition, the job can start or not. I've been surfing on the web for days but didn't find out any answer. Could you please help me?

1 Answers

On Rundeck Enterprise you can use the Ruleset Workflow Strategy to decide if some job or step runs or not based on an option or data value (Check this example related to data values) generated from your SQL query.

The best approach on the Community version is to use an inline-script step that calls the job whichs contains your step using RD-CLI or Rundeck API (using cURL). Check this example about how to call a job from inline-script step using RD-CLI.

You can write a script like:

if [ @data.your_data_value@ = 'available' ]; then
    rd run -p YourProjectName -j YourJobToCall
else
    echo "Not available, nothing to do"
fi

Of course if you don't want to call another jobs you can create an inline-script step with all logic inside, something like:

if [ @data.your_data_value@ = 'available' ]; then
    # step logic
else
    echo "Not available, nothing to do"
fi

So, the idea is to create the first step with your SQL call wichs generates data (check this too), and then a second step that gets that data and decides on an inline script step.

Related