Sharing files in tasks between playbooks

683 views
Skip to first unread message

Vincent Van der Kussen

unread,
Apr 19, 2013, 3:23:32 PM4/19/13
to ansible...@googlegroups.com
Hi,

We are adding more and more systems and services under Ansible's control and it's fun and allows us to manage our environment in a much more efficient way.

Currently we have all playbooks in Ansible's top dir but imho this is will make the overview of the top dir's content less clear ( i like clean things). I would also like to have our playbooks to be "portable" so we can tar them so other people can reuse them. Of course if we link to things outside of the playbook folder it would become a dependency to run that playbook.

So I tried to put playbooks in a "playbooks" dir under the top dir but I ran in the following problem:

I've included a task in a playbook which copies a file to the target machine but it doesn't work because the file is located outside of the playbook's dir and therefore not relative to the playbook's dir

structure :
-------------

./playbooks/myplay/play.yml

./common/tasks/task.yml
./common/files/file.txt

- in the playbook i have this :

tasks:¬
- include: ../../common/tasks/task.yml¬

- The task contains this :

name: copy file
- action: copy src="../files/file.txt" dest="/tmp"
 

When i run the play.yml i get the following :

msg: could not find  src=playbooks/myplay/common/files/file.txt


As far I can see the base dir is relative to the playbook which makes it rather hard to accomplish this kind of things.

Any suggestions?

Thanks
Vincent


Michael DeHaan

unread,
Apr 19, 2013, 4:12:24 PM4/19/13
to ansible...@googlegroups.com
Have you looked into using roles?

They are designed to be redistributable and have some improvements to relative pathing inside them when you use them.




--
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-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Vincent Van der Kussen

unread,
Apr 20, 2013, 1:57:04 AM4/20/13
to ansible...@googlegroups.com

Hi Michael,

Haven't looked at roles yet. But that might be the way to go.

Thanks for replying

Vincent

Reply all
Reply to author
Forward
0 new messages