Puppet Bolt is an open-source tool which is widely used to automate the manual work.

Bolt is based on Ruby and its command-line tool which get execute scripts, command on a local and remote server over SSH and WinRM. It helps Sysadmin to manage multiple servers in many ways.

Manage updates Software installation Logs reading Stop or start services Command execution

The good news is you don’t need to install any agent on the servers. It’s agentless.

Prerequisite

The following example is on Ubuntu so you need a Ubuntu VM with sudo access to root.

Update System

We highly recommend you to upgrade all the available repository and package before installing any new package on the system. Execute the following command and it’ll do the job for you.

Installing Puppet Bolt

Since its agentless, you don’t need to install on every server. Instead, just on one server which will act as a master which can be used to connect to remote servers. Bolt is a multi-platform tool so you can install on your favorite OS.

Windows macOS RHEL CentOS Fedora Debian Ubuntu

Refer to the official site for the latest available version. Let’s get this installed on Ubuntu. Run the following command to get the package. Next, install the above-downloaded package using the Debian package manager command. Again, update the system using the following command. Finally, execute the following command to install the bolt. You have successfully installed puppet bolt on your server. As mentioned earlier, Bolt connects to another server over SSH key so I assume you already have key exchanged between servers. If not, you can refer this guide to setup SSH key exchange. Let’s connect to remote servers and run bolt commands. To run a command on a single node use the following command. Please replace the COMMAND with the command you want to execute and NODE with the remote server’s hostname or IP. Similarly, you can also run a command on multiple nodes. If in case you need to add password authentication to a command then you can add it using the flags. Suppose you want to see how long system has been running then you will need to use uptime command like this: You should see the following output. It may possible that you want to run some command that contains the spaces so you’ll need to wrap the command in single quotation marks:

Running Scripts

We all have a set of scripts that we use regularly. Bolt makes it easy to reuse those script without any modification and run them on even more nodes simultaneously. All you need to do is specify the name and path of the script that you want to run. You should see the output something similar to this: You can run scripts in any language as long as the appropriate interpreter is installed on the remote system.

Automation with Task

The task is a set of actions that you want to run on remote machines. Tasks can be written in any language that runs on a remote node. Tasks make it easy to reuse and share scripts and helps you to achieve automation. You can download some existing tasks from Puppet forge and upload your tasks there as per your need. For example, if you want to check the status of the vim package then you can use the following command. You will see the output similar to this: If you don’t find the vim package installed then you can install it using the following command. You can run plan 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 Bolt installed. You can use puppet bolt to copy files on remote nodes. You can simply upload the file or directory to the remote node using the bolt file upload command. All you have to do is specify the path of the file on the local machine and destination on remote node. You can upload a file on multiple remote nodes simultaneously like this: A lot of possibilities as you can see.

Creating an Inventory file

Bolt allows you to create an inventory file that will store information about your nodes, tasks, and, configuration. You can specify different nodes in a group and the inventory file by default stored at inventory.yaml inside the project directory. Here is an example of creating an inventory file. You can replace these node1, node2, node3 with your actual node domain name or the IP address of your nodes. You can now add this inventory file into the bolt commands to execute tasks on the specified nodes. Conclusion I hope by now you have an idea about what Bolt is and how it can help you with the automation. You may also be interested in learning about Puppet.

How to Install Puppet Bolt to Automate Sysadmin tasks  - 46