Why should I know if condition in bash especially for Devops?
Hi All!
Today we're going to see and learn if / elseif condition in bash.
Everybody have a thought why if condition is main important to learn than other statements in bash. Let's see why
It is always good to have knowledge on powershell, python and especially bash as a Devops guy. Nowadays most of the organization prefers Infrastucture as Code (Iac) with DRY (Donot Repeat Yourself) mostly. i.e. single/same YAML code file should be applicable for their multiple environments.
Consider an example that an organization has Dev, QA and Production environments. They need same infra to be deployed on all the environments after the verification from Dev then QA then finally Production.
So here, Infrastucture is not going to change, only the environment gets changed (i.e. subscription, resourcegroup, resourcename ...etc,). so we should have a single YAML file based on condition.
But, why learning Bash "if condition" especially is a question here when python, powershell sripting tech available? because
"If condition" applied on YAML is as similar as bash script. so that if we know bash script, it will be easy to work with YAML with some logical aspects.
Note: I'm not saying that bash is best than other. Powershell, Bash and python all are suits based on need.
Please look into the below image, I have a single YAML with if-elseif for 3 environments in Azure Devops.
Comments
Post a Comment