|
4 | 4 | #
|
5 | 5 | # @api private
|
6 | 6 | class promtail::install {
|
7 |
| - include archive |
| 7 | + if $promtail::install_method == 'archive' { |
| 8 | + assert_type(String[1], $promtail::checksum) |
| 9 | + include archive |
8 | 10 |
|
9 |
| - case $facts['os']['architecture'] { |
10 |
| - 'x86_64', 'amd64': { $arch = 'amd64' } |
11 |
| - 'aarch64': { $arch = 'arm64' } |
12 |
| - 'armv7l': { $arch = 'arm' } |
13 |
| - default: { fail("Unsupported kernel architecture: ${facts['os']['architecture']}") } |
14 |
| - } |
| 11 | + case $facts['os']['architecture'] { |
| 12 | + 'x86_64', 'amd64': { $arch = 'amd64' } |
| 13 | + 'aarch64': { $arch = 'arm64' } |
| 14 | + 'armv7l': { $arch = 'arm' } |
| 15 | + default: { fail("Unsupported kernel architecture: ${facts['os']['architecture']}") } |
| 16 | + } |
15 | 17 |
|
16 |
| - case $facts['kernel'] { |
17 |
| - 'Linux': { |
18 |
| - $data_dir = '/usr/local/promtail_data' |
19 |
| - if versioncmp($promtail::version, 'v0.3.0') > 0 { |
20 |
| - $release_file_name = "promtail-linux-${arch}" |
21 |
| - } else { |
22 |
| - $release_file_name = "promtail_linux_${arch}" |
| 18 | + case $facts['kernel'] { |
| 19 | + 'Linux': { |
| 20 | + $data_dir = '/usr/local/promtail_data' |
| 21 | + if versioncmp($promtail::version, 'v0.3.0') > 0 { |
| 22 | + $release_file_name = "promtail-linux-${arch}" |
| 23 | + } else { |
| 24 | + $release_file_name = "promtail_linux_${arch}" |
| 25 | + } |
23 | 26 | }
|
| 27 | + default: { fail("${facts['kernel']} is not yet supported") } |
24 | 28 | }
|
25 |
| - default: { fail("${facts['kernel']} is not yet supported") } |
26 |
| - } |
27 | 29 |
|
28 |
| - if versioncmp($promtail::version, 'v1.0.0') > 0 { |
29 |
| - $archive_type = 'zip' |
30 |
| - } else { |
31 |
| - $archive_type = 'gz' |
32 |
| - } |
| 30 | + if versioncmp($promtail::version, 'v1.0.0') > 0 { |
| 31 | + $archive_type = 'zip' |
| 32 | + } else { |
| 33 | + $archive_type = 'gz' |
| 34 | + } |
33 | 35 |
|
34 |
| - $version_dir = "${data_dir}/promtail-${promtail::version}" |
35 |
| - $binary_path = "${version_dir}/${release_file_name}" |
| 36 | + $version_dir = "${data_dir}/promtail-${promtail::version}" |
| 37 | + $binary_path = "${version_dir}/${release_file_name}" |
36 | 38 |
|
37 |
| - file { [$data_dir, $version_dir]: |
38 |
| - ensure => directory, |
39 |
| - } |
| 39 | + file { [$data_dir, $version_dir]: |
| 40 | + ensure => directory, |
| 41 | + } |
40 | 42 |
|
41 |
| - archive { "${binary_path}.gz": |
42 |
| - ensure => present, |
43 |
| - source => "${promtail::source_url}/${promtail::version}/${release_file_name}.${archive_type}", |
44 |
| - extract => true, |
45 |
| - extract_path => $version_dir, |
46 |
| - creates => $binary_path, |
47 |
| - checksum => $promtail::checksum, |
48 |
| - checksum_type => 'sha256', |
49 |
| - cleanup => false, |
50 |
| - } |
| 43 | + archive { "${binary_path}.gz": |
| 44 | + ensure => present, |
| 45 | + source => "${promtail::source_url}/${promtail::version}/${release_file_name}.${archive_type}", |
| 46 | + extract => true, |
| 47 | + extract_path => $version_dir, |
| 48 | + creates => $binary_path, |
| 49 | + checksum => $promtail::checksum, |
| 50 | + checksum_type => 'sha256', |
| 51 | + cleanup => false, |
| 52 | + } |
51 | 53 |
|
52 |
| - file { |
53 |
| - $binary_path: |
54 |
| - ensure => file, |
55 |
| - mode => '0755', |
56 |
| - require => Archive["${binary_path}.gz"], |
57 |
| - ; |
58 |
| - "${promtail::bin_dir}/promtail": |
59 |
| - ensure => link, |
60 |
| - target => $binary_path, |
61 |
| - require => File[$binary_path], |
62 |
| - notify => Service['promtail'], |
63 |
| - ; |
| 54 | + file { |
| 55 | + $binary_path: |
| 56 | + ensure => file, |
| 57 | + mode => '0755', |
| 58 | + require => Archive["${binary_path}.gz"], |
| 59 | + ; |
| 60 | + "${promtail::bin_dir}/promtail": |
| 61 | + ensure => link, |
| 62 | + target => $binary_path, |
| 63 | + require => File[$binary_path], |
| 64 | + notify => Service['promtail'], |
| 65 | + ; |
| 66 | + } |
| 67 | + } elsif $promtail::install_method == 'package' { |
| 68 | + package { $promtail::package_name: |
| 69 | + ensure => $promtail::package_ensure, |
| 70 | + } |
64 | 71 | }
|
65 | 72 | }
|
0 commit comments