gneisstech / bedrock

Incubating infrastructure as data, code
MIT License
0 stars 0 forks source link

DRYer configs with python #37

Open keshto opened 3 years ago

keshto commented 3 years ago

Intention The yaml is mostly the same with only a few differences. This can be templated away to be easier to compare the differences as well as not repeating oneself (DRY). Possibly related to this issue https://github.com/gneisstech/bedrock/issues/15

Requirements Install python3 and python3-yaml

chmod the script

Usage

./yaml_filler.py 
Invalid option or number of arguments.

Usage: yaml_filler.py [OPTION]
Fill in the template.yaml with values depending on deployment option.

Options:
  ci     fill out the template using the ci values
  dev    fill out the template using the dev values

Notes Running ./yaml_filler.py ci will output a file named 'br_k8s_ci.yaml' and ./yaml_filler.py dev will output the dev version named 'br_k8s_dev.yaml'. This is a quickly hacked together script and is more for a demo of possible options to explore rather than something that should be merged. There are more considerations to be made. Such as if one was to move forward with python should one use Jinja type templates instead? There is a POSIX bash + awk way of doing this https://www.starkandwayne.com/blog/bashing-your-yaml/ however that has other issues explained in the article. Also, please note that the order of the yaml after running the script (this is cosmetic and does not affect the functionality) will be different than the original template as well as no comments preserved in the output file.