Opsview Knowledge Center

Configuration

How to configure the Opsview Monitor playbooks in Puppet

We will need to create some files in order to get puppet ready to automatically import Opsview hosts.

/etc/puppet/opsview.conf

You will need to create this file in the following format on each client that you wish to connect with an Opsview server. The user account must have a role with appropriate CONFIGURATION permissions:

url: http://opsview.example.com/rest
username: foobar
password: foobaz

You should use https to ensure the connection is secured to the Opsview server, but this may not always be possible if you use a self-signed certificate.

modules/opsview/manifests/init.pp

init.pp will define the “opsview” class, which provides an exported resource to collect host information from puppet nodes.It also defines an “opsview::manage” class that will be used by the “manage” node to collect all of the host information and send it to Opsview.

class opsview (
         #Default settings
         $opsview_hostgroup = $opsview::params::opsview_hostgroup,
         $opsview_host_templates = $opsview::params::opsview_host_templates,
         $opsview_reload = $opsview::params::opsview_reload,
         $opsview_keywords = $opsview::params::opsview_keywords,
        ) inherits opsview::params {
        @@opsview_monitored {$fqdn:
          ip => $ipaddress,
          hostgroup => $opsview_hostgroup,
          hosttemplates => $opsview_host_templates,
          reload_opsview => $opsview_reload,
          keywords => $opsview_keywords,
          tag => ['opsview']
        }
}
class opsview::manage {
        Opsview_monitored <<| tag == 'opsview' |>>
}

modules/opsview/manifests/params.pp

params.pp will set the default values that are used by the exported resource defined in init.pp; feel free to modify these as needed.

class opsview::params {
        $opsview_hostgroup="Monitoring Servers"
        $opsview_host_templates=['Network - Base']
        $opsview_keywords=[]
        $opsview_reload=false
}

Setting up site.pp

Now that init.pp and params.pp have been set up for the Opsview puppet module, we can update our site.pp to make use of our new opsview classes.

node default {
        include opsview
}
node 'puppetmaster.yourdomain.com' {
        include opsview
        include opsview::manage
}
node 'ciscoswitch.yourdomain.com' {
        class {'opsview':
          opsview_host_templates => ['Network - Base', 'Network - Cisco'],
          opsview_keywords => ['cisco', 'network']
        }
}

In the above example, the ‘puppetmaster.yourdomain.com’ node will send its host information to puppetdb using the ‘opsview’ class.In addition to this, it will gather all of the host information from puppetdb and send it over to Opsview using the ‘opsview::manage’ class.

Our ‘ciscoswitch.yourdomain.com’ node is also calling the ‘opsview’ class, but is overriding the default values for opsview_host_templates and opsview_keywords.

Configuration

How to configure the Opsview Monitor playbooks in Puppet