-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Add "best practices" example of separate staging/production inventories #290
Comments
I can't speak to best practices, but we're using a structure like this:
I'm oversimplifying a bit, but that overall structure allows us to target just the collection of systems that we want with the host or groups-specific settings intended for the collection. |
This is kind of what the documentation is suggesting as a best practice - which makes sense, but it can get complicated. For example: pretend your servers follow AWS Tagging best practices. Your server names might encapsulate multiple dimensions of categories. In their example of Then assume you want to run playbooks against production Customer Service Portal-related hosts in the Philadelphia data center. If we create inventories for specific combinations of categories (like Maybe despite all of this, creating staging/prod (etc.) inventories is still the best practice - but it would still be helpful to see some examples. My issue is that the tips/tricks documentation is leaving it up to interpretation. |
You can reference several inventories (repeat Depending on the complexity of the environment, using dynamic inventories may be preferable over trying to create complex inventory structures. I've previously read about how to create custom dynamic inventories (e.g., external data sources), but we've not yet had to reach for that functionality. Deferring to others for further feedback. |
Per the Ansible Tips and tricks documentation:
Separate production and staging inventory
You can keep your production environment separate from development, test, and staging environments by using separate inventory files or directories for each environment. This way you pick with -i what you are targeting. Keeping all your environments in one file can lead to surprises!
There aren't any examples of this in the documentation. I couldn't find any here either.
It sounds like a good idea to separate hosts into groups like
development
,staging
,production
(etc.) - but I can't figure out how to run a playbook againstdevelopment:staging
on some occasions, andproduction
on others (at least not without copy/pasting roles all over a project).The text was updated successfully, but these errors were encountered: