Open mickmcgrath13 opened 3 years ago
This same use case can be extended to Terraform and other IAC frameworks as well. To create multiple environments (dev, qa and prod) from same terraform/any other IAC code base we generally I will have separate config files {env}.config.vars and CI process would pass the env variable so that dynamically we can pick respective config.vars.
After reviewing the options here I would vote for option 2
Example: Pass ENV=DEV to docker run through CI process and when running terraform we can just do terraform plan --var="ENV=DEV"
from @ConnorGraham
Background I have a use-case where my ansible playbook handles different operations (
beta-create
,beta-promote
,beta-destroy
), depending on the lifecycle of a single CI build.This is handled through ansible using tags. The tags I want to run is controlled with the cli argument
--tags
or the environment variableTAGS_RUN
. Passing the cli argument viabitops.config.yml
statically won't work because I need to dynamically change the tags depending on the operation I need to run. Passing theTAGS_RUN
env var in to the bitops docker image works in this one case, but the tool bitops uses may not always contain such clean parity between cli args and env vars.Potential Solutions
Multiple Environments + Improved Default env merging I could put all my common ansible code in to the bitops
default
environment and create a separate environment for each operations that only containsbitops.config.yml
within theansible/
directoryMultiple
bitops.config.yml
within a single environment Allow thebitops.config.yml
location to be overwritten with an environment variableBefore hook to modify
bitops.config.yml
Implement a bitops before hook to modifybitops.config.yml
at runtime