Using Puppet to install Filebeat RPM

Consistent and repeatable infrastructure is key in DevOps and and large scale deployments and today we will try to install Filebeat RPM package into CencOS machine.

Setup of CentOS

My main development machine is MBR and I don’t want to create any VM in DigitalOcean also so my best option is to use good old Vagrant. As I already have setup from my blog post about Creating custom RPM package of Filebeat.

But we still need clean machine so we will destroy the old one and create shiny new one. Below commands are executed in project directory where

vagrant destroy && vagrant up

We also need to install puppet agent into this machine we can do it by using vagrant shell provisioner when we want to repeat installation in some other machine. Below is VagrantFile with puppet-agent install script. Save it with name

The full and clear puppet installation instructions for CentOS can be found on Tecmint - Installing Puppet Master and Agent in RHEL/CentOS 7/6/5

#!/usr/bin/env bash

# If puppet command is present skip installation
if [ -x "$(command -v puppet)" ]; then
  echo 'Puppet already installed skip installation.' >&2
  exit 0

# Install RPM package
rpm -ivh

# Install puppet agent
yum install puppet-agent -y
puppet resource package puppet ensure=latest

# Restart puppet service
system puppet restart

Next we need to enable the script provisioner on vagrant in VagrantFile.

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config| = "boxcutter/centos72"

  config.vm.provision "shell", path: ""

Now we need to provision our running vagrant machine with command:

vagrant provision

Run filebeat puppet manifest

NOTE If You change the name of the puppet manifests directory name after vagrant machine has been restarted then You need to do vagrant reload to remap the shared directories.

Use Puppet 4 on Vagrant machine

Now that we have installed Puppet 4 node agent on our vagrant machine we need to enable puppet 4 support for vagrant also because current vagrant only supports by default puppet 3.

First create following directory structure in same directory where VagrantFile is placed.

$ tree
|-- puppet-env
|   `-- test
|       `-- manifests
|           `-- site.pp
`-- Vagrantfile

Then change VagrantFile like shown below:

Vagrant.configure("2") do |config| = "boxcutter/centos72"

  config.vm.provision "shell", path: ""
  config.vm.provision "puppet" do |puppet|
    puppet.environment_path = "puppet-env"
    puppet.environment = "dev"

Finally add below into site.pp file:

class filebeat {
  package { 'filebeat-5.4.1-x86_64':
    provider => 'rpm',
    ensure => present,
    install_options => ['-ivh'],
    source => "/tmp/filebeat-5.4.1-x86_64.rpm" ,
    require => File["/tmp/filebeat-5.4.1-x86_64.rpm"],

  file { "/tmp/filebeat-5.4.1-x86_64.rpm":
    source => ''

include filebeat

To apply these changes You just need to run:

vagrant provision

You should now have access to command when You login to Your vagrant machine.

Written on June 5, 2017