Puppet Class: profile::netbox::host

Defined in:
modules/profile/manifests/netbox/host.pp

Summary

profile for collecting netbox host data

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • status (Netbox::Host::Status) (defaults to: lookup('profile::netbox::host::status'))

    the netbox status of the host or unknown

  • location (Optional[Netbox::Host::Location]) (defaults to: lookup('profile::netbox::host::location'))

    location data including site and cluster



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'modules/profile/manifests/netbox/host.pp', line 5

class profile::netbox::host (
    Netbox::Host::Status             $status   = lookup('profile::netbox::host::status'),
    Optional[Netbox::Host::Location] $location = lookup('profile::netbox::host::location'),
) {
    unless $status == 'active' {
        warning("${facts['networking']['fqdn']} is ${status} in Netbox")
    }
    $_status = $status ? {
        'active' => wmflib::ansi::fg($status, 'green'),
        default  => wmflib::ansi::fg($status, 'red'),
    }
    motd::message { 'netbox status':
        message  => "Netbox Status: ${_status}",
        priority => 1,
    }
    unless $location {
        warning("${facts['networking']['fqdn']}: no Netbox location found")
    } else {
        $message = $location ? {
            Netbox::Host::Location::Virtual => "Virtual Machine on Ganeti cluster ${location['ganeti_cluster']} and group ${location['ganeti_group']}",
            default                         => "Bare Metal host on site ${location['site']} and rack ${location['rack']}",
        }
        motd::message { 'netbox location':
            message => $message,
        }
    }
}