Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

How to install Ansible on Linux for vSphere configuration

Part 2: Using Ansible for Managing VMware vsphere Infrastructure

managing-Vmware-vSphere-through-Ansible-devops-automation-tool-api-pyvmomi-780x405.png

Recently I took over a task to evaluate few DevOps configuration, automation and orchestration tools to configure VMware vSphere. There are many tools available in the market for DevOps automation. Personally I like and already worked on PowerCLI DSC earlier and have great expertise. Still I preferred Ansible since I have expertise on the same tool since great community support. Plus my entire team was using Ansible for other product configuration management and they had good hands on experience. Ansible server is called controller. This software is only installed on Linux OS. No software for windows. Here I am using CentOS version 7 to install Ansible. Installation is very straight just going through below commands. First i will prepare OS and update all the packages on Linux by running.

sudo yum update -y

Note: My linux server – Ansible controller has direct access to internet and all the packages are getting installed from online CentOS repository.

Install-ansible-on-linux-ubuntu-redhat-centos-sudo-yum-update-packages-base-extras-updates-base-no-packages-marked-for-update-pyvmomi-ansible-devops-automation.png

I will be Installing Ansible using python PIP. Below command installs python-setuptools. Why I am using pip here when yum can do the same task? I want Ansible and all the required modules to be of same version to avoid any dependencies or conflict. Differences in Ansible and module version might cause issues. PIP will give uniformity.

sudo yum install python-setuptools -y

sudo-yum-install-python-setuptools-Install-ansible-using-python-pip-on-linux-centos-for-pyvmomi-vmware-vsphere-automation-devops.png

This command installs PIP. PIP is a package manager for Python packages, or modules if you like.

sudo easy_install pip

sudo-easy_install-pip-python-modules-pyvmomi-automation-ansible-installation-module-automation-devops.png

This will install actual Ansible controller software, alternative to pip command is sudo yum install ansible.

sudo pip install ansible 

sudo-pip-install-ansible-devops-automation-tool-vsphere-vcenter-esxi-module-pyvmomi-python-module.png

This is last step and shows how to install Ansible module pyvmomi for vSphere. Same step you can use to install any other modules.

sudo pip install pyvmomi

sudo-pip-install-pyvmomi-python-ansible-module-for-automation-devops-vsphere-ansible-automation-testing.png

Everything is installed correctly till now. Its time to test Ansible, which I will test using ping module against localhost. I am getting success message with all green color messages after execution and response to ping is pong. In next article I will use it to configure Esxi servers.

ansible localhost -m ping

vmware-vsphere-ansible-localhost-module-pyvmomi-ping-test-ping-pong-success-devops-automation-ansible-declarative.png

This is first part of installing Ansible and Pyvyomi module for vSphere is done, In next parts I will take work on configuring vSphere.

Useful Article
PART 1 : BUILDING AND BUYING GUIDE IDEAS FOR VMWARE LAB
PART 2 : BUILDING AND HARDWARE BUYING GUIDE IDEAS FOR VMWARE LAB
PART 3 : MY VSPHERE LAB CONFIGURATION ON VMWARE WORKSTATION
PART 4 : CONFIGURING VMWARE WORKSTATION NETWORKING IN HOME LAB
PART 5 : CONFIGURING STORAGE IN VMWare WORKSTATION FOR OPTIMAL SPEED
PART 6 : CONFIGURE VMWARE WORKSTATION TO SAVE SSD SPACE AND TIME
PART 7 : CREATING NESTED VMWARE ESXI SERVER VM IN HOMELAB ON VMWARE WORKSTATION
PART 8 : CPU COOLING SOLUTION FOR MY HOME LAB ON VMWARE WORKSTATION

Go Back

Comment

Blog Search

Page Views

12278933

Follow me on Blogarama