A place to discuss best practices and methodology around process discovery and modeling, decisions, and content management as well as practices to truly transform your business with design thinking, Agile, and artificial intelligence (AI).
Ansible is a very powerful engine that can support Infrastructure as Code. In this blog I would like to highlight the capability of Ansible as a Provisioning Engine.
Ansible can provision infrastructure for any type of business. It has modules that can support provisioning of virtual machines and other infrastructure components easily. These can be on technologies for virtualization such as VMware ESXi, Red Hat Virtualization, HyperV and also Hyper-scalar technologies such as AWS, Azure or GCP.
Ansible has a wide variety of modules for provisioning. Some of the modules can be found on their official modules website
My experience with Ansible over the past few years has been with the below powerful platforms.
VMware Modules
AWS Modules
Azure Modules
GCP Modules
I am going to share my experience with working on these platforms and how I was able to use Ansible to provision infrastructure rapidly for some of our Clients.
VMware has Enterprise Data Center solutions and cloud computing virtualization platform. While VMware has a very powerful interface of the vCenter to provision virtual machines on demand, it is a manual approach. When the requirement from your Clients has a very strict and compressed timeline, like I had from one of my clients, manually provisioning virtual machines becomes a challenge. You can probably provision multiple virtual machines in parallel by the click of the mouse but, you are also limited by the performance and the number of requests that can run in parallel on your vCenter. More importantly, you need to be present in front of the console to monitor this and request more when resources on the vCenter become available.
Ansible makes virtual machines provisioning easier to extend and you do not need to be present in front of the console to monitor progress since it is automated. Ansible Engine or Ansible Tower extends this capability by leveraging Ansible playbooks and perform configuration management on provisioned virtual machines and Infrastructure.You can provision and configure 100s of virtual machines within a matter of minutes and hours rather than days and weeks.
The Technical Architecture of VMware Infrastructure that can be deployed using Ansible is described below:
To provision the above, there are a few mandatory requirements;
1. The Ansible Control Server should be able to connect to the network where the physical infrastructure and the vCenter resides.
2. Remote connectivity to the Ansible Control Server should be possible for you to connect to it. You will also need the credentials to install Ansible on it.
3. At the time of this blog, the ansible version available was 2.8.1
4. We will need Python version >= 2.6
5. We will need PyVmomi python API to connect to VMware infrastructure
Once we have the necessary access and connectivity in place, we are ready to begin with our first deployment and provisioning of the virtualized infrastructure using Ansible.
The following steps will make this possible:
Setup the necessary variables that will be used in the Playbook
The first step is to setup the necessary variables that will be used in the playbooks. A sample playbook in mentioned in the picture.
Some of the important variables we will need to set are:
# Global Variables
vcenter_server
vcenter_user
vcenter_pass
datacenter
cluster
# ESXi Variables
esxi_hostname
esxi_username
esxi_password
# VM Variables
vm_name
template_name
network
datastore
folder
dns_server
Create Data Center on the vSphere
The second step is to create the Data Center on the vSphere. A sample playbook in mentioned in the picture.
The important modules that we will use here are:
vmware_datacenter: This module can be used to manage (create, delete) VMware vSphere Data centers
assert: This module asserts that the Data Center is actually created
debug: Display a message at the end on the console
Create Cluster on the Data Center
The third step is to create the Cluster on the Data Center. A sample playbook in mentioned in the picture.
vmware_cluster: This module can be used to gather information about clusters in VMWare infrastructure.
assert: This module asserts that the Cluster is actually created
Create the ESXi hosts on the Cluster
The fourth step is to create the ESXi hosts on the Cluster A sample playbook in mentioned in the picture.
vmware_host: This module can be used to add, reconnect, or remove an ESXi host to or from vCenter.
vmware_maintenancemode: This module can be used for placing a ESXi host into maintenance mode.
assert: This module asserts that the ESXi host is actually added and also check if the ESXi host has exited from maintenance mode.
Create the Guest Virtual Machines using a existing template
The fifth step is to create the guest virtual machine on the ESXi host. A sample playbook in mentioned in the picture.
The important modules that we will use here are: vmware_guest: This module can be used to create new virtual machines from templates or other virtual machines, manage power state of virtual machine such as power on, power off, suspend, shutdown, reboot, restart etc., modify various virtual machine components like network, disk, customization etc., rename a virtual machine and remove a virtual machine with associated components.
vmware_guest_snapshot: This module can be used to create, delete and update snapshot(s) of the given virtual machine.
assert: This module asserts that the guest VM is actually created and also check if the snapshot of the guest VM is taken
Decommission the Guest Virtual Machine
The sixth step is only necessary if your are testing in the Sandbox environment and need to decommission VM. In real-time, in a Production or Non-Production environment, this may not be necessary in short term. A sample playbook in mentioned in the picture.
vmware_guest: This module can be used to create new virtual machines from templates or other virtual machines, manage power state of virtual machine such as power on, power off, suspend, shutdown, reboot, restart etc., modify various virtual machine components like network, disk, customization etc., rename a virtual machine and remove a virtual machine with associated components.
vmware_guest_powerstate: This module can be used to Power on / Power off / Restart a virtual machine. The vmware_guest module above can also be used for the same.
To sum it up, ansible is a powerful platform that can be leveraged to provision infrastructure at scale and meet the aggressive timelines and deliver in a record timeline.
About the author: Siddhartha (Sidd) is a forward-focused Technology Leader with a passion for design with over 23 years of rich experience in Solutions Architecture, Program Management and Delivery Management. He is an Enterprise IT and Business Transformation Advisor, Design Thinking Coach, and Agile Champion. He also mentors entreprenuers and students in the startup eco-system on value-driven transformations and internet of things.
Copy