Skip to content

Commit

Permalink
Merge pull request voxpupuli#530 from anarcat/no-init-env-options
Browse files Browse the repository at this point in the history
pass options through env_vars if no control over init files
  • Loading branch information
anarcat authored Mar 1, 2021
2 parents 829fd02 + 207b85e commit e652fef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 24 additions & 2 deletions manifests/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,37 @@
'none': {}
}

unless $env_vars.empty {
if $init_style == 'none' and $install_method == 'package' {
$env_vars_merged = $env_vars + {
'ARGS' => $options,
}
} else {
$env_vars_merged = $env_vars
}

if $install_method == 'package' and $package_ensure in ['absent', 'purged'] {
# purge the environment file if the package is removed
#
# this is to make sure we can garbage-collect the files created by
# this module, when purging it.
file { "${env_file_path}/${name}":
ensure => absent,
}
} elsif $install_method == 'package' or !$env_vars_merged.empty {
# manage the environment file if the package is installed *or*, in
# any other case, if there's something to add to it
#
# the logic here is that the package-managed .service files *need*
# those files to be present, even if empty, so it's critical that
# the file not get removed
file { "${env_file_path}/${name}":
mode => '0644',
owner => 'root',
group => '0', # Darwin uses wheel
content => epp(
'prometheus/daemon.env.epp',
{
'env_vars' => $env_vars,
'env_vars' => $env_vars_merged,
}
),
notify => $notify_service,
Expand Down
4 changes: 4 additions & 0 deletions spec/classes/node_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@

if facts[:os]['family'] == 'RedHat'
it { is_expected.not_to contain_file('/etc/sysconfig/node_exporter') }
elsif facts[:os]['name'] == 'Archlinux'
it { is_expected.to contain_file('/etc/default/node_exporter') }
it { is_expected.not_to contain_file('/etc/sysconfig/node_exporter') }
else
it { is_expected.not_to contain_file('/etc/default/node_exporter') }
it { is_expected.not_to contain_file('/etc/sysconfig/node_exporter') }
end
end

Expand Down

0 comments on commit e652fef

Please sign in to comment.