VMware vSphere PowerCLI Reference. Graf Brian

Чтение книги онлайн.

Читать онлайн книгу VMware vSphere PowerCLI Reference - Graf Brian страница 6

VMware vSphere PowerCLI Reference - Graf Brian

Скачать книгу

A supported database is already available unless you plan on using the internal vPostgres database.

      • A valid system data source name (DSN) exists that allows vCenter Server to connect to the created database.

      • The vCenter Server is able to directly access the hosts it will manage without any network address translation between the server and the hosts.

      No Magic Wands

      Notice that all these requirements and recommendations are the same as those you’d check if you were manually installing vCenter Server on a single machine. People often think that scripting introduces some kind of magic or new ways to do things behind the scene. Not so! We use exactly the same methods VMware does for a manual install; it’s just automated. If things go wrong, troubleshoot them the same way you would for a standard vCenter Server install that went wrong.

      Create an Automated Installation

      When installing vCenter Server manually, you first download the media, and then run through a series of wizards, ensuring that each step within the wizard is correctly configured before completing the installation and waiting for the wizard to install vCenter Server. This process can become cumbersome if the installation needs to be repeated multiple times, and mistakes can be made that could cause key configured items to be incorrect.

      Once you know what properties are required to perform an automated (also known as silent) install, you will be able to begin writing a script that can be reused as many times as desired. One key to creating a successful installation script that can be reused is to use variables for property values. This allows the user to use CSV files, additional scripts, and other methods to specify different values for each property in subsequent deployments without having to manually edit the installation script.

      Generally, scripts have a few key items: property variables for repeatability, the location of the installation media, installer switches that specify how the installer will act, and a line that creates the installation string to be run.

The automated vCenter installation scripts vary slightly depending on the version of vCenter used (requirements and features can change between versions). The properties defined in Listing 1-1 are configured for use with vCenter Server 6. If you are using a previous version of vCenter Server for your install, the properties may be different. However, the method of invoking the vCenter installation remains the same.

      In this example, we are installing vCenter Server 6 using a remote SQL Server 2014 database. vCenter Server 6 can also install using an internal vPostgres database. To ensure a successful installation, we specify values for all of the properties required for the type of installation we are performing.

note.tif

      NOTE A manual install offers multiple installation paths and options. When performing an automated install, use only the inputs necessary for the type of deploy you want to perform. There is no need to specify every single available property within the installer GUI.

      As you can see in Listing 1-1, once values have been given to each of the variables for the required properties, it is only a matter of creating the argument string that will be passed to the installer. Using a script like this ensures each installation is configured correctly and no mistakes are made.

      Before running the sample script in Listing 1-1, we ensured that all prerequisites and installation requirements were completed. Listing 1-1 shows how you might automate an installation of vCenter Server.

Listing 1-1: Sample script for an automated installation of vCenter Server

      Not all vCenter Servers are installed on Windows machines. VMware has released a virtual appliance known as the vCenter Server Appliance (vCSA) that can be used in place of a Windows vCenter. This option is compelling to many users because it does not require a Microsoft Windows license, and with each new release it is continuing to increase the size of environment it can handle.

Previous versions of the vCSA could be deployed using the Deploy OVF Template button within the C# client. However, with vCSA 6 this option is no longer possible. Luckily, we still have a few other options for deploying it. Along with the installer files, vCSA 6 has a command-line tool packaged in the installation media. The command-line tool leverages the use of a JavaScript Object Notation (JSON) configuration file and the OVF Tool to deploy the virtual appliance. Listing 1-2 shows an example of how we can use PowerCLI to configure the JSON configuration file and deploy the vCenter Server appliance.

Leveraging features found in PowerShell version 3 and later, we are able to convert the vCSA configuration template JSON file and convert it into a PowerShell object that we can then manipulate for our deployment purposes. Once the JSON file is converted into a PowerShell object, we can easily go through each property of the object and set its value. Once we have finished setting all the properties necessary for deployment, we can convert the PowerShell object back into a JSON file and use it to deploy the vCenter Server appliance. Figure 1-1 shows what is returned during the import process.

Listing 1-2: Sample script for an automated installation of the vCenter Server appliance

Figure 1-1: Sample vCSA import progress

Additional components, such as the vCenter Client or Update Manager, can also be installed in an automated fashion. We can deploy Update Manager the same way we deployed the Windows vCenter Server (see Listing 1-3).

Listing 1-3: Sample script for a silent install of the vSphere Client

vSphere Update Manager (VUM) deployments can also be automated in a similar fashion as vCenter Server. Update Manager can leverage a local database, but to maintain consistency with how we deployed vCenter Server, we will be deploying to a remote SQL database. Listing 1-4 shows how you can automate the deployment of vSphere Update Manager 6.

Listing 1-4: Sample script for an automated installation of vSphere Update Manager

      VMware supports more automated installation options and parameters, such as installing a linked mode vCenter Server, and maintains an online installation document here:

      https://www.vmware.com/support/pubs/vsphere-esxi-vcenter-server-pubs.html

      Set Up Your vCenter Server Folder Structure

      Two types of folders are supported in vSphere. From within the Hosts and Clusters view, you are able to create folders at any point under the datacenter level. These are commonly known as yellow folders and can be used throughout the infrastructure to organize the clusters, hosts, and VMs in a logical view.

      Blue folders can be seen in the VMs and Templates view. Use these folders to more accurately reflect the layout of your VMs from a logical point of view. For example, you can create folders based on

Скачать книгу