What Is Bolt?
Bolt is an agentless automation tool from the Puppet family. It connects to servers over SSH (Linux) or WinRM (Windows), runs a command, script, task or plan, and prints the result. Nothing has to be installed on the targets except what the connection needs.
| Puppet agent | Bolt |
| Style | Desired state, runs every 30 minutes by itself | On demand, runs when you ask |
| Needs an agent | Yes, with certificates | No (SSH or WinRM only) |
| Best for | Keeping configuration correct over time | One-off actions: patching, restart, health checks, orchestration |
| Language | Puppet manifests | Commands, scripts, tasks (any language), plans (YAML or Puppet) |
Both together: Many teams use both. The agent keeps servers configured. Bolt triggers actions at the right moment, for example 'drain the node, patch, reboot, check, add back'.
Install Bolt
bash
# Use the package for your platform from the Puppet download page, then:
sudo dnf install -y puppet-bolt # or apt install puppet-bolt
brew install --cask puppetlabs/puppet/puppet-bolt # macOS
choco install puppet-bolt # Windows
bolt --versio
Version note: Bolt is released separately from the Puppet agent, and new features arrive often. Check bolt --version and the release notes for your version.
First Commands
bash
bolt command run 'uptime' --targets web01.example.com --user alice --private-key ~/.ssh/id_ed25519
bolt command run 'systemctl is-active nginx' --targets web01,web02,web03 --user alice
bolt command run 'hostname' --targets ssh://web01.example.com:2222 --user alice
bolt command run 'Get-Service W32Time' --targets winrm://win01.example.com --user Administrator --password-prompt
bolt command run 'whoami' --targets localhost
| Option | Meaning |
-t, --targets | Comma-separated list, group name, or query |
-u, --user, --private-key, --password-prompt | Credentials |
--run-as root | Switch to another user (uses sudo) |
--sudo-password-prompt | Ask for the sudo password |
--no-host-key-check | Skip host key verification (lab only) |
--format json | Machine readable output |
--concurrency 50 | How many targets at once (default 100) |
--no-verbose, --log-level debug | Control logging |
Run a Script
bash
cat > check_disk.sh <<'EOF'
#!/bin/bash
echo "Host: $(hostname)"
df -h / | tail -1
EOF
bolt script run ./check_disk.sh --targets web01,web02 --user alice --run-as root
# With arguments
bolt script run ./backup.sh --targets db01 --user alice -- /var/lib/mysql /backup
Upload and Download
bash
bolt file upload ./app.conf /etc/app/app.conf --targets web01,web02 --user alice --run-as root
bolt file download /var/log/app.log ./logs/ --targets web01 --user alice
A Bolt Project
For anything beyond one-liners, create a project directory. Bolt reads its configuration from files in it.
bash
mkdir ops-bolt && cd ops-bolt
bolt project init ops --modules puppetlabs-package # creates bolt-project.yaml and inventory.yaml
text
ops-bolt/
bolt-project.yaml project settings and modules
inventory.yaml your targets and groups
Puppetfile modules Bolt needs (installed with bolt module install)
modules/ your own modules with tasks and plans
ops/
tasks/restart_app.sh
tasks/restart_app.json
plans/patch.pp (or patch.yaml)
Inventory: Targets and Groups
yaml
# inventory.yaml
---
config:
ssh:
user: alice
private-key: ~/.ssh/id_ed25519
host-key-check: true
run-as: root
groups:
- name: web
targets:
- web01.example.com
- web02.example.com
- name: web03.example.com
config:
ssh:
port: 2222
vars:
role: webserver
env: production
- name: db
targets:
- db01.example.com
vars:
role: database
- name: windows
targets:
- win01.example.com
- win02.example.com
config:
transport: winrm
winrm:
user: Administrator
password:
_plugin: prompt
message: 'Windows password'
ssl: true
- name: all_servers
groups: [web, db]
bash
bolt inventory show --targets all
bolt inventory show --targets web --detail
bolt command run 'uptime' --targets web
bolt command run 'uptime' --targets 'web,db'
bolt command run 'uptime' --targets all_servers --concurrency 10
Dynamic targets from PuppetDB or the cloud
yaml
# inventory.yaml with the PuppetDB plugin
version: 2
groups:
- name: ubuntu_nodes
targets:
- _plugin: puppetdb
query: "inventory[certname] { facts.os.name = 'Ubuntu' }"
uri: certname
config:
puppetdb:
server_urls: ['https://puppetdb.example.com:8081']
cacert: ~/.puppetlabs/bolt/ssl/ca.pem
Other plugins read targets from AWS, Azure, GCP, Terraform state, Vagrant and more, so your inventory stays correct without manual edits.
Tasks
A task is a script with a defined interface: it receives parameters as environment variables (PT_name) or JSON on stdin, and returns text or JSON. Tasks can be written in Bash, Python, PowerShell or anything executable. A JSON file describes the task for Bolt, the console and validation.
bash
# modules/ops/tasks/restart_app.sh
#!/bin/bash
service="${PT_service:-nginx}"
if systemctl restart "$service"; then
echo "{\"service\": \"$service\", \"status\": \"restarted\"}"
else
echo "{\"_error\": {\"msg\": \"restart failed\", \"kind\": \"ops/restart-failed\"}}"
exit 1
fi
json
{
"description": "Restart a service",
"input_method": "environment",
"supports_noop": false,
"parameters": {
"service": {
"description": "Name of the service",
"type": "Optional[String[1]]"
}
}
}
bash
bolt task show # list tasks
bolt task show ops::restart_app # help for one task
bolt task run ops::restart_app service=nginx --targets web
bolt task run package action=status name=openssl --targets web # built-in package task
bolt task run service action=restart name=nginx --targets web
bolt task run ops::restart_app service=app --targets web --params '{"service":"app"}' --format jso
Built-in Tasks Worth Knowing
| Task | Use |
package | Install, upgrade, uninstall, status |
service | start, stop, restart, enable, status |
facts | Collect facts |
reboot | Reboot and wait for the node |
puppet_agent::install | Install the Puppet agent on nodes |
puppet_conf | Read or set Puppet settings |
apply_helpers::... | Support apply blocks |
Apply Puppet Code with Bolt
Bolt can compile Puppet code locally and apply the catalog on remote targets, with no Puppet server.
bash
bolt apply manifests/site.pp --targets web
bolt apply --execute 'package { "htop": ensure => installed }' --targets web --noop
Output and Results
bash
bolt command run 'hostname -f' --targets all --format json | jq '.items[] | {target, status, value: .value.stdout}'
bolt command run 'cat /etc/os-release' --targets web --format human
bolt command run 'systemctl is-active nginx' --targets web --no-verbose --rerun failure # run again only on failed targets
bolt command run 'uptime' --targets web --save-reru
Security Basics
- Use SSH keys, not passwords, and
host-key-check: true
- Use
run-as: root with sudo rules instead of logging in as root
- Keep passwords out of the inventory using plugins (
prompt, env_var, Vault, pkcs7 encrypted values)
- Limit what the Bolt user can run with
sudoers where possible
- Review tasks like any other code before running on production
Practice Tasks
- Install Bolt and run
uptime on two lab VMs
- Write an inventory with groups
web and db and variables
- Write a task that prints disk usage with a parameter for the mount point
- Run the built-in
package task to check the installed version of OpenSSL on all nodes
- Use
bolt apply --noop to preview a small manifest
Conclusion
Bolt gives agentless, on-demand control. Use an inventory with groups, run commands and scripts, wrap repeatable actions into tasks, and keep the Puppet agent for continuous configuration.
Quick Summary: bolt command/script/task/file; inventory.yaml groups; tasks with PT_ params; apply for manifests; agent for state.