Us­ing An­si­ble for Manag­ing VMware In­fra­struc­ture

This ar­ti­cle is an in­tro­duc­tion to dif­fer­ent An­si­ble mod­ules, which can be used to man­age var­i­ous VMware ob­jects in VMware in­fra­struc­ture.

OpenSource For You - - Contents - By: Ab­hi­jeet Ka­surde The au­thor works at Red Hat and is a FOSS evan­ge­list. He loves to ex­plore new tech­nolo­gies and soft­ware. You can con­tact him at ab­hi­jeetka­

An­si­ble is an IT au­to­ma­tion tool. It can con­fig­ure sys­tems, de­ploy soft­ware and or­ches­trate ad­vanced IT tasks such as con­tin­u­ous de­ploy­ments or zero down­time rolling up­dates. Many of you al­ready know that you can man­age your VMware in­fra­struc­ture us­ing An­si­ble.

A re­cent de­vel­op­ment branch of An­si­ble, i.e., 2.4-de­vel (­si­ble/an­si­ble/tree/de­vel), has brought in a lot of im­prove­ments in both its per­for­mance and its re­li­a­bil­ity.

Manag­ing the ESXi host with dif­fer­ent tools

The vSphere Client and the vSphere Web Client pro­vide sim­ple ways to man­age your ESXi host and op­er­ate its vir­tual ma­chines.

An­other way of manag­ing this is the

Vir­tu­al­i­sa­tion Man­age­ment Ob­ject Man­age­ment In­fra­struc­ture’s (VMOMI) net­work ex­posed API. VMOMI can be used by var­i­ous pro­gram­ming lan­guage bind­ings like PyV­momi (­momi).

Get­ting started with An­si­ble

You can read more about An­si­ble of­fi­cial doc­u­men­ta­tion at­si­ Also, Open Source For You has cov­ered var­i­ous An­si­ble re­lated top­ics in past edi­tions.

Let us dis­cuss a few An­si­ble VMware mod­ules that are es­sen­tial for manag­ing and ad­min­is­trat­ing var­i­ous VMware ob­jects.

Manag­ing vir­tual ma­chines

vmware_guest: This mod­ule is re­quired in or­der to man­age a vir­tual ma­chine in your vCen­ter or stand­alone ESXi en­vi­ron­ment. The mod­ule can cre­ate, mod­ify, re­name and re­move a vir­tual ma­chine. It can also power on, power off, res­tart and sus­pend a vir­tual ma­chine.

The fol­low­ing An­si­ble Play­book ex­am­ple shows how to cre­ate a vir­tual ma­chine:

- name: Ex­am­ple Play­book for creat­ing vir­tual ma­chine hosts: lo­cal­host tasks:

- name: Cre­ate a vir­tual ma­chine with name testvm01


dat­a­cen­ter: dat­a­cen­ter01 es­x­i_host­name: es­x­i_host_01


name: testvm01

guest_id: cen­tos64guest user­name: user

pass­word: pass@123

state: present disk:

- size_gb: 1

type: thin

data­s­tore: Lo­calDS_0

hard­ware: mem­o­ry_mb: 512 num_c­pus: 1 osid: cen­tos64guest scsi: par­avir­tual

You can read more about this mod­ule at http://docs. an­si­­si­ble/lat­est/vmware_guest_­mod­ule.html.

vmware_guest_­facts: You of­ten want to get de­tails about a vir­tual ma­chine like its IP ad­dress, folder path, MAC ad­dress, etc. This mod­ule does ex­actly that. vmware_guest_ facts gives you all the vi­tal in­for­ma­tion about a vir­tual ma­chine. You can chain the in­for­ma­tion re­ceived from this mod­ule to var­i­ous other VMware mod­ules.

--name: Ex­am­ple play­book to get facts about vir­tual ma­chine hosts: lo­cal­host tasks:

- name: get list of facts about vir­tual ma­chines


val­i­date_certs: False

host­name: es­x­i_host­name_01

user­name: user

pass­word: pass@123

dat­a­cen­ter: dat­a­cen­ter_01

name: testvm01 folder: /vm reg­is­ter: guest_­facts_0001

- de­bug: msg=”{{ guest_­facts_0001 }}”

You can read more about this mod­ule at http://docs. an­si­­si­ble/lat­est/vmware_guest_­fact­s_­mod­ule.html.

vmware_guest_find: This mod­ule pro­vides in­for­ma­tion about the folder path in which the vir­tual ma­chine is lo­cated. This in­for­ma­tion is re­quired in var­i­ous other VMware mod­ules.

The fol­low­ing ex­am­ple will find the folder path re­lated to a vir­tual ma­chine.

--name: Ex­am­ple play­book to find the de­tails of folder re­lated to vir­tual ma­chine hosts: lo­cal­host tasks:

- name: Get folder path for vir­tual ma­chine vmware_guest_find: val­i­date_certs: false host­name: user­name: user pass­word: pass name: testvm01 dat­a­cen­ter: dat­a­cen­ter_01 reg­is­ter: fold­er_de­tails

- de­bug: msg=”{{ fold­er_de­tails }}”

You can read more about this mod­ule at https://github. com/an­si­ble/an­si­ble/blob/de­vel/lib/an­si­ble/mod­ules/cloud/ vmware/

vmware_guest_s­nap­shot: When we want to pre­serve the state of the vir­tual ma­chine at a given point of time, we take a snap­shot of the vir­tual ma­chine. This mod­ule pro­vides the func­tion­al­ity to man­age var­i­ous op­er­a­tions re­lated to a snap­shot such as cre­ate, delete, re­vert and re­store. This mod­ule re­quires in­for­ma­tion on the folder path along with the vir­tual ma­chine name. Here, we can use the in­for­ma­tion pro­vided by vmware_guest_find on the folder path.

The fol­low­ing play­book ex­am­ple will show how to take a sim­ple snap­shot of a vir­tual ma­chine:

--name: Ex­am­ple to take a snap­shot of vir­tual ma­chine hosts: lo­cal­host tasks:

- name: Take a snap­shot


host­name: es­x­i_host­name_01

user­name: root

pass­word: esxi@123

name: testvm01

folder: /vm

snap­shot_­name: my_se­cure_stable_s­nap­shot

reg­is­ter: snap_s­tate_001

- de­bug: msg=”{{ snap_s­tate_001 }}”

You can read more about this mod­ule at­si­ble. com/an­si­ble/lat­est/vmware_guest_s­nap­shot_­mod­ule.html.

Manag­ing clus­ters

vmware_­clus­ter: This mod­ule al­lows you to man­age a clus­ter in your VMware in­fra­struc­ture. It also al­lows you to set var­i­ous clus­ter prop­er­ties such as HA, vSAN and DRS.

The fol­low­ing ex­am­ple will add a sam­ple clus­ter in a given VMware in­fra­struc­ture:

--name: Ex­am­ple play­book to add a clus­ter hosts: lo­cal­host tasks:

- name: Add clus­ter

vmware_­clus­ter: val­i­date_certs: false

host­name: es­x­i_host­name_01

user­name: root

pass­word: esxi@123

dat­a­cen­ter_­name: dat­a­cen­ter_01 clus­ter_­name: es­x_­clus­ter_002 reg­is­ter: new_­clus­ter_de­tails - de­bug: msg=new_­clus­ter_de­tails

You can read more about this mod­ule at http://docs. an­si­­si­ble/lat­est/vmware_­clus­ter_­mod­ule.html.

Manag­ing data cen­tres

vmware_­dat­a­cen­ter: This mod­ule al­lows you to man­age a data cen­tre in your VMware in­fra­struc­ture. You can read more about this mod­ule at­si­­si­ble/lat­est/vmware_­dat­a­cen­ter_­mod­ule.html.

Manag­ing VMware net­works

You can man­age var­i­ous VMware net­work ob­jects such as a dis­trib­uted vir­tual switch, vir­tual switch, port group, dis­trib­uted vir­tual switch port group, etc.

You can read more about these var­i­ous mod­ules at­si­­si­ble/lat­est/list_of_­cloud_­mod­ules. html#vmware.

An­si­ble VMware mod­ules are un­der­go­ing heavy de­vel­op­ment; you can take ac­tive part in this by de­vel­op­ing or test­ing var­i­ous mod­ules. You can read more about hack­ing An­si­ble mod­ules at­si­ble/an­si­ble/blob/ de­vel/hack­ing/



[2]­si­­si­ble/lat­est/vmware_guest_ mod­ule.html

[3]­si­­si­ble/lat­est/vmware_guest_ fact­s_­mod­ule.html

[4]­si­ble/an­si­ble/blob/de­vel/lib/ an­si­ble/mod­ules/cloud/vmware/

[5]­si­­si­ble/lat­est/vmware_guest_ snap­shot_­mod­ule.html

[6]­si­­si­ble/lat­est/vmware_­clus­ter_ mod­ule.html

[7]­si­­si­ble/lat­est/vmware_ dat­a­cen­ter_­mod­ule.html

[8]­si­­si­ble/lat­est/list_of_­cloud_ mod­ules.html#vmware


Newspapers in English

Newspapers from India

© PressReader. All rights reserved.