diff --git a/REFERENCE.md b/REFERENCE.md
index 0e91581..e298bbe 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -132,7 +132,7 @@ Data type: `String`
owner of config_file
-Default value: `'root'`
+Default value: `$service_name`
##### `config_file_group`
@@ -140,7 +140,7 @@ Data type: `String`
group of config_file
-Default value: `'root'`
+Default value: `$service_name`
##### `config_file_mode`
@@ -148,7 +148,7 @@ Data type: `Stdlib::Filemode`
mode of config_file
-Default value: `'0644'`
+Default value: `'0600'`
##### `receivers`
diff --git a/manifests/config.pp b/manifests/config.pp
index c9818a5..63d0e27 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -17,12 +17,13 @@
}
concat { 'otelcol-config' :
- ensure => present,
- path => $otelcol::config_file,
- format => 'yaml',
- owner => $otelcol::config_file_owner,
- group => $otelcol::config_file_group,
- mode => $otelcol::config_file_mode,
+ ensure => present,
+ path => $otelcol::config_file,
+ format => 'yaml',
+ owner => $otelcol::config_file_owner,
+ group => $otelcol::config_file_group,
+ mode => $otelcol::config_file_mode,
+ require => Package['otelcol'],
}
concat::fragment { 'otelcol-config-header' :
target => 'otelcol-config',
diff --git a/manifests/init.pp b/manifests/init.pp
index 25fa850..c645dbc 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -58,9 +58,9 @@
String $environment_file = "/etc/${package_name}/${package_name}.conf",
Optional[String] $run_options = undef,
String $config_file = "/etc/${package_name}/config.yaml",
- String $config_file_owner = 'root',
- String $config_file_group = 'root',
- Stdlib::Filemode $config_file_mode = '0644',
+ String $config_file_owner = $service_name,
+ String $config_file_group = $service_name,
+ Stdlib::Filemode $config_file_mode = '0600',
Hash[String, Hash] $receivers = {},
Hash[String, Hash] $processors = {},
Hash[String, Hash] $exporters = {},
diff --git a/spec/classes/otelcol_spec.rb b/spec/classes/otelcol_spec.rb
index b435dd7..461f972 100644
--- a/spec/classes/otelcol_spec.rb
+++ b/spec/classes/otelcol_spec.rb
@@ -17,6 +17,9 @@
is_expected.to contain_concat('otelcol-config').with({
'path' => '/etc/otelcol/config.yaml',
'format' => 'yaml',
+ 'mode' => '0600',
+ 'owner' => 'otelcol',
+ 'group' => 'otelcol',
})
is_expected.to contain_concat__fragment('otelcol-config-header')
is_expected.to contain_concat__fragment('otelcol-config-baseconfig')
@@ -40,8 +43,6 @@
let :params do
{
package_name: 'otelcol-contrib',
- config_file_owner: 'otelcol-contrib',
- config_file_group: 'otelcol-contrib',
}
end
@@ -57,7 +58,14 @@
}
it { # Validate vaild YAML for config
- is_expected.to contain_concat('otelcol-config') # .with_content(configcontent.to_yaml)
+ is_expected.to contain_concat('otelcol-config').with({
+ 'path' => '/etc/otelcol-contrib/config.yaml',
+ 'format' => 'yaml',
+ 'mode' => '0600',
+ 'owner' => 'otelcol-contrib',
+ 'group' => 'otelcol-contrib',
+ })
+ # .with_content(configcontent.to_yaml)
# yaml_object = YAML.load(catalogue.resource('file', 'otelcol-config').send(:parameters)[:content])
# expect(yaml_object.length).to be > 0
}
@@ -73,8 +81,6 @@
let :params do
{
package_name: 'otelcol-contrib',
- config_file_owner: 'otelcol-contrib',
- config_file_group: 'otelcol-contrib',
manage_archive: true,
}
end
@@ -150,7 +156,7 @@
{
config_file_owner: 'root',
config_file_group: 'root',
- config_file_mode: '0600',
+ config_file_mode: '0640',
}
end
@@ -160,7 +166,7 @@
is_expected.to contain_concat('otelcol-config').with(
'owner' => 'root',
'group' => 'root',
- 'mode' => '0600'
+ 'mode' => '0640'
)
}
end