Last night I ran a playbook from a wrong branch that referenced an old inventory file with old IPs for each server, and deployed a dev build to a production machine. What would be a a good practice to avoid such mistake from happening in the future? How can I isolate environments better?
1 Answer
The best practice is to separate production and staging(testing) inventory. See Staging vs Production.
This way you pick with -i what you are targeting.
To make it more robust you might want to clone a separate structure for production and restrict access to it. Pull from staging before deploying to production.
In detail, this would mean to 1) put the directories into git, 2) make sure staging is committed, pushed and merged, and 3) then pull to the production and deploy. The workflow is up to you.
-
I targeted dev, but some of the machines in dev inventory had prod IPs. I think there was reshuffling by the infra team a while back and the branch i was on used that. I am looking for a fool proof ,solution that will exclude such possibility.– JavaHeadCommented May 10, 2019 at 12:25
-
Sure, I've updated the answer. Please, update the question (you're able to edit it) and delete the comment to make the thread clear. Commented May 10, 2019 at 12:31