In this approach, you will always maintain the dev and master branches. The initial code is committed to the dev branch, and once stable, you will promote it to the master branch. The same roles and playbooks that exist in the master branch will run across all environments. On the other hand, you will have separate folders for each of your environments. Let's look at an example. We'll show how you can have a separate configuration and an inventory for two environments: stage and production. You can extend it for your scenario to fit all the environments you use. Let's first look at the playbook in playbooks/variables.yaml
that will run across these multiple environments and has the following content:
- hosts: web user: root tasks: - name: Print environment name debug: var: env - name: Print db server url debug: var: db_url - name: Print domain url debug...