Using RunDeck to automatically version control RunDeck changes

15. September 2015 00:30 by Jay Grossman in   //  Tags: , ,   //   Comments (0)

I am big fan of the open source project RunDeck (a.k.a. My Cron Sprawl Killer). I use it on multiple personal projects and have put it in production at my day job (at Rent the Runway).

Rundeck is great when you need something to centralize scheduled jobs, handle multi-step jobs across servers/platforms, or a way to expose common automation tasks. I have quite a bit of experience with Control-M (enterprise solution to solve same problems from BMC) and I prefer Rundeck ease of use/low learning curve.

What is RunDeck

Rundeck is open source software that helps you automate routine operational procedures in data center or cloud environments. Rundeck provides a number of features that will alleviate time-consuming grunt work and make it easy for you to scale up your automation efforts and create self service for others. Teams can collaborate to share how processes are automated while others are given trust to view operational activity or execute tasks.

Rundeck allows you to run tasks on any number of nodes from a web-based or command-line interface. Rundeck also includes other features that make it easy to scale up your automation efforts including: access control, workflow building, scheduling, logging, and integration with external sources for node and option data.

What is the problem I want to solve

RunDeck's web interface makes it really easy for non-tech folks to make changes, such setting up projects and jobs. Since scheduled jobs are pretty important, I want a version history for changes and need an easy way to restore the system.

I use the Linux version installed with the RPM (as opposed to the launcher option). I found that:

  • the system level configuration is stored in /etc/rundeck
  • the project definitions are stored in /var/rundeck/projects
  • the job definitions can be exported as xml files

I'd love to be able to automatically keep version history for these sets of files in Git.

Using RunDeck to save RunDeck changes in GitHub

First I set up a GitHub repo that would store these 3 types of configuration:


Then I created a job in my RunDeck instance:


The job is scheduled the following command task every hour on the RunDeck server:

  ### Call the RunDeck API to get list of projects 
  curl ${RUNDECK_URL}:4440/api/13/projects?authtoken=${RUNDECK_API_TOKEN}>projects.xml
  projectlist=$(cat projects.xml | grep name | sed "s/<name>//g" sed "s/<\/name>//g")
  ### Save each project to xml file in jobs directory
  for project in $projectlist; do
      echo "the next file is $project"
      rd-jobs list -p $project --file /var/rundeck/jobs/$project.xml
  ### Copy RunDeck system configuration files to config directory
  cp -rf /etc/rundeck/*.* /var/rundeck/config/
  ### Sync to GitHub
  cd /var/rundeck
  DATETIMESTAMP="$(date +"%Y.%m.%d.%H%M")"
  git commit -am "pushing from rundeck ${DATETIMESTAMP}"
  git push origin master


PLEASE NOTE: You'll need to set the ${RUNDECK_URL} and ${RUNDECK_API_TOKEN} variables. 


About the author

Jay Grossman

techie / entrepreneur that enjoys:
 1) building software projects/products
 2) digging for gold in data
 3) rooting for my Boston sports teams:New England PatriotsBoston PatriotsBoston Red SoxBoston CelticsBoston Bruins

Month List