Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Puppet and VMware Photon OS

DZone's Guide to

Puppet and VMware Photon OS

How to use Puppet in order to manage Photon OS hosts, which are Linux container hosts optimized for VMware platforms.

· DevOps Zone
Free Resource

Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.

Photon OS is a minimal Linux container host, optimized to run on VMware platforms. It's part of the wider VMware effort around vSphere Integrated Containers (VIC), which aims to make containers a first-class citizen on vSphere. VMware does this by wrapping the containers in Photon OS. When running in vSphere, this exposes information about those containers to the standard vSphere management tools in the same way that VMware tools do for VM operations. With VMworld coming up this week, we thought it would be interesting to demonstrate how Puppet can help with managing Photon OS hosts.

We don’t have a native agent at the moment for Photon OS. But we recently made puppet-agent available on Docker Hub. Photon OS is designed to run containers, so why not run Puppet in one as well? Along with new features available in the 1.6 release of Puppet agent shipped just last week, we can extend our management to Photon OS-based machines.

Running a Photon OS Host

Standing up your own Photon OS host for testing couldn't be simpler. The official documentation provides an ISO image, as well as an OVA and images for launching in GCE and EC2. VMware, handily, also makes available a Vagrant box running PhotonOS. Logged into a Photon OS host, we can now try out Puppet.

Using Facter With Photon OS

We’ll start by demonstrating Facter. Facter is a low-level tool used by Puppet to provide context to your Puppet code. Facter provides a simple cross-platform interface (for both humans and machines) to system-level information about the host — for instance, the network configuration, available memory or operating system version.

docker run --rm --privileged --net host -v /etc:/etc -v /var:/var -v /usr:/usr -v /lib64:/lib64 puppet/facter os

This should correctly identify Photon as the operating system, along with details of the version number. For instance:

{
  architecture => "x86_64",
  family => "RedHat",
  hardware => "x86_64",
  name => "PhotonOS",
  release => {
    full => "1.0",
    major => "1",
    minor => "0"
  },
  selinux => {
    enabled => false
  }
}

A quick note on all those arguments: Facter is available in the puppet/facter image on Docker Hub. But you’re interested in information about the host, not about the container. So we mount a series of folders from the host, and connect the running container to the host network.

Using Puppet with Photon OS

Lets try another example. We’ll use the puppet-agent image, and we’ll use the puppet resource subcommand to list out all the packages installed on the host

docker run --rm --privileged --net host -v /etc:/etc -v /var:/var -v /usr:/usr -v /lib64:/lib64 puppet/puppet-agent resource package --param provider

Here’s a sample of the output. As you can see Puppet is correctly picking up packages managed by the tdnf package management tool used by Photon OS.

package { 'xml-security-c':
  ensure   => '1.7.3-2.ph1',
  provider => 'tdnf',
}
package { 'xz':
  ensure   => '5.2.2-2.ph1',
  provider => 'tdnf',
}
package { 'zlib':
  ensure   => '1.2.8-3.ph1',
  provider => 'tdnf',
}

We’re just using puppet resource as an example here. You can also use puppet agent or apply to make changes to the underlying Photon OS host. For instance, let’s ensure rsync is installed using Puppet.

docker run --rm --privileged --net host -v /etc:/etc -v /var:/var -v /usr:/usr puppet/puppet-agent apply -e 'package { "rsync": ensure => installed }'

Assuming rsync wasn’t already installed, this should output something like the following:

Notice: Compiled catalog for photon in environment production in 0.61 seconds
Notice: /Stage[main]/Main/Package[rsync]/ensure: created
Notice: Applied catalog in 1.11 seconds

The same image can also be used to run a full Puppet agent and connect to your Puppet master. Here we daemonize the container so it will keep running, and the agent will contact the Puppet master at puppet.example.com. The image is simply exposing Puppet as the entry point for the container, so any standard Puppet command line parameters and arguments will work.

docker run -D --hostname agent --rm --privileged --net host -v /etc:/etc -v /var:/var -v /usr:/usr puppet/puppet-agent agent --no-daemonize --server puppet.example.com 

We run the Puppet agent in the foreground (with the --no-daemonize flag), as the Docker container itself deals with the daemonizing the process due to the -D flag on docker run.

Hopefully, the above is enough to get you started adding Photon OS hosts to your existing Puppet-managed infrastructure. If you’re interested in other examples, or what else you can do with Puppet and Photon OS (or other VMware products like vRealize Automation or vSphere), then do visit the Puppet booth at VMworld, or let us know in the comments for this post.

Download the ‘Practical Blueprint to Continuous Delivery’ to learn how Automic Release Automation can help you begin or continue your company’s digital transformation.

Topics:
puppet ,vmware

Published at DZone with permission of Gareth Rushgrove, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}