voxpupuli / puppet-prometheus

Puppet module for prometheus
https://forge.puppet.com/puppet/prometheus
Apache License 2.0
60 stars 241 forks source link

add prometheus::server:purge_rules parameter to enable purging in ${config_dir}/rules file resource? #631

Open slvr32 opened 2 years ago

slvr32 commented 2 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Create a file resource for $prometheus::server::config_dir/rules in a puppet profile

What are you seeing

notice the file resource conflict with the forge prometheus module

What behaviour did you expect instead

It would be nice to have a prometheus::server::purge_rules toggle for the ${config_dir}/rules file resource, to facilitate purging of old/unmanaged .rules files for a prometheus instance, so that that toggle could be used in the ${config_dir}/rules file resource in server.pp

Output log

Any additional information you'd like to impart

slvr32 commented 2 years ago

I figured out a solution with a tidy resource, using the following in a related puppet manifest

I have a bit of custom logic to create .rules files in the prometheus::config_dir/rules directory, but a tidy resource following the .rules files creation worked as I was hoping, not deleting .rules files that were already managed by puppet.

$config_dir = lookup('prometheus::config_dir')

tidy { "${config_dir}/rules":
  matches => '*.rules',
  recurse   => true,
}