Description: Support gnocchi_metricd.conf file. 
Author: Théo Gindre <theo.gindre@infomaniak.com>
Forwarded: no
Last-Update: 2025-03-17

Index: puppet-module-gnocchi/lib/puppet/provider/gnocchi_metricd_config/openstackconfig.rb
===================================================================
--- /dev/null
+++ puppet-module-gnocchi/lib/puppet/provider/gnocchi_metricd_config/openstackconfig.rb
@@ -0,0 +1,10 @@
+Puppet::Type.type(:gnocchi_metricd_config).provide(
+  :openstackconfig,
+  :parent => Puppet::Type.type(:openstack_config).provider(:ruby)
+) do
+
+  def self.file_path
+    '/etc/gnocchi/gnocchi-metricd.conf'
+  end
+
+end
Index: puppet-module-gnocchi/lib/puppet/type/gnocchi_metricd_config.rb
===================================================================
--- /dev/null
+++ puppet-module-gnocchi/lib/puppet/type/gnocchi_metricd_config.rb
@@ -0,0 +1,61 @@
+Puppet::Type.newtype(:gnocchi_metricd_config) do
+
+  ensurable
+
+  newparam(:name, :namevar => true) do
+    desc 'Section/setting name to manage from gnocchi-metricd.conf'
+    newvalues(/\S+\/\S+/)
+  end
+
+  newproperty(:value, :array_matching => :all) do
+    desc 'The value of the setting to be defined.'
+    def insync?(is)
+      return true if @should.empty?
+      return false unless is.is_a? Array
+      return false unless is.length == @should.length
+      return (
+        is & @should == is or
+        is & @should.map(&:to_s) == is
+      )
+    end
+    munge do |value|
+      value = value.to_s.strip
+      value.capitalize! if value =~ /^(true|false)$/i
+      value
+    end
+
+    def is_to_s( currentvalue )
+      if resource.secret?
+        return '[old secret redacted]'
+      else
+        return currentvalue
+      end
+    end
+
+    def should_to_s( newvalue )
+      if resource.secret?
+        return '[new secret redacted]'
+      else
+        return newvalue
+      end
+    end
+  end
+
+  newparam(:secret, :boolean => true) do
+    desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
+
+    newvalues(:true, :false)
+
+    defaultto false
+  end
+
+  newparam(:ensure_absent_val) do
+    desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
+    defaultto('<SERVICE DEFAULT>')
+  end
+
+  autorequire(:anchor) do
+    ['gnocchi::install::end']
+  end
+
+end
--- /dev/null
+++ puppet-module-gnocchi-25.0.0/lib/puppet/provider/gnocchi_api_config/openstackconfig.rb
@@ -0,0 +1,10 @@
+Puppet::Type.type(:gnocchi_api_config).provide(
+  :openstackconfig,
+  :parent => Puppet::Type.type(:openstack_config).provider(:ruby)
+) do
+
+  def self.file_path
+    '/etc/gnocchi/gnocchi-api.conf'
+  end
+
+end
--- /dev/null
+++ puppet-module-gnocchi-25.0.0/lib/puppet/type/gnocchi_api_config.rb
@@ -0,0 +1,61 @@
+Puppet::Type.newtype(:gnocchi_api_config) do
+
+  ensurable
+
+  newparam(:name, :namevar => true) do
+    desc 'Section/setting name to manage from gnocchi-api.conf'
+    newvalues(/\S+\/\S+/)
+  end
+
+  newproperty(:value, :array_matching => :all) do
+    desc 'The value of the setting to be defined.'
+    def insync?(is)
+      return true if @should.empty?
+      return false unless is.is_a? Array
+      return false unless is.length == @should.length
+      return (
+        is & @should == is or
+        is & @should.map(&:to_s) == is
+      )
+    end
+    munge do |value|
+      value = value.to_s.strip
+      value.capitalize! if value =~ /^(true|false)$/i
+      value
+    end
+
+    def is_to_s( currentvalue )
+      if resource.secret?
+        return '[old secret redacted]'
+      else
+        return currentvalue
+      end
+    end
+
+    def should_to_s( newvalue )
+      if resource.secret?
+        return '[new secret redacted]'
+      else
+        return newvalue
+      end
+    end
+  end
+
+  newparam(:secret, :boolean => true) do
+    desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
+
+    newvalues(:true, :false)
+
+    defaultto false
+  end
+
+  newparam(:ensure_absent_val) do
+    desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
+    defaultto('<SERVICE DEFAULT>')
+  end
+
+  autorequire(:anchor) do
+    ['gnocchi::install::end']
+  end
+
+end
