Discussion:
[ansible-project] Is Ansible the right tool for what I want to do?
Tim Skoch
2015-07-09 20:25:59 UTC
Permalink
I'm setting up a lab with a bunch of VMs, and each of these VMs will serve
one of a set of purposes (mostly servers). In setting up each one, I'm
keeping detailed notes of exactly what I have installed, configuration
changes I have made, etc. The setup process is tedious enough that even
with detailed notes, I'm not excited at the prospect of having to rebuild
one of these. Ideally I would like to be able to delete and quickly
rebuild a particular machine from the ground up as quickly as possible.

A friend recommended Ansible as the solution to this. I've been reading
the introduction docs, and it looks like Ansible is exactly what I have
been looking for - My Ansible "Playbooks/Plays/Tasks/Modules" would then *become
*my detailed notes, and I would get the added benefit of being able to
version them as well.

Here is what I *think* I want to do so far, but I want to make sure I'm
going down the right path before I get too far down it. Suppose for
example that I need two "Mailserver" type server VMs, one "Desktop" type
VM, and three "Database" servers. Each of those quoted "types" has its own
set of services which need to be set up, daemons configured, and various
other tweaks.

Am I correct that what I want to do here is set up one "Playbook", which
contains a "Play" for each of these types? And each of those "Plays" would
contain various tasks/modules to set the machine up in the desired
configuration? Do "Roles" come into play here? Maybe I need a "Role" for
each type, instead of a "Play"?

Thanks!
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/813b38c2-793b-4779-ba3b-394a033ef23d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Greg DeKoenigsberg
2015-07-10 14:35:04 UTC
Permalink
Post by Tim Skoch
I'm setting up a lab with a bunch of VMs, and each of these VMs will serve
one of a set of purposes (mostly servers). In setting up each one, I'm
keeping detailed notes of exactly what I have installed, configuration
changes I have made, etc. The setup process is tedious enough that even
with detailed notes, I'm not excited at the prospect of having to rebuild
one of these. Ideally I would like to be able to delete and quickly rebuild
a particular machine from the ground up as quickly as possible.
This is pretty much the ideal Ansible use case.
Post by Tim Skoch
A friend recommended Ansible as the solution to this. I've been reading the
introduction docs, and it looks like Ansible is exactly what I have been
looking for - My Ansible "Playbooks/Plays/Tasks/Modules" would then become
my detailed notes, and I would get the added benefit of being able to
version them as well.
Yep!
Post by Tim Skoch
Here is what I think I want to do so far, but I want to make sure I'm going
down the right path before I get too far down it. Suppose for example that
I need two "Mailserver" type server VMs, one "Desktop" type VM, and three
"Database" servers. Each of those quoted "types" has its own set of
services which need to be set up, daemons configured, and various other
tweaks.
Am I correct that what I want to do here is set up one "Playbook", which
contains a "Play" for each of these types? And each of those "Plays" would
contain various tasks/modules to set the machine up in the desired
configuration? Do "Roles" come into play here? Maybe I need a "Role" for
each type, instead of a "Play"?
You're spot on.

Roles are for reusability. Let's say those two Mailserver-type VMs end
up becoming many VMs, all with small differences between them. You
would build a single "mailserver" role and then you could invoke it
from different playbooks using different variables each time.

If I were in your shoes, I'd just run full speed ahead with playbooks.
Get comfortable with those, and then you can read up on roles and
refactor using them more heavily if you see fit.

Good luck!

--g
Post by Tim Skoch
Thanks!
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/813b38c2-793b-4779-ba3b-394a033ef23d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Greg DeKoenigsberg
Ansible Community Guy

Find out why SD Times named Ansible
their #1 Company to Watch in 2015:
http://sdtimes.com/companies-watch-2015/
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAM1FbhEC%2B3WE68iL5V03c45EcGE8R5neMStiV50yL6yogunPnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Toshio Kuratomi
2015-07-10 14:41:09 UTC
Permalink
Post by Tim Skoch
A friend recommended Ansible as the solution to this. I've been reading
the introduction docs, and it looks like Ansible is exactly what I have
been looking for - My Ansible "Playbooks/Plays/Tasks/Modules" would then
become my detailed notes, and I would get the added benefit of being able
to version them as well.
Yes, ansible (or config management software in general but on this list
we're mostly making ansible our choice for config management ;-) is a good
choice for this problem.
Post by Tim Skoch
Here is what I think I want to do so far, but I want to make sure I'm
going down the right path before I get too far down it. Suppose for
example that I need two "Mailserver" type server VMs, one "Desktop" type
VM, and three "Database" servers. Each of those quoted "types" has its own
set of services which need to be set up, daemons configured, and various
other tweaks.
Post by Tim Skoch
Am I correct that what I want to do here is set up one "Playbook", which
contains a "Play" for each of these types?

There are multiple ways to organize your tasks, plays, and playbooks but
this sounds like one reasonable way to do it. You may find it a little
better to have two levels of playbooks:

* a playbook that has a play for each type of vm that you're managing
* a master config playbook that includes the playbooks for each type of vm.

That is one way to make it possible to run the plays for each type of vm
separately (for instance when testing or when saving time on deploying a
change to just one type of vm) in some cases and together in others (when
making sure that your whole lab has the current config for instance)
Post by Tim Skoch
And each of those "Plays" would contain various tasks/modules to set the
machine up in the desired configuration?

Yes, exactly.

Here's a brief set of files that demonstrate that:

$ cat master.yml
---
- include: database.yml
- include: desktop.yml

$ cat database.yml
---
- hosts: db_hosts
tasks:
- command: "echo {{ ansible_hostname}}"

$ cat desktop.yml
---
- hosts: desktop_hosts
tasks:
- command: "echo {{ ansible_hostname}}"

$ cat inven
[db_hosts]
db01 ansible_ssh_host=127.0.0.2

[desktop_hosts]
desktop01 ansible_ssh_host=127.0.0.3

You can run all your plays via:
ansible-playbook -v -i inven master.yml

Or just the database plays like:
ansible-playbook -v -i inven database.yml
Post by Tim Skoch
Do "Roles" come into play here? Maybe I need a "Role" for each type,
instead of a "Play"?
You definitely can use roles here. They are intended for this level of
organizing your configs. However, it is not necessary if you want to take
your learning step-by-step. Compared to includes, roles give you the tools
to better generalize and encapsulate a set of tasks. I find this useful
when I want to mix and match a set of tasks with various machines.

For instance, I might have a common-software role that installed vim, tmux,
and zsh that I added to my plays for all of my machine types. Or a
student-account-system role that I added to any machine that students were
intended to login to but not to machines that were only for staff.

Hope this is helpful and remember, there's more than one way to organize
these things: someone else might be doing this in a different way that
makes more sense for you to emulate.

-Toshio
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAG9juEqir7FxYXkpctVskEY%2B-BGNOK%3DMd99cqYCF1iVOxo1uLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...