FOSS Project Spotlight: Run Remote Tasks on Linux and Windows with Puppet Bolt

Puppet Bolt

Puppet, the company that makes automation software for managing systems and delivering software, has introduced Puppet Bolt, an open-source, agentless multiplatform tool for running commands, scripts, tasks and orchestrated workflows on remote Linux and Windows systems.

The tool, which is freely available as a Linux package, Ruby gem and macOS or Windows installer, is ideal for sysadmins and others who want to perform a wide range of automation tasks on remote bare-metal servers, VMs or cloud instances without the need for any prerequisites. Puppet Bolt doesn't require any previous Puppet know-how. Nor does it require a Puppet agent or Puppet master. It uses only SSH and WinRM (or can piggyback Puppet transports) to communicate and execute tasks on remote nodes.

Despite its simplicity, Puppet Bolt can execute all your existing scripts written in Bash, PowerShell, Python or any other language, stop and start Linux or Windows services, gather information about packages and system facts, or deploy procedural orchestrated workflows, otherwise known as plans. You can do all this right from your workstation or laptop.

For those already using open-source Puppet or Puppet Enterprise, Puppet Bolt enables you to take advantage of the more than 5,700 modules available in the Puppet Forge for everything from deploying database servers to setting up Docker or Kubernetes. You also can query PuppetDB directly with Puppet Bolt.

Install Puppet Bolt and Run Some Tasks

You also can install Puppet Bolt with apt or yum once you add the Puppet repositories:


$ sudo apt install puppet-bolt

You can install Puppet Bolt on Windows with the available .msi, or if you're running Bash on Windows 10, by using the Linux instructions for the flavor you installed. Follow the link in the Resources section to see detailed installation instructions for your favorite platform.

If you're running Ruby (and have gcc and make on your workstation), you can get Puppet Bolt up and running in moments with the simple command:


$ gem install bolt

In just a few minutes, you're now ready to start running one-off commands, tasks, scripts or plans. Puppet Bolt is perfect for troubleshooting or deploying quick changes, distributing scripts to run across your infrastructure, or automating changes that need to happen in a particular order as part of an application deployment. See the built-in Puppet Bolt commands by running:


$ bolt help

Ad Choices Symbol

Figure 1. Built-in Puppet Bolt Commands

A typical Puppet Bolt command looks like this:


$ bolt <SUBCOMMAND> <ACTION> [options] --nodes <NODE> 

Where <SUBCOMMAND> can be a command, file, script, task or plan. Target nodes can be listed after the --nodes (or -n) flag or listed in a plain-text file. For example, check the uptime on all your nodes at once like this:


$ bolt command run uptime -n server01,server02,server03...

Or:


$ bolt command run uptime -n @mynodes.txt

When executing on WinRM nodes, indicate the WinRM protocol in the nodes string:


$ bolt command run <COMMAND> --nodes winrm://<WINDOWS.NODE> 
 ↪--user <USERNAME> --password <PASSWORD>

Running your existing tried and true scripts (written in any language) on remote nodes is just as simple:


$ bolt script run mypythonfile.py -n @mynodes.txt

Puppet Bolt really shines when it comes to tasks and plans that rely on more formal orchestration capabilities. You can view built-in Bolt tasks by executing $ bolt task show (Figure 2).

Ad Choices Symbol

Figure 2. Built-in Bolt Tasks

For example, if you want to stop, start or restart services on a Linux or Windows node, you could execute the following task:


$ bolt task run service::linux name=cron action=restart -n 
 ↪linuxnode01 

Or:


$ bolt task run service::windows name=Netman action=restart 
 ↪-n @windowsnodes.txt 

You also can use the task command to look at the status and version of a particular package or app on one or thousands of nodes:


$ bolt task run package name=cron action=status -n linuxnode01
Started on linuxnode01...
Finished on linuxnode01:
  {
   "status": "up to date",
   "version": "3.0pl1-128ubuntu2"
  }
Successful on 1 node: linuxnode01
Ran on 1 node in 2.10 seconds

Similarly, you can view built-in plans with the $ bolt plan show statement (Figure 3).

Built-in Bolt Plans

Figure 3. Built-in Bolt Plans

You can run these plans without any Puppet agent (or master), but if you want to take advantage of Puppet modules you've written or downloaded from the Forge, such as one to set up nodejs and connect it to your load balancer, you might do this by combining Puppet Bolt with a target node that already has the Puppet agent installed:


$ bolt plan run nodejs::myplan load_balancer=lb.myorg.com 

Not all modules require the Puppet agent. For example, Puppet Bolt can run the puppetlabs/aws module without it.

Puppet Bolt Is a Great On-Ramp to Puppet

Puppet Bolt is lightweight and easy to learn, with new features added regularly by Puppet's development team, making it an ideal replacement for Ansible, Rundeck, Bladelogic and even Bash and PowerShell scripts. Unlike tools with limited scope, Puppet Bolt treats every target node as a first-class citizen and lets you do everything from quick fixes to full app deployments.

At the same time, working with Puppet Bolt is a great way to introduce yourself to model-based automation, which Puppet pioneered and has become the de facto standard for organizations determined to reap the benefits of pervasive automation. You can use everything you learn with Puppet Bolt elsewhere in the Puppet universe, which means you and your DevOps teammates finally can share a common tool and expertise—without any prerequisites.

Resources

About the Author

John Tonello is Sr. Technical Marketing Manager for Puppet Inc. He's been a Linux user and enthusiast since building his first Slackware system from diskette 20 years ago.