VMWare Automation With Ansible

ကျွန်တော် sharing လုပ်ချင်တာ က VMWare ESXi or vCenter ကို Ansible သုံးပြီး ဘယ်လို Automate လုပ်ရမလဲကို sharing လုပ်ချင်ပါတယ်.

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

*Prerequisites*

  • Linux, Mac, or WSL Terminal with ( Bash or Z Shell )
  • Python Library For VMWare API Management
  • Ansible
  • Microsoft VSCode or IDE
  • VMWare ESXi Server Physical or Virtual Machine
  • VMWare ESXi License Key for API Access
  • vCenter or ESXi server SSL Certificate
  • Ansible Inventory and Test Playbook

*Linux, Mac, or WSL Terminal with ( Bash or Z Shell )*

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

*Python Library For VMWare API Management*

ကျွန်တော်အရင်ဆုံး vSphere Automation Python SDK ကို install လုပ်ပါမယ်. တစ်ကယ်လို့ vSphere Automation Python SDK ကိုမသုံးခြင်ရင်လဲရပါတယ်. လိုအပ်တဲ့ python library ကို install လုပ်လဲရပါတယ်.

#python library

> pip3 install pyvmomi

#vSphere Automation Python SDK

> pip install –upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git

*Ansible*

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

ကျွန်တော်က apt နဲ့ install လုပ်ထားပါတယ်.

*Microsoft VSCode or IDE*

ကျွန်တော် က MS VSCode ကို သုံးထားပါတယ်. ကိုယ်ကြိုက်ရာ IDE ကိုသုံးလို့လဲရပါတယ်. Ansible Playbook ရေးရာမှာ Identation နဲ့ syntax highlighting အတွက် VSCode မှာ Extensions ထည့်ပါ.

#For VIM User

တစ်ကယ်လို့ VIM ကို IDE အနေနဲ့ သုံးချင်ရင် .vimrc ဖိုင်မှာ Tab နဲ့ space ကိုပြောင်းလို့ရပါတယ်.

# .vimrc file

  • shiftwidth: sw
  • tabstop: ts
  • expandtab: et

*VMWare ESXi Server Physical or Virtual Machine*

ကျွန်တော်က VMWare ESXi 6.7 ကို သုံးထားပါတယ်.

SSH Service ကို ESXi Web UI or Console မှာ ဖွင့်ပေးပါ.

#From Web UI

#From Console

SSH Access ကို Test လုပ်ပါ.

SSH Password မလိုဘဲ Access လုပ်ဖို့ အောက်ပါ absolute path မှာ public key ကို သွားသိမ်းပါ.

cat ~/.ssh/id_rsa.pub | ssh root@esxi6-7 ‘cat >> /etc/ssh/keys-root/authorized_keys’

SCP သုံးလဲရပါတယ်.

*VMWare ESXi License Key for API Access*

vSphere Automation API Access လုပ်ဖို့ license လိုပါတယ်.

*VMware vSphere ESXi 7.0 Enterprise Plus key*

JJ2WR-25L9P-H71A8-6J20P-C0K3F

HN2X0-0DH5M-M78Q1-780HH-CN214

JH09A-2YL84-M7EC8-FL0K2-3N2J2

vSphere Automation API နဲ့ Ansible connection ကို SSL နဲ့ သုံးချင်ရင် အောက်ပါ link မှာကြည့်ပါ.

https://docs.ansible.com/ansible/latest/scenario_guides/vmware_scenarios/vmware_requirements.html

*Ansible Inventory and Test Playbook*

Ansible Inventory and Configuration File

Ansible Ad-hoc Test

တစ်ကယ် SSL ကို မသုံးချင်ရင် Ansible Playbook မှာ “validate_certs: false” ကိုထည့်ရေးပါ.

တစ်ကယ်လို့ vSphere Automation API ကို အခြားစက်မှာ Install လုပ်ထားရင် delegate_to ကိုသုံးပါ.

Ansible Test Playbook for VMWare ESXi

*Ansible playbook*

https://github.com/Htunn/Ansible_VMWare

#တစ်ကယ်လို့ Ansible ကိုဆက်လက်လေ့လာလိုလျှင်.

https://docs.ansible.com/ansible/latest/scenario_guides/guide_vmware.html

https://www.ansiblefordevops.com/

*Thank For Your Time, Mate*

Leave a Reply

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