Puppet Class: profile::prometheus::squid_exporter

Defined in:
modules/profile/manifests/prometheus/squid_exporter.pp

Overview

Parameters:

  • prometheus_nodes (Array[Stdlib::Fqdn]) (defaults to: lookup('prometheus_nodes'))
  • http_proxy (Stdlib::HTTPUrl) (defaults to: lookup('http_proxy', {'default_value' => undef}))


3
4
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
32
33
34
35
36
37
# File 'modules/profile/manifests/prometheus/squid_exporter.pp', line 3

class profile::prometheus::squid_exporter (
    Array[Stdlib::Fqdn] $prometheus_nodes = lookup('prometheus_nodes'),
    Stdlib::HTTPUrl $http_proxy = lookup('http_proxy', {'default_value' => undef}),
) {
    $prometheus_ferm_nodes = join($prometheus_nodes, ' ')
    $ferm_srange = "(@resolve((${prometheus_ferm_nodes})) @resolve((${prometheus_ferm_nodes}), AAAA))"

    # Note that prometheus-squid-exporter is only in buster and up
    require_package('prometheus-squid-exporter')

    service { 'prometheus-squid-exporter':
        ensure  => running,
        require => Service['squid'], # Squid and not Squid3 again on buster
    }

    if $http_proxy{
        $proxy_port = split($http_proxy, ':')[2]
        file { '/etc/default/prometheus-squid-exporter':
            owner   => 'root',
            group   => 'root',
            mode    => '0444',
            content => template('profile/prometheus/squid-exporter.conf.erb'),
            notify  => Service['prometheus-squid-exporter'],
        }
    }


    base::service_auto_restart { 'prometheus-squid-exporter': }

    ferm::service { 'prometheus-squid-exporter':
        proto  => 'tcp',
        port   => '9301',
        srange => $ferm_srange,
    }
}