Skip to content

Commit

Permalink
(profile::core::common) add manage_node_exporter param
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Nov 9, 2023
1 parent 3d40c48 commit efe3250
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 11 deletions.
2 changes: 2 additions & 0 deletions hieradata/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,5 @@ ipmi::networks:
nm::conf:
main:
dns: "none"

prometheus::node_exporter::version: "1.6.1"
3 changes: 2 additions & 1 deletion hieradata/role/rke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ cni::plugins::checksum: "f3a841324845ca6bf0d4091b4fc7f97e18a623172158b72fc3fdcdb
cni::plugins::enable: ["macvlan"]
cni::plugins::version: "1.2.0"
profile::core::helm::version: "3.5.4"
profile::core::kernel::devel: true
profile::core::kernel::debuginfo: true
profile::core::kernel::devel: true
profile::core::common::manage_node_exporter: false
profile::core::rke::version: "1.3.12"

files:
Expand Down
8 changes: 8 additions & 0 deletions site/profile/manifests/core/common.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
# @param manage_resolv_conf
# If `true`, manage resolv.conf
#
# @param manage_node_exporter
# If `true`, install prometheus node_exporter
#
class profile::core::common (
Boolean $manage_puppet_agent = true,
Boolean $manage_chrony = true,
Expand All @@ -53,6 +56,7 @@
Boolean $manage_repos = true,
Boolean $manage_irqbalance = true,
Boolean $manage_resolv_conf = true,
Boolean $manage_node_exporter = true,
) {
include auditd
include accounts
Expand Down Expand Up @@ -117,6 +121,10 @@
include telegraf
}

if $manage_node_exporter {
include prometheus::node_exporter
}

if $manage_firewall {
include firewall
}
Expand Down
22 changes: 22 additions & 0 deletions spec/classes/core/common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ class { 'sssd': service_names => ['sssd'] }
it { is_expected.to contain_class('resolv_conf') }
end
end

context 'with manage_node_exporter param' do
context 'when false' do
let(:params) do
{
manage_node_exporter: false,
}
end

include_examples 'no node_exporter'
end

context 'when true' do
let(:params) do
{
manage_node_exporter: true,
}
end

it { is_expected.to contain_class('prometheus::node_exporter') }
end
end
end
end
end
15 changes: 6 additions & 9 deletions spec/hosts/roles/rke_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

require 'spec_helper'

shared_examples 'generic rke' do
shared_examples 'generic rke' do |facts:|
include_examples 'common', facts: facts, node_exporter: false
include_examples 'debugutils'
include_examples 'docker'
include_examples 'rke profile'
Expand Down Expand Up @@ -47,8 +48,7 @@

it { is_expected.to compile.with_all_deps }

include_examples 'common', facts: facts
include_examples 'generic rke'
include_examples 'generic rke', facts: facts

it do
is_expected.to contain_class('rke').with(
Expand All @@ -67,8 +67,7 @@

it { is_expected.to compile.with_all_deps }

include_examples 'common', facts: facts
include_examples 'generic rke'
include_examples 'generic rke', facts: facts

it do
is_expected.to contain_class('rke').with(
Expand All @@ -87,8 +86,7 @@

it { is_expected.to compile.with_all_deps }

include_examples 'common', facts: facts
include_examples 'generic rke'
include_examples 'generic rke', facts: facts

it do
is_expected.to contain_class('rke').with(
Expand All @@ -107,8 +105,7 @@

it { is_expected.to compile.with_all_deps }

include_examples 'common', facts: facts
include_examples 'generic rke'
include_examples 'generic rke', facts: facts

it do
is_expected.to contain_class('rke').with(
Expand Down
8 changes: 7 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def node_files

# XXX The network param is a kludge until the el8 dnscache nodes are converted
# to NM.
shared_examples 'common' do |facts:, no_auth: false, chrony: true, network: true|
shared_examples 'common' do |facts:, no_auth: false, chrony: true, network: true, node_exporter: true|
include_examples 'bash_completion', facts: facts
include_examples 'convenience'
include_examples 'telegraf'
Expand Down Expand Up @@ -269,6 +269,12 @@ def node_files
end
end

if node_exporter
include_examples 'node_exporter'
else
include_examples 'no node_exporter'
end

if facts[:os]['family'] == 'RedHat'
it { is_expected.to contain_class('epel') }
it { is_expected.to contain_class('yum::plugin::versionlock').with_clean(true) }
Expand Down
9 changes: 9 additions & 0 deletions spec/support/spec/prometheus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

shared_examples 'node_exporter' do
it { is_expected.to contain_class('prometheus::node_exporter').with_version('1.6.1') }
end

shared_examples 'no node_exporter' do
it { is_expected.not_to contain_class('prometheus::node_exporter') }
end

0 comments on commit efe3250

Please sign in to comment.