Last Updated: July 25, 2019
·
4.011K
· firebladee

Check_mk & Puppet

If you are using puppet and checkmk then why not get puppet to install the checkmk server - in this case omd - and also get puppet to install check_mk agents and update the server with the new agent details.

I have created two recipes. One for creating omd sites and the second one for check_mk.

https://github.com/Firebladee/Puppet/blob/master/modules/omd/manifests/site/add.pp
https://github.com/Firebladee/Puppet/tree/master/modules/check_mk

Lets look at the easy one first.

The omd recipe will create the omd sites that you need. In nodes.pp add

$omd_site = "DEV1"
include omd
include omd::site::add

For Multiply sites then :

$omd_site = ["DEV1", "site2"]
include omd
include omd::site::add

One day I will change that to a class but for now it will do.
check_mk
This recipe will install the checkmk agent on target machines and will update the checkmk server with the new agent.

TO add a new agent.

class { "check_mk":
    install     => "agent",
    omd_site    => "ALL",
}

To add parents

class { "check_mk":
    install     => "agent",
    omd_site    => "ALL",
    parents     => "172.18.145.11"
}

To add tags

class { "check_mk":
    install     => "agent",
    omd_site    => ["ALL", "DEV2"],
    check_mk_tags   => ["SSH", "Management"]
}

For host alias

class { "check_mk":
    install     => "agent",
    omd_site    => "ALL",
    check_mk_alias  => "This server does nothing"
}

Server
To add the server

class { "check_mk":
    install     => "server",
    omd_site    => ["DEV1, "ALL"]
}

Working examples:
Server

node "omd.test.com" inherits default {
    $yum_extrarepo  = "puppetlabs"
    $omd_site       = ["DEV5", "DEV1", "DEV2", "DEV3", "DEV4", "ALL"]

    include yum
    include omd
    include omd::site::add
    include sudo
    include ntp

    class { "check_mk":
            install         => "server",
            omd_site        => ["DEV5", "DEV1", "DEV2", "DEV3", "DEV4", "ALL"],
            parents         => "172.18.145.11",
            check_mk_tags   => "Management"
    }
}

Agents

 node "puppet.test.com" inherits default {
    $yum_extrarepo  = "puppetlabs"

    include yum
    class { "check_mk":
            install         => "agent",
            omd_site        => "ALL",
            parents         => "172.18.145.11",
            check_mk_tags   => "Management"
    }
    include ntp
}

node "app01.something.com" {
    $yum_extrarepo  = ["puppetlabs", "spacewalk-client"]

    include yum
    class { "check_mk":
            install         => "agent",
            omd_site        => ["ALL", "DEV1"],
            check_mk_tags   => "DEV1",
    }
    include hosts::allow
    include ntp
    include puppet
}