3
0

Merge branch 'jenkins-build-15' into 'master'

Auto-merge for build 15

See merge request puppet/prometheus_cd!14
This commit is contained in:
2025-10-18 10:38:44 +00:00
11 changed files with 374 additions and 17 deletions

View File

@@ -73,6 +73,11 @@
</li>
<li>
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Afirewall_3A_3Aiptables.html" title="puppet_classes::prometheus_cd::firewall::iptables (puppet_class)">prometheus_cd::firewall::iptables</a></span>
</li>
<li>
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Amain_3A_3Aconfig.html" title="puppet_classes::prometheus_cd::main::config (puppet_class)">prometheus_cd::main::config</a></span>

View File

@@ -43,49 +43,56 @@
</li>
<li id="object_puppet_classes::prometheus_cd::main::config" class="even">
<li id="object_puppet_classes::prometheus_cd::firewall::iptables" class="even">
<div class="item">
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Afirewall_3A_3Aiptables.html" title="puppet_classes::prometheus_cd::firewall::iptables (puppet_class)">prometheus_cd::firewall::iptables</a></span>
</div>
</li>
<li id="object_puppet_classes::prometheus_cd::main::config" class="odd">
<div class="item">
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Amain_3A_3Aconfig.html" title="puppet_classes::prometheus_cd::main::config (puppet_class)">prometheus_cd::main::config</a></span>
</div>
</li>
<li id="object_puppet_classes::prometheus_cd::main::dirs" class="odd">
<li id="object_puppet_classes::prometheus_cd::main::dirs" class="even">
<div class="item">
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Amain_3A_3Adirs.html" title="puppet_classes::prometheus_cd::main::dirs (puppet_class)">prometheus_cd::main::dirs</a></span>
</div>
</li>
<li id="object_puppet_classes::prometheus_cd::main::files" class="even">
<li id="object_puppet_classes::prometheus_cd::main::files" class="odd">
<div class="item">
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Amain_3A_3Afiles.html" title="puppet_classes::prometheus_cd::main::files (puppet_class)">prometheus_cd::main::files</a></span>
</div>
</li>
<li id="object_puppet_classes::prometheus_cd::main::install" class="odd">
<li id="object_puppet_classes::prometheus_cd::main::install" class="even">
<div class="item">
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Amain_3A_3Ainstall.html" title="puppet_classes::prometheus_cd::main::install (puppet_class)">prometheus_cd::main::install</a></span>
</div>
</li>
<li id="object_puppet_classes::prometheus_cd::main::service" class="even">
<li id="object_puppet_classes::prometheus_cd::main::service" class="odd">
<div class="item">
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Amain_3A_3Aservice.html" title="puppet_classes::prometheus_cd::main::service (puppet_class)">prometheus_cd::main::service</a></span>
</div>
</li>
<li id="object_puppet_classes::prometheus_cd::main::yumrepo" class="odd">
<li id="object_puppet_classes::prometheus_cd::main::yumrepo" class="even">
<div class="item">
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Amain_3A_3Ayumrepo.html" title="puppet_classes::prometheus_cd::main::yumrepo (puppet_class)">prometheus_cd::main::yumrepo</a></span>
</div>
</li>
<li id="object_puppet_classes::prometheus_cd::params" class="even">
<li id="object_puppet_classes::prometheus_cd::params" class="odd">
<div class="item">
<span class='object_link'><a href="puppet_classes/prometheus_cd_3A_3Aparams.html" title="puppet_classes::prometheus_cd::params (puppet_class)">prometheus_cd::params</a></span>
</div>

View File

@@ -0,0 +1,142 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Puppet Class: prometheus_cd::firewall::iptables
&mdash; Documentation by YARD 0.9.36
</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" />
<link rel="stylesheet" href="../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "puppet_classes::prometheus_cd::firewall::iptables";
relpath = '../';
</script>
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../puppet_class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../_index.html">Index (p)</a> &raquo;
<span class='title'><span class='object_link'>Puppet Classes</span></span>
&raquo;
<span class="title">prometheus_cd::firewall::iptables</span>
</div>
<div id="search">
<a class="full_list_link" id="puppet_class_list_link"
href="../puppet_class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Puppet Class: prometheus_cd::firewall::iptables</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd><span class='object_link'><a href="prometheus_cd_3A_3Aparams.html" title="puppet_classes::prometheus_cd::params (puppet_class)">prometheus_cd::params</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>
manifests/firewall/iptables.pp
</dd>
</dl>
</div>
<h2>Summary</h2>
Class manages the firewall rules for the prometheus_cd module.
<h2>Overview</h2>
<div class="docstring">
<div class="discussion">
<p>prometheus_cd::firewall::iptables.pp Module name: prometheus_cd Author: Arne Teuke (arne_teuke@confdroid.com)</p>
</div>
</div>
<div class="tags">
</div><div class="method_details_list">
<table class="source_code">
<tr>
<td>
<pre class="lines">
6
7
8
9
10
11
12
13
14
15
16</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'manifests/firewall/iptables.pp', line 6</span>
class prometheus_cd::firewall::iptables (
) inherits prometheus_cd::params {
if ($ps_prom_host == $fqdn) and ($ps_manage_fw == true) {
# main port
firewall { &quot;${ps_fw_prefix}${$ps_main_port} main port&quot;:
proto =&gt; &#39;tcp&#39;,
dport =&gt; $ps_main_port,
jump =&gt; &#39;accept&#39;,
}
}
}</pre>
</td>
</tr>
</table>
</div>
</div>
<div id="footer">
Generated by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>.
</div>
</div>
</body>
</html>

View File

@@ -104,7 +104,19 @@
6
7
8
9</pre>
9
10
11
12
13
14
15
16
17
18
19
20
21</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'manifests/main/dirs.pp', line 6</span>
@@ -112,6 +124,18 @@
class prometheus_cd::main::dirs (
) inherits prometheus_cd::params {
require prometheus_cd::main::install
if $ps_prom_host == fqdn {
file { $ps_main_dir:
ensure =&gt; directory,
owner =&gt; &#39;root&#39;,
group =&gt; &#39;root&#39;,
mode =&gt; &#39;0755&#39;,
selrange =&gt; s0,
selrole =&gt; object_r,
seltype =&gt; etc_t,
seluser =&gt; system_u,
}
}
}</pre>
</td>
</tr>

View File

@@ -120,7 +120,8 @@
22
23
24
25</pre>
25
26</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'manifests/main/service.pp', line 6</span>
@@ -128,7 +129,8 @@
class prometheus_cd::main::service (
) inherits prometheus_cd::params {
require prometheus_cd::main::files
if $manage_prometheus == true {
require prometheus_cd::firewall::iptables
if ($ps_prom_host == $fqdn) and ($manage_prometheus == true) {
service { &#39;prometheus&#39;:
ensure =&gt; running,
hasstatus =&gt; true,

View File

@@ -79,6 +79,8 @@
<span class='object_link'><a href="prometheus_cd_3A_3Amain_3A_3Ayumrepo.html" title="puppet_classes::prometheus_cd::main::yumrepo (puppet_class)">prometheus_cd::main::yumrepo</a></span><br/>
<span class='object_link'><a href="prometheus_cd_3A_3Afirewall_3A_3Aiptables.html" title="puppet_classes::prometheus_cd::firewall::iptables (puppet_class)">prometheus_cd::firewall::iptables</a></span><br/>
</dd>
</dl>
@@ -194,6 +196,78 @@
&mdash;
<div class='inline'>
<p>whether to manage node exporter</p>
</div>
</li>
<li>
<span class='name'>ps_manage_fw</span>
<span class='type'>(<tt>Boolean</tt>)</span>
<em class="default">(defaults to: <tt>false</tt>)</em>
&mdash;
<div class='inline'>
<p>whether to manage the firewall</p>
</div>
</li>
<li>
<span class='name'>ps_prom_host</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&#39;prometheus.example.net&#39;</tt>)</em>
&mdash;
<div class='inline'>
<p>the fqdn of the prometheus server</p>
</div>
</li>
<li>
<span class='name'>ps_fw_prefix</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&#39;50&#39;</tt>)</em>
&mdash;
<div class='inline'>
<p>the firewall rule prefix</p>
</div>
</li>
<li>
<span class='name'>ps_main_port</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>&#39;9090&#39;</tt>)</em>
&mdash;
<div class='inline'>
<p>the firewall main port for prometheus</p>
</div>
</li>
@@ -209,10 +283,6 @@
<pre class="lines">
11
12
13
14
15
16
17
@@ -226,18 +296,43 @@
25
26
27
28</pre>
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 11</span>
<pre class="code"><span class="info file"># File 'manifests/params.pp', line 15</span>
class prometheus_cd::params (
# installation
String $reqpackage_prom = &#39;prometheus2&#39;,
String $reqpackage_ne = &#39;node_exporter&#39;,
String $pkg_ensure = &#39;present&#39;,
# config logic
Boolean $manage_prometheus = false,
Boolean $manage_node_exporter = false,
Boolean $ps_manage_fw = false,
String $ps_prom_host = &#39;prometheus.example.net&#39;,
# firewall
String $ps_fw_prefix = &#39;50&#39;,
String $ps_main_port = &#39;9090&#39;,
) {
# defaults
@@ -246,6 +341,9 @@ class prometheus_cd::params (
$os_name = $facts[&#39;os&#39;][&#39;name&#39;]
$os_release = $facts[&#39;os&#39;][&#39;release&#39;][&#39;major&#39;]
# dirs
$ps_main_dir = &#39;/etc/prometheus&#39;
# includes must be last
include prometheus_cd::main::config
}</pre>

View File

@@ -0,0 +1,16 @@
# prometheus_cd::firewall::iptables.pp
# Module name: prometheus_cd
# Author: Arne Teuke (arne_teuke@confdroid.com)
# @summary Class manages the firewall rules for the prometheus_cd module.
##############################################################################
class prometheus_cd::firewall::iptables (
) inherits prometheus_cd::params {
if ($ps_prom_host == $fqdn) and ($ps_manage_fw == true) {
# main port
firewall { "${ps_fw_prefix}${$ps_main_port} main port":
proto => 'tcp',
dport => $ps_main_port,
jump => 'accept',
}
}
}

View File

@@ -6,4 +6,16 @@
class prometheus_cd::main::dirs (
) inherits prometheus_cd::params {
require prometheus_cd::main::install
if $ps_prom_host == fqdn {
file { $ps_main_dir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
selrange => s0,
selrole => object_r,
seltype => etc_t,
seluser => system_u,
}
}
}

View File

@@ -6,7 +6,8 @@
class prometheus_cd::main::service (
) inherits prometheus_cd::params {
require prometheus_cd::main::files
if $manage_prometheus == true {
require prometheus_cd::firewall::iptables
if ($ps_prom_host == $fqdn) and ($manage_prometheus == true) {
service { 'prometheus':
ensure => running,
hasstatus => true,

View File

@@ -7,14 +7,27 @@
# @param [String] pkg_ensure which version of the package to install
# @param [boolean] manage_prometheus whether to manage prometheus
# @param [boolean] manage_node_exporter whether to manage node exporter
# @param [boolean] ps_manage_fw whether to manage the firewall
# @param [String] ps_prom_host the fqdn of the prometheus server
# @param [String] ps_fw_prefix the firewall rule prefix
# @param [String] ps_main_port the firewall main port for prometheus
##############################################################################
class prometheus_cd::params (
# installation
String $reqpackage_prom = 'prometheus2',
String $reqpackage_ne = 'node_exporter',
String $pkg_ensure = 'present',
# config logic
Boolean $manage_prometheus = false,
Boolean $manage_node_exporter = false,
Boolean $ps_manage_fw = false,
String $ps_prom_host = 'prometheus.example.net',
# firewall
String $ps_fw_prefix = '50',
String $ps_main_port = '9090',
) {
# defaults
@@ -23,6 +36,9 @@ class prometheus_cd::params (
$os_name = $facts['os']['name']
$os_release = $facts['os']['release']['major']
# dirs
$ps_main_dir = '/etc/prometheus'
# includes must be last
include prometheus_cd::main::config
}

34
templates/prometheus.yaml Normal file
View File

@@ -0,0 +1,34 @@
global:
scrape_interval: 60s
scrape_timeout: 10s
evaluation_interval: 15s
storage:
tsdb:
out_of_order_time_window: 5m
alerting:
alertmanagers:
- follow_redirects: true
scheme: http
timeout: 10s
api_version: v2
static_configs:
- targets: []
scrape_configs:
- job_name: prometheus
honor_timestamps: true
scrape_interval: 60s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
follow_redirects: true
static_configs:
- targets:
- localhost:9090
basic_auth:
username_file: /etc/prometheus/secrets/prometheus-auth/username
password_file: /etc/prometheus/secrets/prometheus-auth/password
remote_write:
- url: "http://localhost:9090/api/v1/write"
basic_auth:
username_file: /etc/prometheus/secrets/prometheus-auth/username
password_file: /etc/prometheus/secrets/prometheus-auth/password