diff --git a/hieradata/common.yaml b/hieradata/common.yaml index 47859a6a22..3fcf33b2b8 100644 --- a/hieradata/common.yaml +++ b/hieradata/common.yaml @@ -468,3 +468,5 @@ ipmi::networks: nm::conf: main: dns: "none" + +prometheus::node_exporter::version: "1.6.1" diff --git a/hieradata/role/rke.yaml b/hieradata/role/rke.yaml index 56830c3e07..7c63f1a790 100644 --- a/hieradata/role/rke.yaml +++ b/hieradata/role/rke.yaml @@ -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: diff --git a/site/profile/manifests/core/common.pp b/site/profile/manifests/core/common.pp index db662e1f30..bfa7e1f25a 100644 --- a/site/profile/manifests/core/common.pp +++ b/site/profile/manifests/core/common.pp @@ -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, @@ -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 @@ -117,6 +121,10 @@ include telegraf } + if $manage_node_exporter { + include prometheus::node_exporter + } + if $manage_firewall { include firewall } diff --git a/spec/classes/core/common_spec.rb b/spec/classes/core/common_spec.rb index ff13b1b67e..3db30409dd 100644 --- a/spec/classes/core/common_spec.rb +++ b/spec/classes/core/common_spec.rb @@ -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 diff --git a/spec/hosts/roles/rke_spec.rb b/spec/hosts/roles/rke_spec.rb index 867ea5e291..b17add32c5 100644 --- a/spec/hosts/roles/rke_spec.rb +++ b/spec/hosts/roles/rke_spec.rb @@ -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' @@ -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( @@ -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( @@ -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( @@ -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( diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3ee5acd333..37f099e7ae 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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' @@ -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) } diff --git a/spec/support/spec/prometheus.rb b/spec/support/spec/prometheus.rb new file mode 100644 index 0000000000..8b90de6b4b --- /dev/null +++ b/spec/support/spec/prometheus.rb @@ -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