45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'manifests/install.pp', line 45
class thanos::install (
Pattern[/\d+\.\d+\.\d+/] $version = $thanos::version,
String $package_name = $thanos::package_name,
String $os = $thanos::os,
String $real_arch = $thanos::real_arch,
# Installation
Enum['present', 'absent', 'latest'] $package_ensure = $thanos::package_ensure,
Enum['url', 'package', 'none'] $install_method = $thanos::install_method,
String $download_extension = $thanos::download_extension,
Stdlib::HTTPUrl $download_url = $thanos::real_download_url,
Optional[String] $extract_command = $thanos::extract_command,
Stdlib::Absolutepath $base_dir = $thanos::base_dir,
Stdlib::Absolutepath $bin_dir = $thanos::bin_dir,
Stdlib::Absolutepath $config_dir = $thanos::config_dir,
Boolean $purge_config_dir = $thanos::purge_config_dir,
Array[Type[Resource]] $notify_services = $thanos::notify_services,
# User Management
Boolean $manage_user = $thanos::manage_user,
Boolean $manage_group = $thanos::manage_group,
String $user = $thanos::user,
String $group = $thanos::group,
Stdlib::Absolutepath $usershell = $thanos::usershell,
Array[String] $extra_groups = $thanos::extra_groups,
) {
assert_private()
case $install_method {
'url': {
archive { "/tmp/thanos-${version}.${download_extension}":
ensure => present,
extract => true,
extract_path => $base_dir,
source => $download_url,
checksum_verify => false,
creates => "${base_dir}/thanos-${version}.${os}-${real_arch}/thanos",
cleanup => true,
extract_command => $extract_command,
}
-> file {
"${base_dir}/thanos-${version}.${os}-${real_arch}/thanos":
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555';
"${bin_dir}/thanos":
ensure => link,
notify => $notify_services,
target => "${base_dir}/thanos-${version}.${os}-${real_arch}/thanos";
}
}
'package': {
package { $package_name:
ensure => $package_ensure,
notify => $notify_services,
}
if $manage_user {
User[$user] -> Package[$package_name]
}
}
'none': {}
default: {
fail("The provided install method ${install_method} is invalid")
}
}
if $manage_user {
ensure_resource('user', [$user], {
ensure => 'present',
system => true,
groups => concat([$group], $extra_groups),
shell => $usershell,
})
if $manage_group {
Group[$group] -> User[$user]
}
}
if $manage_group {
ensure_resource('group', [$group], {
ensure => 'present',
system => true,
})
}
file { $config_dir:
ensure => 'directory',
owner => 'root',
group => $group,
purge => $purge_config_dir,
recurse => $purge_config_dir,
}
}
|