Noob Question: Automating Playbook Execution

This isn't an exact answer to your question, but hopefully it can
provide you with some ideas.

We're using Jenkins[*] as a front-end to ansible. Playbooks are
wrapped in Jenkins jobs, which allow us to schedule and remotely
trigger the playbooks, or have them run automatically on VCS
commits, or in response to some other job, like a successful
software build. Using Jenkins also allows us to capture run times,
do fancy trending and reporting, trigger other tasks based on the
results of a playbook run, and do all the other approximately 5
billion things for which Jenkins plugins exist. (Seriously, Jenkins
is pretty much the best thing ever.) Finally, ansible compliments
Jenkins nicely, because it allows us to trivially do things like
distribute build artifacts to mutliple clusters of app servers
simultaneously.

(Incidentally, I'm also using Jenkins to control our puppet
infrastructure; the pupetmaster setup that puppetlabs recommends is,
frankly, absurd, but we have too much invested in puppet manifests
and modules to throw it away. Our nodes are managed via multiple
geograpically-distributed Jenkins slaves, controlled by a single
master, which communicate over ssh, much like ansible. Honestly, if
ansible existed when I started designing this infrastructure, I'd
likely be triggering puppet runs from playbooks, via jenkins!)

  [*]: http://jenkins-ci.org/

* Trevor Squillario <tsquillario at gmail.com> [2012/08/31 12:58]:

I am currently trying to run integrate ansible runs through jenkins. If i use the --extra-vars option of ansible in the execute shell part of the jenkins job, extra quotes are added around it and ansible fails to read the values of extra-vars which renders my playbook unusable.

I would like to know how you got around this issue ?

It’s entirely possible that Jenkins is stripping the quotes prior to execution. You may want to try single vs double in this situation. Also, if you’re passing complex data to the playbook in this way you’ll need to use JSON which is going to have it’s own set of nested quoting fun. If that is the case, you may want to try passing in your variables via a separate file a la --extra-vars "@variables.json". Even if Jenkins strips off the quotes in this case the @ will not be interpreted by the shell as a special character and execution should proceed.

I think you might find the answer here: https://groups.google.com/forum/#!topic/ansible-project/wzG5BMC7h_w