Linux, Windows, Virtualization, OpenSource & Blogging

Puppet Bolt – Run Ad hoc Commands, Scripts, Puppet Tasks and Plans


Puppet Bolt is an open source, agentless task runner that executes commands, scripts, and ad hoc tasks across your infrastructure.

Bolt has built-in command line interface and connects to remote systems via SSH and WinRM on Linux and Windows respectively.

Bolt can:

  • Execute commands on remote systems.
  • Upload and execute scripts written in Bash, Python, PowerShell and other languages.
  • Run puppet tasks on remote systems that don’t have puppet agent installed.
  • Support both password and passwordless communication.

Puppet Bolt uses an internal version of puppet agent for executing tasks on remote machines, so you can run a task on remote machines that has puppet agent installed without any problem.

Puppet Bolt is still in the development stage.

We will install Bolt on *nix system and go through some of its functionalities.


Puppet Bolt

         Hostname: server.itzgeek.local
         IP Address:

Remote Machine

        Hostname: client.itzgeek.local
        IP Address:

Install Bolt

Bolt depends on gems, and you need to install Ruby, GCC compiler, and its dependencies. Install these packages on your Puppet Bolt machine.

### CentOS 7 / RHEL 7 ###

yum install -y make gcc ruby-devel

### Fedora ####

dnf install -y make gcc redhat-rpm-config ruby-devel rubygem-rdoc

### Debian 9 / Ubuntu 16.04 ###

apt-get update
apt-get install -y make gcc ruby-dev

Install Bolt as a gem.

gem install bolt

Bolt Command

As I said, Bolt can execute ad-hoc commands, run scripts, run puppet tasks or plans and upload files on remote nodes from your Bolt node.

Bolt commands typically contain the nodes in which you want to execute the commands on and also the user credential.

Example Ad-hoc command with username and password:

bolt command run <COMMAND> --nodes <NODE> --user <USER> --password <PASSWORD>

Example Ad-hoc command with passwordless authentication:

bolt command run <COMMAND> --nodes <NODE>


bolt command run <COMMAND> --nodes <NODE> --user <USER>

You can mention multiple nodes separated by a comma. Also, You can use the short flag, -n for –nodes, -u for –user and -p for –password in the command.

bolt command run <COMMAND> -n <NODE1,NODE2> -u <USER> -p <PASSWORD>

In our next chapter, we will go through capabilities of Puppet Bolt.

Running commands with Bolt

Let us run simple shell command on a remote machine with puppet Bolt.

In my case, I am running Bolt with uname -a command to get the machine detail of client.itzgeek.local (remote machine).

Below command uses password authentication. You can either use the hostname or IP address in the command.

To use the hostname in the command, you need to have DNS server configured in your environment.

READ: How to configure DNS server in CentOS 7 / RHEL 7

READ: How to configure DNS server in Debian 9 / Ubuntu 16.04

bolt command run 'uname -a' --nodes --user raj --password xxx


Linux client.itzgeek.local 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Ran on 1 node in 0.51 seconds

If you want to use passwordless authentication, then you can remove username and password flag from the above command.

If you are running Bolt to execute the command on a remote system for the first time that has never been ssh from the Bolt machine (server.itzgeek.local) then you might get an error.

Host key verification failed for fingerprint dd:c7:3e:07:95:0b:d5:cf:79:42:27:0d:52:eb:cf:62 is unknown for ""

Ran on 1 node in 0.07 seconds

To resolve the issue, ssh to the remote machine before running Bolt.

Example command for running the command on multiple nodes with password authentication.

bolt command run 'uname -a' --node, --user raj --password xxx

Likewise, you can run other shell commands using the above command.

Running script with Bolt

Let us run a simple shell script on a remote machine with puppet Bolt.

During the run, Bolt copies the script from the local Bolt machine to remote machine and executes it on the remote machine and then deletes it on completion from the remote machine.

Here, I am using a simple script to get the hostname and then will execute the same on the remote machine.


Content into the file.

echo "The remote hostname is `uname -n`"

Execute the shell script on the remote machine with Bolt.

bolt script run --nodes --user raj --password xxx


The remote hostname is client.itzgeek.local

Ran on 1 node in 0.88 seconds

You should get the output something like above. Same way, you can execute scripts written in other languages.

Uploading files with Bolt

You can easily upload files to remotes machines with Bolt. Typical upload file command will look like below.

bolt file upload <SOURCE> <DESTINATION> --nodes node1 --user raj --password xxx

For example, let us copy the /var/log/messages file to /tmp on the remote machine.

bolt file upload /var/log/messages /tmp/messages --nodes --user raj --password xxx


Uploaded '/var/log/messages' to ''

Ran on 1 node in 0.50 seconds

Uploaded file is at client.itzgeek.local:

[root@client ~]# ls -la /tmp/
total 96
drwxrwxrwt.  8 root root   188 Nov 11 03:53 .
dr-xr-xr-x. 17 root root   224 Sep 29 10:19 ..
drwxrwxrwt.  2 root root     6 Sep 29 10:14 .font-unix
drwxrwxrwt.  2 root root     6 Sep 29 10:14 .ICE-unix
-rw-rw-r--.  1 raj  raj  97891 Nov 11 03:53 messages
drwx------.  3 root root    17 Nov  8 12:06 systemd-private-b3716d92e1a74ed19f439c313ce75e1d-chronyd.service-QMmu0S
drwxrwxrwt.  2 root root     6 Sep 29 10:14 .Test-unix

Running Puppet task with Bolt

Read this page on how to run puppet tasks and plan using Bolt. You can run puppet tasks on the remote machine without the need of Puppet agent.

That’s All.


You might also like

Puppet Bolt – Run Ad hoc Commands, Scripts, Puppet Tasks and Plans