3/30/12 VMZaUe - ConfigXUaWion ToolV 1/9 ZZZ.daWadiVk.co.Xk/hWml_docV/YmZaUe/WoolV.hWm AdYanced ConfigXUaWion ToolV In my last section on the VMware series I am going to cover advanced configuration tools, I will be covering host profiles, vCLI, , PowerCLI. I am from a Unix background and if I can I try to script everything this eliminates the human error factor, once you know a script works then you can run hundreds of times knowing that the same outcome will occur, you can script many common tasks in VMware. There are a few new features in version 4 Host Profiles which almost eliminate the need for complex scripted installations The next generation of command-line tools which allow everyone to script configurations of not just ESXi servers but also the vCenter environment Below is a list of the current tools that are available for with VMware Local CLI at the ESXi host YRX UHTXLUH URRW OHYHO DFFHVV DQG D SSH FRQQHFWLRQ (PXTT\), WKLV LV LGHD IRU WKRVH ZKR OLNH WKH FRPPDQG-O ELW OLNH WKH UQL[ ZRUOG. YSphere CLI YCLI DOORZV \RX WR UXQ FRPPDQGV IURP \RXU WLQGRZ/LLQX[ VHUYHU UHPRWHO\ ZLWKRXW DQ SSH VHVVLRQ, QRW DOO F WKH ORFDO CLI DUH DYDLODEOH LQ WKH YCLI YSphere PoZerCLI (toolkit for ZindoZs/PoZershell toolkit) PRZHUCLI SOXJV GLUHFWO\ LQWR YCHQWHU UHPRWHO\ DQG FDUULHV RXW PDQ\ IXQFWLRQV WKDW DUHQ'W HYHQ H[SRVHG LQ D JRRG NQRZOHGJH RI REMHFW-RULHQWHG SURJUDPPLQJ (REMHFWV, SURSHUWLHV, DWWULEXWHV, HWF). YSphere Perl (Perl YSphere PoZerCLI) TKLV WRRONLW H[SRVHV WKH VDPH IXQFWLRQDOLW\ DV WKH PRZHUSKHOO WRRONLW YSphere Management Assistant DJJUHJDWHV PXFK RI WKH IXQFWLRQDOLW\ VHHQ LQ WKH YCLI DQG WKH PHUO WRRONLW, LW DOORZV IRU DQ LQWHUDFWLYH CLI WR DOVR DXWRPDWHV PXFK RI WKH DXWKHQWLFDWLRQ LVVXHV, PHDQLQJ \RX KDYH QR QHHG WR GLVFORVH WKH URRW DFFRXQW Host Profiles DUH QRW D VFULSWLQJ HQJLQH RU CLI WRRO EXW FDUU\ RXW PDQ\ RI WKH SRVW FRQILJXUDWLRQ WDVNV RI DQ ESXL VHUYHU Q VFULSWLQJ, \RX FDQ DFKLHYH WKH VDPH UHVXOWV ZLWK KRVW SURILOHV DV ZLWK VFULSWLQJ, VR LI \RX GRQ'W OLNH VFULSW WK Host Profiles Host profiles allow you to capture the configuration of a ESXi server and apply it another ESXi server, essentially it acts like a policy object that can be applied to either an ESXi server or cluster in the vCenter inventory, thus you can cut down on the scripting element. If you want maximum control over any settings that make up your ESX server than scripted installation is the way to go, but if you are using ESXi host profiles may be a better route because they are relatively easy to use and require no scripting knowledge whatsoever. Host profiles have five main functions Capture the configuration profile of an existing host Apply the configuration profile to a new ESXi server Confirm that an ESXi server is correctly configured Prompt the administrator for per ESXi server settings such as VMKernel network configuration Apply the profile as an ESXi host is added into vCenter cluster - a mere drag and drop event configures the ESXi server You cannot install additional software into the ESXi server and there are some issues with the HA agent starting, but they are ideal for masse rollouts of ESXi servers. Host profiles are associated with the vCenter you logged in to when you create them, they are not available across multiple vCenters even in OiQNed PRde, also the vCenter must manage the ESXi server. FLUVWO\ PD\ ZDQW WR SUHEXLOG D FOHDQ ESXL VHUYHU DQG DSSO\ D PRGHVW Y SZLWFK, NTP DQG ILUHZDOO FRQILJXUDWLRQ. WU\ WR EXLOG DV P WZHDN WR PXFK DIWHU DSSO\LQJ WR D QHZ ESXL VHUYHU. HRVW SURILO HV KDYH PDQ\ QXPEHU RI VHWWLQJV, I DP QRW JRLQJ WR VKRZ \RX D DURXQG. FLUVW ULJKW-FOLFN WKH VRXUFH ESXL VHUYHU DQG FKRRVH KRVW SURILOH, WKHQ VHOHFW "CUHDWH PURILOH IURP HRVW"
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
3/30/12 VMware - Configuration Tools
1/9www.datadisk.co.uk/html_docs/vmware/tools.htm
Advanced Configuration Tools
In my last section on the VMware series I am going to cover advanced configuration tools, I will be covering host profiles, vCLI, ,PowerCLI. I am from a Unix background and if I can I try to script everything this eliminates the human error factor, once you know a script
works then you can run hundreds of times knowing that the same outcome will occur, you can script many common tasks in VMware.
There are a few new features in version 4
Host Profiles which almost eliminate the need for complex scripted installationsThe next generation of command-line tools which allow everyone to script configurations of not just ESXi servers but also the vCenterenvironment
Below is a list of the current tools that are available for with VMware
Local CLI at the ESXi hostYou require root level access and a SSH connection (PuTTy), this is idea for those who like the command-line and using switches, a
bit like the Unix world.
vSphere CLIvCLI allows you to run commands from your Window/Linux server remotely without an SSH session, not all commands available at
the local CLI are available in the vCLI
vSphere PowerCLI
(toolkit for windows/Powershell toolkit)
PowerCLI plugs directly into vCenter remotely and carries out many functions that aren't even exposed in the GUI. You should have
a good knowledge of object-oriented programming (objects, properties, attributes, etc).
vSphere Perl
(Perl vSphere PowerCLI)This toolkit exposes the same functionality as the PowerShell toolkit
vSphere Management Assistantaggregates much of the functionality seen in the vCLI and the Perl toolkit, it allows for an interactive CLI to ESX classic and ESXi, it
also automates much of the authentication issues, meaning you have no need to disclose the root account
Host Profilesare not a scripting engine or CLI tool but carry out many of the post configuration tasks of an ESXi server normally undertaken with
scripting, you can achieve the same results with host profiles as with scripting, so if you don't like script this is the way to go.
Host Profiles
Host profiles allow you to capture the configuration of a ESXi server and apply it another ESXi server, essentially it acts like a policy object
that can be applied to either an ESXi server or cluster in the vCenter inventory, thus you can cut down on the scripting element. If you wantmaximum control over any settings that make up your ESX server than scripted installation is the way to go, but if you are using ESXi host
profiles may be a better route because they are relatively easy to use and require no scripting knowledge whatsoever.
Host profiles have five main functions
Capture the configuration profile of an existing hostApply the configuration profile to a new ESXi serverConfirm that an ESXi server is correctly configuredPrompt the administrator for per ESXi server settings such as VMKernel network configuration
Apply the profile as an ESXi host is added into vCenter cluster - a mere drag and drop event configures the ESXi server
You cannot install additional software into the ESXi server and there are some issues with the HA agent starting, but they are ideal for masserollouts of ESXi servers. Host profiles are associated with the vCenter you logged in to when you create them, they are not available across
multiple vCenters even in linked mode, also the vCenter must manage the ESXi server.
Firstly may want to prebuild a clean ESXi server and apply a modest vSwitch, NTP and firewall configuration. try to build as much as you can so that you don't have to
tweak to much after applying to a new ESXi server. Host profiles have many number of settings, I am not going to show you all of them but do have a look and play
around.
First right-click the source ESXi server and choose host profile, then select "Create Profile from Host"
3/30/12 VMware - Configuration Tools
2/9www.datadisk.co.uk/html_docs/vmware/tools.htm
create and edit a host
profile
Type in a friendly name and a description
Next we get the summary screen
Now go to the home page and select "Host Profiles"
This is the main host profiles screen, we will discuss some of this later, you can edit the production_cluster profile we created by selecting the "edit profile" link
if you select the "edit profile", you will see the edit edit screen, this has vast amounts of information, there is lots to configure here, hence why I stated earlier that
when you build the first source ESXi server try to configure as much possible
3/30/12 VMware - Configuration Tools
3/9www.datadisk.co.uk/html_docs/vmware/tools.htm
Once you have created and configured your host profile you might want to test it against some existing ESXi servers to see if they are
compliant with your build, next we attach a a ESXi server to the host profile and apply it
To attach ESXi servers to you host profile, right-click the host profile and select "Attach Host/Cluster"
Select the cluster or the ESXi server/s you want to attach
In the "Hosts and Clusters" tab you can now see two ESXi servers attached to the "production_cluster" host profile, and if you notice in the top right-hand corner the links are now live, you can apply this profile to a
3/30/12 VMware - Configuration Tools
4/9www.datadisk.co.uk/html_docs/vmware/tools.htm
Attaching
and
applying
host
profiles
host or check its compliance, which is what we are going to do now
Select each ESXi server in turn and click the "Check Compliance Now" link, vmware1 should be compliant as this is the ESXi server we created the host profile with in the first place, however vmware2 is not compliant as
the TSM service is different
Before you apply a host profile to a ESXi server it must be in maintenance mode, then just click the "apply profile" link, below is the screen you get if your ESXi server is not in maintenance mode
You may have to tweak the ESXi server after applying the profile (IP address, etc) but 99% of the configuration should be complete.
You also have the ability to export the host profile, this can then be imported on another vCenter server, the host profile is saved in the
VMware Profile Format (.vpf) format as seen below
vCLI
vCLI does not cover all the commands that the service console does, for instance you cannot add a second service console port for the
VMware iSCSI software initiator and VMware HA, you cannot open firewall ports for the iSCSI. vCLI comes in three flavors
Windows installer
Linux installerDownloadable VM (called VMware management appliance)
They all use the perl environment, so if you are using windows you need ActivePerl installed, then download the latest version of vCLI fromVMware and install, hopefully you should end up with a vCLI icon like below
vCLi can configure common tasks such as the following, I am not going to cover every single command so I will point you to the VMwarevCLI documentation
Create vSwitches
3/30/12 VMware - Configuration Tools
5/9www.datadisk.co.uk/html_docs/vmware/tools.htm
setup DNSconfigure NTP
Enable the iSCSI initiator
configure NAS
vCLI can be frustrating sometimes due to the authentication process, it may take some time for the prompt to come back, all vCLIcommands require a host (ESXi server or vCenter), username and password (HUP) to authenticate against the system prior to the command
being executed. There are three ways to authenticate
Use a session file
## uses a cookie that expires after 30 minutes of nonuse, vCLI commands can be long especially when you add the authentication details for example
Lastly we come to PowerCLI, by default PowerCLI is already installed on Windows 7 (see screen shot below of my Windows 7 desktop
PC) and Windows Server 2008 R2, otherwise you can download from the Microsoft website.
3/30/12 VMware - Configuration Tools
8/9www.datadisk.co.uk/html_docs/vmware/tools.htm
Once you have this installed you next need to download the vSphere PowerCLI from the Vmware website, then install this, hopefully youshould end up with a icon like below
Because I installed PowerCLI on my desktop PC, when I open a window I am not connected to a vCenter (notice the error messages), toconnect to a vCenter I use the connect-viserver command
Once connected I can then run the PowerCLI commands, here I get a list of the current ESXi servers and VM's
Now I am not going to explain all the commands, so again go to the VMware documentation for a complete list, there are seven categorieswhich you can carry out tasks
Add - adding objects such as ESXI servers, vSwitchesGet - listing objectsMove - moving objects such as moving a VM from one ESXi server to another
New - create new objects such as port groups, vSwitchesRemove - remove objectsSet - set a VM resource allocation
Stop/Start - stop a vm or start an ESXi server service
3/30/12 VMware - Configuration Tools
9/9www.datadisk.co.uk/html_docs/vmware/tools.htm
You can also feed one command into another with the use of Pipes (|), if you know the Unix world then this will be familiar, I have listedsome common commands below to get you started and to see what tasks you can perform using PowerCLI.
List all the get commands get-command | where object { $_.name-like "get*" }
Now that you have a feel for the commands, you can create scripts to run multiple commands, save the script with the extension of .ps1 thenjust run it, if it complains that you are not authorized then run the command "set-executionpolicy unrestricted", remember this is dangerous asyou can run any command but it will at least get your going on you test setup.