Skip to content

Commit 5a819eb

Browse files
committed
update security exporter to use Vuls server config
- Replace EPP template with stdlib::to_yaml inline config - Add vuls_server_url param with mTLS Puppet cert paths - Pass -config flag via prometheus::daemon options - Remove systemd dropin (handled by prometheus module) - Remove yum-plugin-changelog/security packages
1 parent 16f3722 commit 5a819eb

File tree

2 files changed

+25
-51
lines changed

2 files changed

+25
-51
lines changed

modules/enableit/common/manifests/monitor/exporter/security.pp

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
# @summary Prometheus Security Exporter
22
#
3+
# Collects installed packages and sends them to a Vuls server for
4+
# vulnerability scanning. Exposes CVE metrics via Prometheus.
5+
#
36
# @param enable Boolean flag to enable or disable the exporter. Defaults to false.
47
#
58
# @param noop_value Eit_types::Noop_Value flag to run in noop mode. Defaults to $common::monitor::exporter::noop_value.
69
#
7-
# @param host The host certificate name. Defaults to $trusted['certname'].
10+
# @param host The host certificate name, used for mTLS and scrape target. Defaults to $trusted['certname'].
811
#
912
# @param listen_host The host to listen on. Defaults to '127.254.254.254'.
1013
#
1114
# @param listen_port The port to listen on. Defaults to 63396.
1215
#
16+
# @param vuls_server_url The URL of the Vuls server to send package lists to. Defaults to 'https://vuls.obmondo.com'.
17+
#
1318
# @param config_file Path to the configuration YAML file. Defaults to "${common::monitor::exporter::config_dir}/security_exporter.yaml".
1419
#
1520
# @groups settings enable, noop_value
1621
#
1722
# @groups network host, listen_host, listen_port
1823
#
19-
# @groups configuration config_file
24+
# @groups configuration vuls_server_url, config_file
2025
#
2126
class common::monitor::exporter::security (
22-
Boolean $enable = false,
23-
Eit_types::Noop_Value $noop_value = $common::monitor::exporter::noop_value,
24-
Eit_types::Certname $host = $trusted['certname'],
25-
Stdlib::Host $listen_host = '127.254.254.254',
26-
Stdlib::Port $listen_port = 63396,
27-
Stdlib::Absolutepath $config_file = "${common::monitor::exporter::config_dir}/security_exporter.yaml"
27+
Boolean $enable = false,
28+
Eit_types::Noop_Value $noop_value = $common::monitor::exporter::noop_value,
29+
Eit_types::Certname $host = $trusted['certname'],
30+
Stdlib::Host $listen_host = '127.254.254.254',
31+
Stdlib::Port $listen_port = 63396,
32+
Stdlib::HTTPUrl $vuls_server_url = 'https://vuls.obmondo.com',
33+
Stdlib::Absolutepath $config_file = "${common::monitor::exporter::config_dir}/security_exporter.yaml",
2834
) {
2935

3036
unless $enable { return() }
@@ -47,16 +53,6 @@
4753
noop => $noop_value,
4854
}
4955

50-
if (($facts['os']['name'] == 'RedHat' or $facts['os']['name'] == 'CentOS') and (Integer($facts['os']['release']['major']) < 7)){
51-
package { 'yum-plugin-changelog':
52-
ensure => ensure_latest($enable),
53-
}
54-
55-
package { 'yum-plugin-security':
56-
ensure => ensure_latest($enable),
57-
}
58-
}
59-
6056
service { "${service_name}.service":
6157
ensure => ensure_service($enable),
6258
enable => $enable,
@@ -72,6 +68,7 @@
7268
package_ensure => ensure_latest($enable),
7369
init_style => $facts['service_provider'],
7470
install_method => 'package',
71+
options => "-config=${config_file}",
7572
tag => $::trusted['certname'],
7673
notify_service => Service[$service_name],
7774
group => 'root',
@@ -85,34 +82,22 @@
8582
scrape_job_labels => { 'certname' => $::trusted['certname'] },
8683
}
8784

88-
$_service = @("EOT"/$n)
89-
# THIS FILE IS MANAGED BY OBMONDO. CHANGES WILL BE LOST.
90-
[Service]
91-
ExecStart=
92-
ExecStart=/opt/obmondo/bin/obmondo-security-exporter -config=${config_file}
93-
| EOT
94-
95-
systemd::dropin_file { "${service_name}_dropin":
96-
ensure => ensure_file($enable),
97-
filename => "${service_name}-override.conf",
98-
unit => "${service_name}.service",
99-
content => $_service,
100-
notify => Service["${service_name}.service"],
101-
}
102-
10385
file { $config_file:
10486
ensure => ensure_file($enable),
10587
owner => 'root',
10688
group => 'root',
10789
mode => '0640',
108-
content => epp(
109-
'common/monitor/exporter/security_exporter.yaml.epp', {
110-
cve_api_url => 'https://services.nvd.nist.gov',
111-
server_host => $listen_host,
112-
server_port => $listen_port,
113-
cron_expr => '00 23 * * *',
90+
content => stdlib::to_yaml({
91+
'vuls_server' => {
92+
'url' => $vuls_server_url,
93+
'timeout' => '30s',
94+
'cert_file' => "/etc/puppetlabs/puppet/ssl/certs/${host}.pem",
95+
'key_file' => "/etc/puppetlabs/puppet/ssl/private_keys/${host}.pem",
96+
'ca_file' => '/etc/puppetlabs/puppet/ssl/certs/ca.pem',
11497
},
115-
),
98+
'listen_address' => "${listen_host}:${listen_port}",
99+
'push_interval' => '12h',
100+
}),
116101
notify => Service["${service_name}.service"],
117102
}
118103

modules/enableit/common/templates/monitor/exporter/security_exporter.yaml.epp

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)