By default, ansible looks for tasks in $PWD. tasks are sent to the
remote host, and don't run local.
If you create ansible.cfg in $PWD, and override defaults.library, then
you can have local modules; these run on the local machine.
The following works when ansible is installed thru a package manager(I
use debian):
cat $work_tree/ansible.cfg
==
[defaults]
library = /home/adam/code/$shared_ansible_repo/library:/usr/share/ansible
roles_path = /home/adam/code/$shared_ansible_repo/roles
==
On 05/14/2014 04:07 PM, Michael Peters wrote:
I feel like I'm missing something, but I couldn't find it in the
documentation. Please feel free to RTFM me.
I was just playing around with the pause module in a playbook and
noticed that it only ran on a single host no matter how many hosts
were being executed in the play. That makes sense because pausing on
multiple machines would just be silly.
The real question is how do I do that explicitly in my own tasks? I
have a lot of places in playbooks where I have data that needs to be
inserted on some centralized storage (like a database or files on an
NFS server, etc). At best this data is pointless to insert/update
multiple times. And most of the time it's difficult to make sure it's
done in a idempotent way (think ALTER statements in SQL migrations).
Currently I deal with this by breaking up my playbook into multiple
plays where most of the tasks are in parallel, then another play is
done in serial with just 1 host at a time with some pre-condition
checks to see if it needs to be run and skipping it when it doesn't.
This has the effect of the first host through the serial section does
the work and every other host gets a turn to waste cycles checking
that it actually happened. Then after the "critical section" is done
the rest of the tasks are done in a parallel play.
If I could just explicitly label a task as "just run this on the first
server in the group" like the pause module does I'd be really happy.
--
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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/5373DE76.9090803%40brainfood.com.
For more options, visit https://groups.google.com/d/optout.