Puppet Bolt

Puppet Bolt: an open source, agentless multi-platform automation tool that reduces your time to automation and makes it easier to get started with DevOps. This is similar to ansible. The Puppet task runner is driven through a command line interface and executes commands via SSH. So, you are not required to install any agent software on the remote nodes.

Install Bolt

Bolt can be install easily with puppet repo. Install pdk (puppet development kit) Install the Bolt package directly from http://apt.puppetlabs.com/ or http://yum.puppetlabs.com/

rpm -Uvh https://yum.puppet.com/puppet6/puppet6-release-el-7.noarch.rpm

[root@puppet ~]# yum install puppet-bolt Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: repos.del.extreme-ix.org * extras: repos.del.extreme-ix.org * updates: mirror.nbrc.ac.in base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 puppet6 | 2.5 kB 00:00:00 updates | 3.4 kB 00:00:00 yum.postgresql.org | 4.1 kB 00:00:00 (1/3): puppet6/x86_64/primary_db | 100 kB 00:00:00 (2/3): yum.postgresql.org/7/x86_64/primary_db | 211 kB 00:00:02 (3/3): updates/7/x86_64/primary_db | 3.4 MB 00:00:03 Resolving Dependencies --> Running transaction check ---> Package puppet-bolt.x86_64 0:1.16.0-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================================== Installing: puppet-bolt x86_64 1.16.0-1.el7 puppet6 28 M Transaction Summary =========================================================================================================================================================== Install 1 Package Total download size: 28 M Installed size: 93 M Is this ok [y/d/N]: y Downloading packages: puppet-bolt-1.16.0-1.el7.x86_64.rpm | 28 MB 00:00:15 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : puppet-bolt-1.16.0-1.el7.x86_64 1/1 Verifying : puppet-bolt-1.16.0-1.el7.x86_64 1/1 Installed: puppet-bolt.x86_64 0:1.16.0-1.el7 Complete! [root@puppet ~]# [root@puppet ~]# yum install pdk Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: repos.del.extreme-ix.org * extras: repos.del.extreme-ix.org * updates: mirror.nbrc.ac.in Resolving Dependencies --> Running transaction check ---> Package pdk.x86_64 0:1.10.0.0-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================================== Installing: pdk x86_64 1.10.0.0-1.el7 puppet6 193 M Transaction Summary =========================================================================================================================================================== Install 1 Package Total download size: 193 M Installed size: 193 M Is this ok [y/d/N]: y Downloading packages: pdk-1.10.0.0-1.el7.x86_64.rpm | 193 MB 00:01:44 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pdk-1.10.0.0-1.el7.x86_64 1/1 Verifying : pdk-1.10.0.0-1.el7.x86_64 1/1 Installed: pdk.x86_64 0:1.10.0.0-1.el7 Complete! [root@puppet ~]#

Command Run

Edit and save the following to inventory.yaml:

Setup password-less login to remote servers.

[root@puppet ~]# cat ~/.puppetlabs/bolt/inventory.yaml
---
nodes: [db01,db02]
config:
ssh:
host-key-check: false
[root@puppet ~]#
[root@puppet ~]# bolt command run uptime -n db02
Started on db02...
Finished on db02:
STDOUT:
18:16:06 up 2 min, 0 users, load average: 0.52, 0.61, 0.27
Successful on 1 node: db02
Ran on 1 node in 1.97 seconds
[root@puppet ~]#

[root@puppet ~]# bolt command run uptime -n db01 --user root --password
Please enter your password:
Started on db01...
Finished on db01:
STDOUT:
12:28:50 up 4:56, 1 user, load average: 0.00, 0.04, 0.05
Successful on 1 node: db01
Ran on 1 node in 0.89 seconds
[root@puppet ~]#

[root@puppet ~]# bolt command run uptime -n all
Started on db01...
Started on db02...
Finished on db01:
STDOUT:
12:30:12 up 4:58, 1 user, load average: 0.00, 0.03, 0.05
Finished on db02:
STDOUT:
18:19:36 up 6 min, 0 users, load average: 0.08, 0.32, 0.22
Successful on 2 nodes: db01,db02
Ran on 2 nodes in 0.79 seconds
[root@puppet ~]#

Script Run

We can run script in any language on the remote server.

[root@puppet ~]# cat tsk.sh
#!/bin/bash

uptime
uname -a
[root@puppet ~]#
[root@puppet ~]# bolt script run ./tsk.sh -n all
Started on db01...
Started on db02...
Finished on db02:
STDOUT:
18:28:25 up 15 min, 0 users, load average: 0.06, 0.09, 0.14
Linux db02 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Finished on db01:
STDOUT:
12:39:01 up 5:06, 1 user, load average: 0.00, 0.01, 0.05
Linux db01 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Successful on 2 nodes: db01,db02
Ran on 2 nodes in 1.64 seconds
[root@puppet ~]#

Conclusion:

We have successfully ran command and script on remote servers using bolt.

Enjoy !!!

One Comment

  1. Krishna Prajapati

    git clone git://github.com/centic9/generate-and-send-ssh-key

    cd generate-and-send-ssh-key
    ./generate-and-send-ssh-key.sh –user bob –host myhost

Leave a Reply

Your email address will not be published. Required fields are marked *