Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Default file mode to 0600 #21

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,23 @@ Data type: `String`

owner of config_file

Default value: `'root'`
Default value: `$service_name`

##### <a name="-otelcol--config_file_group"></a>`config_file_group`

Data type: `String`

group of config_file

Default value: `'root'`
Default value: `$service_name`

##### <a name="-otelcol--config_file_mode"></a>`config_file_mode`

Data type: `Stdlib::Filemode`

mode of config_file

Default value: `'0644'`
Default value: `'0600'`

##### <a name="-otelcol--receivers"></a>`receivers`

Expand Down
13 changes: 7 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {},
Expand Down
20 changes: 13 additions & 7 deletions spec/classes/otelcol_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -40,8 +43,6 @@
let :params do
{
package_name: 'otelcol-contrib',
config_file_owner: 'otelcol-contrib',
config_file_group: 'otelcol-contrib',
}
end

Expand All @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -150,7 +156,7 @@
{
config_file_owner: 'root',
config_file_group: 'root',
config_file_mode: '0600',
config_file_mode: '0640',
}
end

Expand All @@ -160,7 +166,7 @@
is_expected.to contain_concat('otelcol-config').with(
'owner' => 'root',
'group' => 'root',
'mode' => '0600'
'mode' => '0640'
)
}
end
Expand Down
Loading