I'm looking for advice about how to organize my playbooks. Not so much the content as their structure on the file system.
Currently I have all of my configuration management (role-level) playbooks at the top level with things like common.yml, app.yml, db.yml, etc. These correspond directly to roles and are pretty much just like the examples in http://docs.ansible.com/playbooks_best_practices.html#directory-layout (along with a site.yml to run through them all for the whole cluster). But I also have a bunch of playbooks for doing various things like rolling upgrades of certain applications, updating configurations of other applications, creating DB snapshots and replication, AWS server creation, etc. I've started to accumulate a lot of these and have started to put them into a plays/ directory organized into per-topic subdirectories. This involved a little bit of rewriting so that all of the paths (files, templates, etc) need "../../" path prefixes since they were being loaded relative to the playbook and not the cwd. Not too bad. But this means that the variables in group_vars, host_vars, etc aren't loaded automatically. I've tried putting boilerplate "vars_files" to load everything it needs that looks something like this: vars_files: - ../../group_vars/all.yml - ../../group_vars/{{ ec2_tag_environment }}.yml - ../../group_vars/{{ ec2_tag_role }}.yml (where ec2_tag_environment and ec2_tag_role are facts provided by ec2.py that correspond to groups) Not only would that be annoying to have to copy/paste into each of these playbooks, but this doesn't quite seem to work. Variables loaded by vars_files don't seem to go into hostvars for that host. I assume they are just globally scoped but I have other plays and included files that rely on things to be in hostvars and I'd rather not rewrite those just because the playbooks moved around (and sometimes they can't be changed because they are included in top-level playbooks too). I guess changing paths to files seems reasonable when moving things, but not the scope of variables. So, what am I doing wrong? Should I just have dozens (and in the future likely hundreds) or playbooks littered at the top level? Could ansible look for group_vars in the CWD as well as the location of the playbook? Something else? 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 [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/CAJQqANc0O8Ga42UxRLcgcJJrCcRGZ%3D8bj%3DSpEyNop5ftSMZXPw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
