Execute CRUD (Raw SQL) from Rundeck

950 views
Skip to first unread message

Laurentius Purba

unread,
Jul 17, 2016, 12:29:38 PM7/17/16
to rundeck-discuss
Hello all,

I was wondering if it's possible to perform CRUD either by uploading sql file or typing SQL statement in textbox from Rundeck.

Any helps is appreciated.

Thanks!
-Laurentius

Ievgen Aleinikov

unread,
Jul 21, 2016, 10:06:25 AM7/21/16
to rundeck-discuss
I don't think rundeck supports it natively (which sql server?, which standard?)

I use python wrapper to execute sql scripts towards mysql.

Laurentius Purba

unread,
Jul 25, 2016, 9:44:13 PM7/25/16
to rundeck-discuss
Ievgen,

Thanks for you response.

Do you mind sharing your workflow on how to implement this? Do you think the following workflow will work:
  • Upload an SQL file to Host A
  • From Rundeck, copy that sql file from Host A to Rundeck
  • Run script that will execute that sql file.

Fred Ellenberger

unread,
Jul 26, 2016, 12:35:18 AM7/26/16
to rundeck-discuss
One way I have managed such scenarios as below is to keep a "repository" of files on the Rundeck server (it can be a Git repo etc) that I can selectively copy to a remote node and execute.  So for the example below, you could copy sql fils(s) to a remote node, then use a remote command or script to execute the SQL, and optionally 'cat' the results if you want to be able to review the results of the operation (ddl/dml update) within the Rundeck logs themselves.  I wouldn't necessarily suggest that you 'cat' a large sql result file.

If you want to be able to fail the rundeck job if the SQL does not run successfully, you could add some job steps after SQL execution to parse the sql log for "common" SQL execution errors (i.e. for Oracle, search for "ORA-", etc).

The best way to detect error, however, is if the program you are executing (i.e. sqlplus for Oracle) can return a non-zero status code, which will automatically fail the Rundeck job.

Many ways to skin this cat, and the flexibility is nice...

-Fred
Reply all
Reply to author
Forward
0 new messages