Puppet Bolt is an open-source IT automation tool that allows you to execute commands, scripts, and tasks across remote nodes without needing an agent installed. It provides a simple yet powerful way to automate manual sysadmin work and achieve consistency across your infrastructure. In this comprehensive guide, we will cover how to install Bolt and use it to run commands, scripts, tasks and more across remote Linux and Windows systems.
Introduction to Puppet Bolt
Puppet Bolt is developed by Puppet, the leading developer of open source infrastructure automation software. Some key highlights of Bolt:
Agentless – No need to install any agent/client software on remote nodes. Works over SSH/WinRM.
Efficient – Can run tasks on thousands of nodes in parallel. Saves huge time compared to manual work.
Powerful – Supports executing commands, scripts, tasks, file uploads/downloads on remote nodes.
Simple – Very easy to get started. YAML based inventory system to manage nodes.
Secure – Relies on SSH or WinRM for transport. Supports RBAC and secrets management.
Bolt allows you to reuse existing scripts and commands. It is cross-platform and can be installed on Linux, Windows and macOS systems. The major benefits of using Bolt include:
- Time savings from automating repetitive tasks
- Consistency and reliability in task execution
- Easy sharing and reuse of tasks across nodes
- No dependency on any agent software
Next, let us look at how to install Bolt on Linux systems.
Installing Bolt on Linux
The following installation steps work for Debian/Ubuntu flavors of Linux. For other distros like RHEL/CentOS, the setup is very similar – just use the relevant package manager instead of apt.
- Ruby 2.4 or higher
- SSH connectivity between nodes for remote execution
First, add the Puppet repository:
wget https://apt.puppet.com/puppet6-release-bionic.deb sudo dpkg -i puppet6-release-bionic.deb
Next, update the packages and install the bolt package:
sudo apt-get update sudo apt-get install puppet-bolt
bolt command can now be used to run Bolt tasks.
Configuring SSH Access
Bolt relies on SSH connectivity between the control machine and remote nodes for executing tasks. Passwordless SSH using key based authentication must be set up.
Generate an SSH key pair on the control node:
ssh-keygen -t rsa
Copy the public key to all remote nodes:
Confirm you can SSH into remote hosts without a password prompt. Bolt uses this SSH connection for remote execution.
Writing Bolt Commands
bolt command is used to invoke Bolt functionality. Some examples of using Bolt:
Run a command on remote Linux nodes:
bolt command run ‘uname -a‘ --nodes node1,node2
Run a PowerShell command on Windows nodes:
bolt command run ‘Get-Process‘ --nodes win1,win2
Run a local script on remote nodes:
bolt script run /local/script.sh --nodes node1,node2
Tasks encapsulate scripts/code into reusable units. Example installing a package using a built-in package task:
bolt task run package action=install name=nginx --nodes web1,web2
Upload a file to multiple nodes:
bolt file upload /local/file.txt /remote/dir --nodes node1,node2
There are many more capabilities like running plans, executing queries, applying Puppet code and more.
Using Bolt Inventory
Bolt uses an inventory file (inventory.yaml by default) to store node information. This allows querying nodes by defined groups and setting config options.
Example inventory file:
--- groups: - name: web_servers nodes: - node1 - node2 - name: db_servers nodes: - node3 - node4 config: ssh: host-key-check: false
The inventory can then be referenced in Bolt commands:
bolt task run package action=install name=nginx --inventoryfile inventory.yaml
Puppet Bolt provides a very powerful way to automate tasks across remote nodes. Some key takeaways:
- Install Bolt on your preferred platform like Linux, Windows or MacOS
- Setup SSH or WinRM for connectivity across nodes
- Use Bolt to execute commands, scripts, tasks, upload files and more
- Manage nodes in an inventory file for easy access
- Reuse existing scripts and commands for time savings
Bolt allows infrastructure automation in a simple yet powerful manner without requiring any agents on remote nodes. To learn more, visit the Puppet Bolt docs at https://puppet.com/docs/bolt/latest/bolt.html.