Many corporate networks consist of a mixture of physical and virtual machines. Deploying and managing these machines...
requires a consistent management system. SaltStack is emerging as a tool that offers an alternative to offerings such as Puppet, Ansible and Chef. In this article, we'll discuss how it can be used to manage vSphere environments.
SaltStack provides the means to manage state on target systems, the so-called minions. Any configuration can be managed and applied to remote systems SaltStack through the use of efficient remote execution engines. Although it was designed primarily for the Linux platform, SaltStack can manage other operating systems as well, including VMware vSphere environments.
How SaltStack works
SaltStack functions on a minion and master topology. SaltStack works with specific commands that can be executed on one or more minions. To make this happen, the minion key is imported on the Salt Master, at which point the Salt Master administrator can issue commands like salt '*' cmd.run 'ls -l /'. This command runs the ls -l / command on all minions currently known to the Salt Master.
Apart from running remote commands, SaltStack allows administrators to use grains. A grain makes it possible to run remote queries on SaltStack minions, thus collecting status information about the minions and allowing administrators to store that information in a central location. Among the many features that are offered, SaltStack can also work with states, which help administrators define a desired state on a target system. These states are applied by using .sls files, which contain very specific instructions about what should happen on a system to obtain a desired state.
Because of the flexibility it offers in managing remote systems, SaltStack-based products are rapidly gaining interest. The functionality can be compared to features that are offered by state management systems such as Puppet and Ansible. SaltStack takes thing a step further and owes its rapid adoption rates to the fact that it includes an efficient way to run remote commands on management systems.
Using SaltStack to manage vSphere
SaltStack can also manage vSphere environments, but the VMware cloud module needs to be configured first. This module contains the URL to the vSphere server, as well as a username and password needed to connect to VMware. The /etc/salt/cloud.providers file on the Salt Master is the typical location where this information is stored. Listing 1, shown below, shows sample contents of this file, which allows the Salt Master to interact with target VMware systems.
Listing 1: VMware Cloud Provider Configuration examples
Listing 2: Example SaltStack profile
## Optional arguments
CD/DVD drive 1:
iso_path: "[nap004-1] vmimages/tools-isoimages/linux.iso"
CD/DVD drive 2:
controller: IDE 2
CD/DVD drive 3:
controller: IDE 3
Hard disk 1:
Hard disk 2:
controller: SCSI controller 2
Hard disk 3:
controller: SCSI controller 3
Network adapter 1:
Network adapter 2:
Network adapter 3:
SCSI controller 1:
SCSI controller 2:
SCSI controller 3:
Once the connection to the vSphere environment has been defined, SaltStack can talk directly to the vSphere server and perform automated operations, such as starting VMs. In order to do so, a profile needs to be defined. Listing 2, shown below, offers an example of such a profile.
Once the profile has been defined, it needs to be applied. As a salt cloud module is used to interface with the vSphere infrastructure, you should use the salt-cloud command to do so. The generic structure of this command is salt-cloud -p myprofile myinstance. This command applies a profile as shown in Listing 2 to deploy an instance with the name myinstance.
Using SaltStack to manage vSphere environments allows administrators to develop a generic deployment and management strategy that can be applied to physical as well as virtual assets.
Is there room for configuration management tools alongside containers?
Tips for nailing your cloud administrator interview
Why is building the right configuration management system so critical?
Migrating data and apps in a hybrid cloud environment