Skip to main content

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

Popular posts from this blog

Glimpse - Key Vault Vs App Configuration for App service In this post, we are jsut going to see glimpse of comparison between Keyvaukt and App Configuration for App services references. Why we are comparing these two? Recently App Configuration references on App Service become Generally Available and it can complements Keyvault. Let us consider a scenario that we need to have client-id and secret which will be used in an API call for authentication from Azure function app/ App service / Logic App standard, in a secure place. So, Here we come to know 2 azure native services are as follows Azure Keyvault Azure App Configuration Azure people(we) typically use keyvault to handle secrets in secure way whereas App Configuration also complements Azure Keyvault then which is better or in which scenario we can pick either of the one. According to me, We can go for keyvault when we need to handle secrets environment specific. Here, enviro...
Glimpse - Azure function migration from .net6 in-process to .net8 isolated Microsoft/Azure periodically announces the end of support for some services and ask us to migrate to a new version/release when they come up with a robust solution than the deprecated. In this post we are going to see a glimpse/UI configuration change of azure function 𝗺𝗶𝗴𝗿𝗮𝘁𝗶𝗼𝗻 𝗳𝗿𝗼𝗺 .𝗻𝗲𝘁𝟲 𝗶𝗻-𝗽𝗿𝗼𝗰𝗲𝘀𝘀 𝗺𝗼𝗱𝗲𝗹 𝘁𝗼 .𝗻𝗲𝘁𝟴 𝗶𝘀𝗼𝗹𝗮𝘁𝗲𝗱. Here, I'm not going to deep dive about the migration whereas going to see the illustration of changing .net version from UI. For learning, GUI is the best place to start. So, as a dev guy we would prefer azure portal mostly. Consider a scenario that, you're requested to migrate your existing .net6 function app to be migrated .net8 isolated, you would go to settings panel and try to change the version in configuration, but the option would be disabled, it was disabled for me initially. Shocking and Afraid! After some point of ...
𝗚𝗹𝗶𝗺𝗽𝘀𝗲 - 𝗔𝘇𝘂𝗿𝗲 𝗱𝗶𝘀𝗸 𝘂𝘀𝗲 𝗰𝗮𝘀𝗲𝘀 Hi Present days, Container based services/applications are growing than applications running from virtual machines. Even though container services evolving IT apps landscape, we could not boycott VM usage. Azure VM also requires and plays vital role for some scenarios. In this post, we are going to see just glimpse of azure disks of VM. This post is not about standard vs premium disk use case FYI. Azure VM can run with OS disk but it is not good practice. There are three types of disks. OS disk Data disk Ephemeral disk We need to know when to use what then only we can avoid performance bottleneck. 𝗗𝗮𝘁𝗮 𝗗𝗶𝘀𝗸 - If we install applications as well in OS disk, we could face performance issue. It is best to use OS disk to have OS infos and booting. The benefilt of Data disk is Easy maintanence Backup and disaster recovery Performance isolation (as it is far from OS acti...