Azure IaC & CAC with Ansible

ကျွန်တော် sharing လုပ်ချင်တာက Infrastructure as Code ( IaC ) & Configuration as Code ( CAC ) Practice ကို Microsoft Azure ပေါ်မှာ ဘယ်လို Implement လုပ်ရမလဲ ကို sharing လုပ်ချင် ပါတယ်.

အရင်ဆုံး ကျွန်တော်တို့ High Level Design ( HLD ) ကိုကြည့်ရအောင်.

*Prerequisites*

  • Microsoft Account
  • Azure Subscription
  • Linux, Mac, or WSL Terminal ( Z Shell or BASH )
  • Homebrew Package Manager ( For Azure CLI )
  • Azure CLI
  • Azure Cloud Shell ( Bash or PowerShell )
  • Ansible
  • Prepare Azure Credentials
  • Test Ansible Playbook

*Microsoft Account & Azure Subscription*

အရင်ဆုံး ကျွန်တော်တို့ Microsoft Account တစ်ခုကို တည်ဆောက်ပါ.

https://account.microsoft.com

ဒါမှမဟုတ် Azure Student Account တစ်ခုကို တည်ဆောက်ပါ.

https://azure.microsoft.com/en-us/free/students/

ကျွန်တော်က Azure Student Account ကိုသုံးထားပါတယ်.

*Linux, Mac, or WSL Terminal ( Z Shell or BASH )*

ကျွန်တော်က ubuntu 20.04 နဲ့ Z Shell ကို သုံးထားပါတယ်.

*Homebrew Package Manager ( For Azure CLI )*

Azure CLI ကို Install လုပ်ဖို့ homebrew package manager ကို Install လုပ်ပါ.

https://brew.sh/

*Azure CLI*

Azure CLI ကို homebrew package manager က install လုပ်ပါ.

*Azure Account Login*

Azure Account ကို az login command ကိုသုံးပြီး ဝင်ပါ.

ပြီးရင် Azure Account ကို verify လုပ်ပါ

*Ansible*

Ansible ကို apt or pip နဲ့ install လုပ်ပါ.

ကျွန်တော်က ansible 2.10.2 ကိုသုံးထားပါတယ်.

ansible azure collection ကို install လုပ်ပါ.

https://galaxy.ansible.com/azure/azcollection

ansible azure collection သုံးစွဲပုံကို အောက်ပါ link မှလေ့လာပါ.

https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_resource_module.html

https://docs.ansible.com/ansible/latest/collections/azure/azcollection/index.html#plugins-in-azure-azcollection

* Microsoft Azure*

Azure အတွက်လိုအပ်တဲ့ python library ကို install လုပ်ပါ.

$ pip install ‘ansible[azure]’

*Azure Cloud Shell*

ကျွန်တော်တို့ Azure Cloud Shell ကိုလဲ သုံး လို့ရပါတယ်. Azure Cloud Shell မှာ ansible က built-in ပါပြီးတာပါ.

Azure Credentials ထုတ်ပုံကို အောက်ပါ links မှ ကြည့်ပါ.

https://dev.to/cloudskills/connecting-to-azure-with-ansible-22g2

*Azure Credentials*

> cat .azure/credentials

*Azure Cloud Shell*

ကျွန်တော်တို့ azure cloud shell ပေါ်မှာ ansible playbook ကို ချက်ချင် run လို့ရပါတယ်. ansible azure collection အတွက်လိုအပ်တဲ dependency ကို built-in ပါပြီးတာပါ.

Microsoft Azure ပေါ်မှာ Resource Group တည်ဆောက်လာ verify လုပ်ပါ.

Ansible Sample Playbook

Ansible ကို ဆက်လေ့လာလိုလျှင်.

https://ansible.github.io/workshops/

https://www.jeffgeerling.com/blog/2020/you-can-get-my-devops-books-free-rest-month

“Thanks for your, mate”

Leave a Reply

Your email address will not be published. Required fields are marked *