Re: [ansible-project] Noob Question: Automating Playbook Execution

429 views
Skip to first unread message

Mark Theunissen

unread,
Aug 31, 2012, 4:22:25 PM8/31/12
to ansible...@googlegroups.com
You can make a playbook that includes other playbooks, so you only have to run one to have them all execute.

You can also have the ntp, sshd, etc. divided into tasks files, and then include those tasks into a single playbook using tags. Then, you can call the main playbook using --tags='ntp' if you just want to run the ntp portion.

And... you can also tag entire playbooks, so you can combine the above two options - have a playbook include other playbooks and tag those.

The best thing is to look at the examples:


- Mark



On Fri, Aug 31, 2012 at 2:58 PM, Trevor Squillario <tsqui...@gmail.com> wrote:
I'm coming from a Puppet mindset where nodes checkin and actions are performed if they are out of spec. With ansible you execute playbooks using the ansible-playbook command, I understand that much.

Say you have many playbooks for various purposes (ntp, sshd, nginx, etc.) how do you automate the execution of those playbooks. Do you have to run each one manually after it's modified? I do realize they are idempotent and can be run multiple times. I just thought maybe there was a better way to automate this process. Is the Pull-Mode the best way to achieve this?

Mark Theunissen

unread,
Aug 31, 2012, 4:24:57 PM8/31/12
to ansible...@googlegroups.com
But yes, there is a pull mode too, I haven't personally used that, as I prefer firing off the final command myself and watching exactly what's happening on each host.

Darren Chamberlain

unread,
Aug 31, 2012, 7:12:41 PM8/31/12
to ansible...@googlegroups.com
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'm coming from a Puppet mindset where nodes checkin and actions
> are performed if they are out of spec. With ansible you execute
> playbooks using the ansible-playbook command, I understand that
> much.
>
> Say you have many playbooks for various purposes (ntp, sshd,
> nginx, etc.) how do you automate the execution of those playbooks.
> Do you have to run each one manually after it's modified? I do
> realize they are idempotent and can be run multiple times. I just
> thought maybe there was a better way to automate this process. Is
> the Pull-Mode the best way to achieve this?

--
Darren Chamberlain <dar...@boston.com>

Wojciech Hajduczenia

unread,
Feb 6, 2014, 7:26:28 AM2/6/14
to ansible...@googlegroups.com
Darren Chamberlain,
i would appreciate for any kind of tutorial how you can wrap ansible playbooks within jenkins environment
including any necessary initial setup to hosts/machine that operates jenkins and some simple scripts to test if it works.

Thanks in advance

Naween Ghimire

unread,
Sep 20, 2014, 4:14:58 PM9/20/14
to ansible...@googlegroups.com, dar...@boston.com
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 ?

Garrett Plasky

unread,
Sep 21, 2014, 1:44:43 PM9/21/14
to ansible...@googlegroups.com, dar...@boston.com
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.

Dan Vaida

unread,
Nov 9, 2014, 6:59:24 AM11/9/14
to ansible...@googlegroups.com, dar...@boston.com
Reply all
Reply to author
Forward
0 new messages