Manage Learn to apply best practices and optimize your operations.

Learn how to manage vSphere environments with SaltStack

The SaltStack management tool allows admins to create a consistent management system for multiple operating systems, including VMware vSphere environments.

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

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.

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

my-vmware-config:
   driver: vmware
   user: 'DOMAIN\user'
   password: 'password'
   url: '10.20.30.40'

vcenter01:
   driver: vmware
   user: 'DOMAIN\user'
   password: 'password'
   url: 'vcenter01.domain.com'
   protocol: 'https'
   port: 443

vcenter02:
   driver: vmware
   user: 'DOMAIN\user'
   password: 'password'
   url: 'vcenter02.domain.com'
   protocol: 'http'
   port: 80

esx01:
   driver: vmware
   user: 'admin'
   password: 'password'
   url: 'esx01.domain.com'

Listing 2: Example SaltStack profile

vmware-centos6.5:
  provider: vcenter01
  clonefrom: test-vm

  ## Optional arguments
  num_cpus: 4
  memory: 8GB
  devices:
    cd:
      CD/DVD drive 1:
        device_type: datastore_iso_file
        iso_path: "[nap004-1] vmimages/tools-isoimages/linux.iso"
      CD/DVD drive 2:
        device_type: client_device
        mode: atapi
        controller: IDE 2
      CD/DVD drive 3:
        device_type: client_device
        mode: passthrough
        controller: IDE 3
    disk:
      Hard disk 1:
        size: 30
      Hard disk 2:
        size: 20
        controller: SCSI controller 2
      Hard disk 3:
        size: 5
        controller: SCSI controller 3
    network:
      Network adapter 1:
        name: 10.20.30-400-Test
        switch_type: standard
        ip: 10.20.30.123
        gateway: [10.20.30.110]
        subnet_mask: 255.255.255.128
        domain: example.com
      Network adapter 2:
        name: 10.30.40-500-Dev-DHCP
        adapter_type: e1000
        switch_type: distributed
      Network adapter 3:
        name: 10.40.50-600-Prod
        adapter_type: vmxnet3
        switch_type: distributed
        ip: 10.40.50.123
        gateway: [10.40.50.110]
        subnet_mask: 255.255.255.128
        domain: example.com
    scsi:
      SCSI controller 1:
        type: lsilogic
      SCSI controller 2:
        type: lsilogic_sas
        bus_sharing: virtual
      SCSI controller 3:
        type: paravirtual
        bus_sharing: physical
    ide:
      IDE 2
      IDE 3

  domain: example.com
  dns_servers:
    - 123.127.255.240
    - 123.127.255.241
    - 123.127.255.242

  resourcepool: Resources
  cluster: Prod

  datastore: HUGE-DATASTORE-Cluster
  folder: Development
  datacenter: DC1
  host: c4212n-002.domain.com
  template: False
  power_on: True
  extra_config:
     mem.hotadd: 'yes'
    guestinfo.foo: bar
    guestinfo.domain: foobar.com
    guestinfo.customVariable: customValue

  deploy: True
  customization: True
  private_key: /root/.ssh/mykey.pem
  ssh_username: cloud-user
  password: veryVeryBadPassword
  minion:
    master: 123.127.193.105

  file_map:
    /path/to/local/custom/script: /path/to/remote/script
    /path/to/local/file: /path/to/remote/file
    /srv/salt/yum/epel.repo: /etc/yum.repos.d/epel.repo

  hardware_version: 10
  image: centos64Guest

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.

Next Steps

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

This was last published in July 2016

Dig Deeper on VMware basics

Join the conversation

2 comments

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

Other than SaltStack, what tools have you used to create a consistent management system?
Cancel
I tried Vagrant but i think that is not the same thing.
Cancel

-ADS BY GOOGLE

SearchServerVirtualization

SearchVirtualDesktop

SearchDataCenter

SearchCloudComputing

Close