diff --git a/resources/monitor.rb b/resources/monitor.rb index 2c930126..55a7e4b2 100644 --- a/resources/monitor.rb +++ b/resources/monitor.rb @@ -35,6 +35,7 @@ property :use_integration_template, [TrueClass, FalseClass], required: false, default: false property :is_jmx, [TrueClass, FalseClass], required: false, default: false property :logs, [Array, nil], required: false, default: [] +property :config_name, [String, nil], required: false, default: 'conf' action :add do Chef::Log.debug("Adding monitoring for #{new_resource.name}") @@ -49,7 +50,7 @@ mode '755' end end - yaml_file = ::File.join(yaml_dir, "#{new_resource.name}.d", 'conf.yaml') + yaml_file = ::File.join(yaml_dir, "#{new_resource.name}.d", "#{config_name}.yaml") else yaml_file = ::File.join(yaml_dir, "#{new_resource.name}.yaml") end @@ -101,7 +102,7 @@ action :remove do yaml_file = if Chef::Datadog.agent_major_version(node) != 5 - ::File.join(yaml_dir, "#{new_resource.name}.d", 'conf.yaml') + ::File.join(yaml_dir, "#{new_resource.name}.d", "#{config_name}.yaml") else ::File.join(yaml_dir, "#{new_resource.name}.yaml") end diff --git a/test/cookbooks/test/recipes/monitor_add.rb b/test/cookbooks/test/recipes/monitor_add.rb index 7f6e3d15..2073ff01 100644 --- a/test/cookbooks/test/recipes/monitor_add.rb +++ b/test/cookbooks/test/recipes/monitor_add.rb @@ -15,3 +15,8 @@ datadog_monitor 'potato' do action :add end + +datadog_monitor 'potato' do + action :add + config_name 'potato-one' +end \ No newline at end of file diff --git a/test/cookbooks/test/recipes/monitor_remove.rb b/test/cookbooks/test/recipes/monitor_remove.rb index 8ad5b8d7..ff81253d 100644 --- a/test/cookbooks/test/recipes/monitor_remove.rb +++ b/test/cookbooks/test/recipes/monitor_remove.rb @@ -15,3 +15,8 @@ datadog_monitor 'potato' do action :remove end + +datadog_monitor 'potato' do + action :remove + config_name 'potato-one' +end \ No newline at end of file