Common inventory for multiple separate projects/environments?

91 views
Skip to first unread message

Lupu Pitkänen

unread,
Nov 6, 2015, 7:34:25 AM11/6/15
to Ansible Project
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

notifi...@marco.link

unread,
Nov 6, 2015, 7:14:49 PM11/6/15
to Ansible Project

Brian Coca

unread,
Nov 9, 2015, 11:56:50 AM11/9/15
to Ansible Project
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.

--
Brian Coca

Lupu Pitkänen

unread,
Nov 10, 2015, 3:19:04 PM11/10/15
to Ansible Project
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.

Jeff

unread,
Nov 11, 2015, 6:49:06 AM11/11/15
to Ansible Project
ditto - great pointers for an Ansible newbie like me - @marco, @brian - thanks and kudos
Reply all
Reply to author
Forward
0 new messages