bitovi / bitops

Automate the provisioning and configuration of cloud infrastructure with BitOps docker image
https://bitops.sh
Other
36 stars 9 forks source link

Multiple Operations On the Same Bitops environment #86

Open mickmcgrath13 opened 3 years ago

mickmcgrath13 commented 3 years ago

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 variable TAGS_RUN. Passing the cli argument via bitops.config.yml statically won't work because I need to dynamically change the tags depending on the operation I need to run. Passing the TAGS_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

  1. 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 contains bitops.config.yml within the ansible/ directory

  2. Multiple bitops.config.yml within a single environment Allow the bitops.config.yml location to be overwritten with an environment variable

  3. Before hook to modify bitops.config.yml Implement a bitops before hook to modify bitops.config.yml at runtime

mickmcgrath13 commented 3 years ago

comment from @shyamrayaprolu

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"