From d62c04f64257860a02be7bf3a6293c97029caeb5 Mon Sep 17 00:00:00 2001 From: Matthew Alexander LaChance Date: Wed, 7 Aug 2024 09:45:05 -0400 Subject: [PATCH] Parameterize the node exporter promfile directory owner Puppetserver needs puppet to own this directory. --- manifests/profile/prometheus/exporter/node.pp | 3 ++- spec/classes/profile/prometheus/exporter/node_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/manifests/profile/prometheus/exporter/node.pp b/manifests/profile/prometheus/exporter/node.pp index b637f7cf8..ddfa86818 100644 --- a/manifests/profile/prometheus/exporter/node.pp +++ b/manifests/profile/prometheus/exporter/node.pp @@ -24,6 +24,7 @@ Optional[String] $version = undef, Array $covered_datacenters = [], String $default_datacenter = 'default', + String $promfile_owner = 'prometheus', ) { $log_file = '/var/log/prometheus-node-exporter.log' @@ -90,7 +91,7 @@ file { '/var/lib/prometheus/node-exporter': ensure => 'directory', mode => '2775', - owner => 'prometheus', + owner => $promfile_owner, group => 'prometheus', } diff --git a/spec/classes/profile/prometheus/exporter/node_spec.rb b/spec/classes/profile/prometheus/exporter/node_spec.rb index 91c1a78d8..643aee8f4 100644 --- a/spec/classes/profile/prometheus/exporter/node_spec.rb +++ b/spec/classes/profile/prometheus/exporter/node_spec.rb @@ -79,6 +79,13 @@ .that_requires('File[/var/lib/prometheus]') end + context 'with promfile_owner set to brlglph' do + let(:params) { { promfile_owner: 'brlglph' } } + + it { is_expected.to contain_file('/var/lib/prometheus/node-exporter').with_owner('brlglph') } + it { is_expected.to contain_file('/var/lib/prometheus/node-exporter').with_group('prometheus') } + end + it do is_expected.to contain_file('/var/lib/prometheus') .with_ensure('directory')