Hi,
I am trying to find a suitable directory structure for my ansible files. I 
have come up with this structure which is not working with the playbooks in 
subdirectories:

.
├── group_vars
├── inventories
│   ├── production
│   │   ├── group_vars
│   │   │   └── all.yml
│   │   └── inventory
│   └── vagrant
│       ├── group_vars
│       │   └── all.yml
│       └── inventory
├── playbooks
│   ├── net1
│   │   └── dnsdhcp.yml
│   ├── net2
│   │   └── dnsdhcp.yml
│   └── update.yml
├── roles
│   ├── dnsmasq
│   ├── bind9
│   └── isc-dhcp
├── playbooks
└── Vagrantfile

In the group_vars for the inventories I have variables which differ between 
the real servers and my vagrant test vms (IP addresses, domain names), this 
is working fine.

Then I would like to organize the playbooks into subdirectories so I don't 
wind up with a directory with dozen of playbooks. The root group_vars 
variables would then define the project wide configuration which can be 
used by multiple playbooks.

For example if I have two subnetworks and I need a DHCP server on each 
(possible different programs), I would write a playbook for each which 
installs the server (using roles) and put them in different subdirectories.

Then I have the master file which includes most playbooks. This file could 
be used to run ansible every day with a cron job.

The problem is that the group_vars are relative to the current running 
playbook, so I can't run 

ansible-playbook -i inventories/vagrant/inventory playbooks/net2/dnsdhcp.yml

One way would be to flatten out the hierarchy in the playbooks directory 
and put a symlink to the root group_vars directory in the playbooks 
directory:

.
├── group_vars
├── playbooks
│   └── group_vars -> ../group_vars
│   ├── net1-dnsdhcp.yml
│   ├── net2-dnsdhcp.yml
│   ├── update.yml

But then I would have to prefix the files for different subnets and would 
have one directory with many playbooks.



Is this a good way to organize the playbooks? I'm not sure if I understand 
the purpose of the playbooks correctly, am I putting the right plays in the 
playbooks or should I organize the plays in an other way into playbooks?

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/587c55ac-a9dd-436d-85b0-d5118e737eaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to