Skip to content

Commit

Permalink
fix file ownerships
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriath committed Jan 7, 2022
1 parent 873ce78 commit c7af82c
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 9 deletions.
17 changes: 10 additions & 7 deletions manifests/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
Stdlib::Absolutepath $env_file_path = $prometheus::env_file_path,
Optional[String[1]] $extract_command = $prometheus::extract_command,
Stdlib::Absolutepath $extract_path = '/opt',
Stdlib::Absolutepath $archive_bin_path = "/opt/${name}-${version}.${os}-${arch}/${name}",
Stdlib::Absolutepath $install_path = "/opt/${name}-${version}.${os}-${arch}",
Stdlib::Absolutepath $archive_bin_path = "${install_path}/${name}",
Boolean $export_scrape_job = false,
Stdlib::Host $scrape_host = $facts['networking']['fqdn'],
Optional[Stdlib::Port] $scrape_port = undef,
Expand All @@ -83,17 +84,17 @@
case $install_method {
'url': {
if $download_extension == '' {
file { "/opt/${name}-${version}.${os}-${arch}":
file { $install_path:
ensure => directory,
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0755',
}
-> archive { "/opt/${name}-${version}.${os}-${arch}/${name}":
-> archive { $archive_bin_path:
ensure => present,
source => $real_download_url,
checksum_verify => false,
before => File["/opt/${name}-${version}.${os}-${arch}/${name}"],
before => File[$archive_bin_path],
}
} else {
archive { "/tmp/${name}-${version}.${download_extension}":
Expand All @@ -108,9 +109,11 @@
extract_command => $extract_command,
}
}
file { $archive_bin_path:
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
exec { "/bin/chown root:0 -R ${install_path}":
command => "/bin/chown root:0 -R ${install_path}", # 0 instead of root because OS X uses "wheel".
onlyif => "/usr/bin/test `/usr/bin/stat -c '%U' ${archive_bin_path}` != 'root'",
}
-> file { $archive_bin_path:
mode => '0555',
}
-> file { "${bin_dir}/${name}":
Expand Down
3 changes: 3 additions & 0 deletions manifests/ipsec_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@
if versioncmp ($version, '0.3.2') >= 0 {
$release = $version
$archive_bin_path = undef # use default
$install_path = undef # use default
}
else {
$release = "v${version}"
$archive_bin_path = "/opt/ipsec_exporter-v${version}.${os}-${arch}"
$install_path = "/opt/ipsec_exporter-v${version}.${os}-${arch}"
}
$real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${release}.${os}-${arch}.${download_extension}")

Expand All @@ -100,6 +102,7 @@
real_download_url => $real_download_url,
bin_dir => $bin_dir,
archive_bin_path => $archive_bin_path,
install_path => $install_path,
notify_service => $notify_service,
package_name => $package_name,
package_ensure => $package_ensure,
Expand Down
7 changes: 7 additions & 0 deletions manifests/nginx_prometheus_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@
creates => "${install_dir}/${package_name}",
cleanup => true,
}
-> exec { "/bin/chown root:0 -R ${install_dir}":
command => "/bin/chown root:0 -R ${install_dir}",
onlyif => "/usr/bin/test `/usr/bin/stat -c '%U' ${install_dir}/${service_name}` != 'root'",
}
-> file { "${install_dir}/${service_name}":
mode => '0555',
}
-> file { "${bin_dir}/${package_name}":
ensure => link,
notify => $notify_service,
Expand Down
7 changes: 7 additions & 0 deletions manifests/postgres_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@
creates => "${install_dir}/${service_name}",
cleanup => true,
}
-> exec { "/bin/chown root:0 -R ${install_dir}":
command => "/bin/chown root:0 -R ${install_dir}",
onlyif => "/usr/bin/test `/usr/bin/stat -c '%U' ${install_dir}/${service_name}` != 'root'",
}
-> file { "${install_dir}/${service_name}":
mode => '0555',
}
-> file { "${bin_dir}/${service_name}":
ensure => link,
notify => $notify_service,
Expand Down
1 change: 1 addition & 0 deletions manifests/pushprox_client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
version => $version,
download_extension => $download_extension,
archive_bin_path => "/opt/PushProx-${version}.${os}-${arch}/pushprox-client",
install_path => "/opt/PushProx-${version}.${os}-${arch}",
os => $os,
arch => $arch,
real_download_url => $real_download_url,
Expand Down
1 change: 1 addition & 0 deletions manifests/pushprox_proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
version => $version,
download_extension => $download_extension,
archive_bin_path => "/opt/PushProx-${version}.${os}-${arch}/pushprox-proxy",
install_path => "/opt/PushProx-${version}.${os}-${arch}",
os => $os,
arch => $arch,
real_download_url => $real_download_url,
Expand Down
7 changes: 7 additions & 0 deletions manifests/redis_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@
creates => "${install_dir}/${service_name}",
cleanup => true,
}
-> exec { "/bin/chown root:0 -R ${install_dir}":
command => "/bin/chown root:0 -R ${install_dir}",
onlyif => "/usr/bin/test `/usr/bin/stat -c '%U' ${install_dir}/${service_name}` != 'root'",
}
-> file { "${install_dir}/${service_name}":
mode => '0555',
}
-> file { "${bin_dir}/${service_name}":
ensure => link,
notify => $notify_service,
Expand Down
2 changes: 0 additions & 2 deletions spec/defines/daemon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@

it {
expect(subject).to contain_file("/opt/smurf_exporter-#{parameters[:version]}.#{prom_os}-#{prom_arch}/smurf_exporter").with(
'owner' => 'root',
'group' => 0,
'mode' => '0555'
)
}
Expand Down

0 comments on commit c7af82c

Please sign in to comment.