ကျွန်တော် sharing လုပ်ချင်တာက Microsoft Windows မှာ Ansible ကို သုံးပြီး Configuration as Code ( CAC ) practice ကို ဘယ်လို Implement လုပ်ရမလဲကို sharing လုပ်ချင်ပါတယ်.
ဤရင်ဆုံး ကျွန်တော်တို့ High Level Design ကို အရင်ကြည့်ရအောင်.
Microsoft Windows Automation With Ansible
*Prerequisites*
- Microsoft Windows Server or Workstation ( VM or Physical )
- Linux, Mac ,or WSL Terminal ( Z Shell or Bash )
- Python Library for WinRM
- Ansible
- Powershell Script ( to open WinRM port )
- MS Domain User or Normal User Account with Admin Privilege
*Microsoft WIndows*
ကျွန်တာ်တို့ windows server or workstation နစ်မျိုးလုံးကို Ansible နဲ့ Automate လုပ်လို့ရပါတယ်.
ကျွန်တော် က windows server 2016 ကိုသုံးထားပါတယ်.
အရင်ဆုံးကျွန်တော်တို့ windows server 2016 VM တစ်လုံးကို Install လုပ်ပါ. System Specification ကိုကိုယ်ကြုိက်သလို ထားပါ.
*Linux, Mac, or WSL Terminal*
ကျွန်တော်က ubuntu 20.04 နဲ့ Z Shell ကို သုံးထားပါတယ်. ကိုယ်ကြုိက်ရာ Shell ကိုသုံးလို့ရပါတယ်.
*Python Library*
ကျွန်တော်တို့ windows ကို manage လုပ်ဖို့လိုအပ်တဲ python library ကို python package manager ကို သုံးပြီး install လုပ်လို့ရပါတယ်.
*Ansible*
ကျွန်တော်တို့ Ansible ကို apt, yum or pip ကို သုံးပြီး install လုပ်လို့ရပါတယ်.
*Powershell Script*
ကျွန်တော်တို့ windows ကို Ansible နဲ့ Automate လုပ်ဖို့ လိုအပ်တဲ့ Port နဲ့ Service တွေကို Powershell ကိုသုံးပြီး ဖွင့်လို့ရပါတယ်.
Powershell upgrade မြင့်နည်းနဲ့ WinRM Port ဖွင့်နည်းကို အောက်ပါ links မှာကြည့်ပါ.
https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html
*Windows Server*
Normal User တစ်ခုကို admin privilege နဲ့ တည်ဆောက်ပါ. Domain User လဲသုံးလို့ရပါတယ်.
*Powershell upgrade*
Powershell ကို upgrade လုပ်ပါ.
WinRM Port and Service ကို ဖွင့်ပါ.
Check WinRM Listener Port
ကျွန်တော်က basic authentication ကိုသုံးထားပါတယ်.
ပြီးရင် ansible win -m win_ping command ကို သုံးပြီး test လုပ်ပါ.
WinRM နဲ့ ပါတ်သတ်ပြီး အောက်ပါ link မှာ ဖတ်ပါ.
https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html
*Ansible Sample Playbook*
Ansible ကိုဆက်လေ့လာလိုလျှင်.
https://ansible.github.io/workshops/
https://www.ansiblefordevops.com/
“Thanks for your time, mate”