|
3 | 3 | class zulip_ops::prometheus::postgresql {
|
4 | 4 | include zulip_ops::prometheus::base
|
5 | 5 | include zulip::supervisor
|
| 6 | + include zulip::golang |
6 | 7 |
|
7 |
| - $version = $zulip::common::versions['postgres_exporter']['version'] |
8 |
| - $dir = "/srv/zulip-postgres_exporter-${version}" |
9 |
| - $bin = "${dir}/postgres_exporter" |
| 8 | + $version = $zulip::common::versions['postgres_exporter-src']['version'] |
| 9 | + $dir = "/srv/zulip-postgres_exporter-src-${version}" |
| 10 | + $bin = "/usr/local/bin/postgres_exporter-${version}-go-${zulip::golang::version}" |
10 | 11 |
|
11 |
| - zulip::external_dep { 'postgres_exporter': |
| 12 | + # Binary builds: https://github.com/prometheus-community/postgres_exporter/releases/download/v${version}/postgres_exporter-${version}.linux-${zulip::common::goarch}.tar.gz |
| 13 | + |
| 14 | + zulip::external_dep { 'postgres_exporter-src': |
12 | 15 | version => $version,
|
13 |
| - url => "https://github.com/prometheus-community/postgres_exporter/releases/download/v${version}/postgres_exporter-${version}.linux-${zulip::common::goarch}.tar.gz", |
14 |
| - tarball_prefix => "postgres_exporter-${version}.linux-${zulip::common::goarch}", |
| 16 | + url => "https://github.com/Sticksman/postgres_exporter/archive/${version}.tar.gz", |
| 17 | + tarball_prefix => "postgres_exporter-${version}", |
| 18 | + } |
| 19 | + |
| 20 | + exec { 'compile postgres_exporter': |
| 21 | + command => "make build && cp ./postgres_exporter ${bin}", |
| 22 | + cwd => $dir, |
| 23 | + # GOCACHE is required; nothing is written to GOPATH, but it is required to be set |
| 24 | + environment => ['GOCACHE=/tmp/gocache', 'GOPATH=/root/go'], |
| 25 | + path => [ |
| 26 | + "${zulip::golang::dir}/bin", |
| 27 | + '/usr/local/bin', |
| 28 | + '/usr/bin', |
| 29 | + '/bin', |
| 30 | + ], |
| 31 | + creates => $bin, |
| 32 | + require => [ |
| 33 | + Zulip::External_Dep['golang'], |
| 34 | + Zulip::External_Dep['postgres_exporter-src'], |
| 35 | + ] |
| 36 | + } |
| 37 | + # This resource exists purely so it doesn't get tidied; it is |
| 38 | + # created by the 'compile postgres_exporter' step. |
| 39 | + file { $bin: |
| 40 | + ensure => file, |
| 41 | + require => Exec['compile postgres_exporter'], |
| 42 | + } |
| 43 | + tidy { '/usr/local/bin/postgres_exporter-*': |
| 44 | + path => '/usr/local/bin', |
| 45 | + recurse => 1, |
| 46 | + matches => 'postgres_exporter-*', |
| 47 | + require => Exec['compile postgres_exporter'], |
15 | 48 | }
|
16 | 49 |
|
17 | 50 | exec { 'create prometheus postgres user':
|
|
27 | 60 | Exec['create prometheus postgres user'],
|
28 | 61 | User[prometheus],
|
29 | 62 | Package[supervisor],
|
30 |
| - Zulip::External_Dep['postgres_exporter'], |
| 63 | + File[$bin], |
31 | 64 | ],
|
32 | 65 | owner => 'root',
|
33 | 66 | group => 'root',
|
|
0 commit comments