Common inventory for multiple separate projects/environments?

Hi,

I’m responsible for dozens of separate projects or server environments (each containing multiple hosts) and now planning to manage all of them using ansible.

There’s a requirement to have a separate git repository for each environment configuration containing inventory, variables, vault, roles and playbooks belonging to that environment only.

The issue is that I need to have a combined inventory of all hosts from all environments so that I could for example run “ansible all …” command for every single host I manage.

I’m aware of the group feature of the inventory, but I can’t see how I could keep the configuration separated that way.

├── env1

│ │ ├── group_vars
│ │ │ └── …
│ │ │
│ │ ├── roles
│ │ │ └── …
│ │ │
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ ├── hosts
│ │ └── site.yml
│ │
├── env2
│ │ ├── group_vars
│ │ │ └── …
│ │ │
│ │ ├── roles
│ │ │ └── …
│ │ │
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ ├── hosts
│ │ └── site.yml
│ │

Is this kind of layout feasible? I couldn’t find any examples for a scenario like this and would appreciate any best practices for this kind of setup. Thank you.

Best Regards,
Lupu

Perhaps this article will help you:

http://rosstuck.com/multistage-environments-with-ansible/

one thing about the article, its using group vars are PLAY level, not
at inventory level, which can cause confusion, specially if you move
the plays to a subdirectory.

Thanks very much for pointing out that article and for the clarification regarding group_vars.

But I can’t see how I could have a separate dir (and git repo) for each group of hosts?
Inventories, group_vars and playbooks seem to be under the same directory structure.

Maybe this is not possible and I need to think other ways to handle all of the hosts at
the same time, maybe with a separate (duplicated) inventory or so.

ditto - great pointers for an Ansible newbie like me - @marco, @brian - thanks and kudos