Description of icon when needed 6 Min Read
installing Ansible

The modern data center has changed from what it was a decade or two ago on a number of fronts. We no longer live in a world where the number of machines can be counted on a couple of hands and maybe a foot, and we now measure in megawatts, rendering a unit count pretty useless. Obviously, this has led to changes in how that management happens and has given rise to systems to help manage the vast array of pieces involved. One of those tools is Ansible, a widely adopted configuration and automation system that can manage a diverse collection of devices in the modern data center. From switches and routers to bare metal, from storage to the ESXi systems themselves, and all the way down to individual virtual machines, installing Ansible can help manage this vast tangle of technology.

This can be a huge boon to keeping things standardized and recreatable for your entire infrastructure. Getting started, however, can sometimes be a bit daunting. No one wants to experiment live on your main production gear, but trying to replicate a huge system for testing is usually impossible. Conveniently, there’s a way to start playing with Ansible and VMware on a more reasonable and incremental scale while still getting a good idea of what’s capable in a larger deployment.

Let’s start by taking a look at installing Ansible to automate VMware Workstation deployment. This is something you can do on a basic Linux distro to install VMware Workstation. Here’s how:

Step 1: Installing Ansible

Most distributions have pre-packaged binaries for working with Ansible, and installing Ansible is easiest when following the official install guide. Trust me, it’ll do a far better (and more comprehensive job) than I can in this blog:

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html

Step 2: Getting the VMware Workstation Role

This is actually pretty straightforward. The VMware Workstation role is present in Ansible’s Galaxy repository, which is where you’ll find many of the available roles for Ansible to use.

You can think of it like a package repository for Ansible:

https://galaxy.ansible.com/vmware/vmware-workstation

The installation is fairly straightforward:

ansible-galaxy install vmware.vmware-workstation

This will grab the role for our use later on, but you are basically ready to use the role now.

Step 3: Using the VMware Workstation Role

Ansible works by making remote ssh connections and using that as the means of remotely controlling the machine. Tip: Make sure you’ve got an ssh key setup for the machine you want to use as the target; if you want to use this on your local machine to install VMware Workstation, this will work too and won’t require you to have an ssh key already setup.

Ansible makes extensive use of yaml files, and if you haven’t worked with them before your big warning for writing them is that WHITE SPACE MATTERS. More than you might imagine. (Hint: If you think Python is picky about white space, yaml is pickier.)

Let’s start using this role by installing VMware Workstation to the local machine.  This will save you the immediate need to deal with ssh keys and dealing with multiple machines at once.

localhost-vmware.yaml:

            —

                 – name: Setup Workstation for Localhost

              hosts: localhost

              roles:

                – { role: vmware_workstation, workstation_license: <license key

here>  }

Now run this file:

# ansible-playbook localhost-vmware.yaml

Note: if you don’t have a workstation_license to add pre-emptively, remove it so your roles line looks like:

– { role: vmware_workstation }

This will:

  • Download the latest VMware Workstation installer
  • Run the unattended installer, and if present, give VMware Workstation the license key
  • If you have a SystemD-based system, it will setup SystemD services instead of legacy SysV basic init scripts.
  • For Debian, Fedora, and RedHat-based systems, ensure that you have the needed package dependencies installed from your package management system

That’s it, you’ve just automated the installation of VMware Workstation.

There are many reasons why you may want to expand on this and run Workstation on other systems, including servers, and this gives you an initial way to automate deployment.  From here, you can explore the other roles available for automating and controlling VMware with Ansible as well as all the other things that Ansible can help you automate.

Ansible has a great quick start guide available here for folks who are new to it:

https://docs.ansible.com/ansible/latest/user_guide/quickstart.html

For anyone interested, I’m (John Hawley) going to be at AnsibleFest 2019 in September in Atlanta. If you’ve got questions, concerns or things you want to talk about come find me, or attend my Birds of a Feather session “State of Ansible and VMware.” While I can’t promise to fix everyone’s problems, I can promise to bring a notebook and take notes on what people are doing with Ansible and VMware!

Stay tuned to the Open Source Blog and follow us on Twitter (@vmwopensource) for all the latest open source news and updates.