Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 6e69221

Browse files
authored
Merge pull request #498 from JoshVanL/consul-backinator-binary
Download backinator binary in consul puppet module
2 parents 796d95d + a944084 commit 6e69221

File tree

4 files changed

+70
-3
lines changed

4 files changed

+70
-3
lines changed

puppet/modules/consul/manifests/init.pp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
String $sha256sums_url = $consul::params::sha256sums_url,
4040
String $exporter_download_url = $consul::params::exporter_download_url,
4141
String $exporter_signature_url = $consul::params::exporter_signature_url,
42+
String $backinator_version = $consul::params::backinator_version,
43+
String $backinator_download_url = $consul::params::backinator_download_url,
44+
String $backinator_sha256 = $consul::params::backinator_sha256,
4245
Integer $uid = 871,
4346
Integer $gid = 871,
4447
String $user = 'consul',
@@ -73,11 +76,12 @@
7376
Exec { path => $path }
7477

7578
$_dest_dir = "${dest_dir}/${app_name}-${version}"
79+
$_backinator_dest_dir = "${dest_dir}/${app_name}-backinator-${backinator_version}"
7680
$bin_path = "${_dest_dir}/${app_name}"
7781
$link_path = "${dest_dir}/bin"
7882
$config_path = "${config_dir}/consul.json"
7983

80-
$exporter_dest_dir = "${dest_dir}/${app_name}_exporter-${exporter_version}"
84+
$exporter_dest_dir = "${dest_dir}/${app_name}-exporter-${exporter_version}"
8185
$exporter_bin_path = "${exporter_dest_dir}/${app_name}_exporter"
8286

8387
$_consul_master_token = $consul_master_token ? {

puppet/modules/consul/manifests/install.pp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
'G'
2424
)
2525

26+
$backinator_download_url = regsubst(
27+
$consul::backinator_download_url,
28+
'#VERSION#',
29+
$consul::backinator_version,
30+
'G'
31+
)
32+
2633
# install unzip if necessary
2734
ensure_resource('package', 'unzip', {})
2835

@@ -84,13 +91,44 @@
8491
extract_path => $consul::exporter_dest_dir,
8592
extract_command => 'tar xfz %s --strip-components=1'
8693
}
94+
-> file {$consul::exporter_bin_path:
95+
ensure => file,
96+
mode => '0755',
97+
}
98+
-> file {"${consul::link_path}/${consul::app_name}_exporter":
99+
ensure => link,
100+
target => $consul::exporter_bin_path,
101+
}
87102
}
88103
else {
89104
file {$consul::exporter_dest_dir:
90105
ensure => absent,
91106
}
92107
}
93108

109+
110+
file {$consul::_backinator_dest_dir:
111+
ensure => directory,
112+
mode => '0755',
113+
}
114+
-> archive {"${consul::_dest_dir}/consul-backinator":
115+
ensure => present,
116+
extract => false,
117+
source => $backinator_download_url,
118+
checksum => $consul::backinator_sha256,
119+
checksum_type => 'sha256',
120+
cleanup => false,
121+
creates => "${consul::_backinator_dest_dir}/consul-backinator",
122+
}
123+
-> file {"${consul::_backinator_dest_dir}/consul-backinator":
124+
ensure => file,
125+
mode => '0755',
126+
}
127+
-> file {"${consul::link_path}/${consul::app_name}-backinator":
128+
ensure => link,
129+
target => "${consul::_backinator_dest_dir}/consul-backinator",
130+
}
131+
94132
file { "${consul::_dest_dir}/consul-backup.sh":
95133
ensure => file,
96134
content => file('consul/consul-backup.sh'),

puppet/modules/consul/manifests/params.pp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
class consul::params {
77
$app_name = 'consul'
88
$version = '1.2.1'
9+
$exporter_version = '0.3.0'
10+
$backinator_version = '1.3'
911
$download_dir = '/tmp'
1012
$systemd_dir = '/etc/systemd/system'
1113
$data_dir = '/var/lib/consul'
1214
$config_dir = '/etc/consul'
1315
$dest_dir = '/opt'
14-
$exporter_version = '0.3.0'
1516
$download_url = 'https://releases.hashicorp.com/consul/#VERSION#/consul_#VERSION#_linux_amd64.zip'
1617
$sha256sums_url = 'https://releases.hashicorp.com/consul/#VERSION#/consul_#VERSION#_SHA256SUMS'
1718
$signature_url = 'https://releases.hashicorp.com/consul/#VERSION#/consul_#VERSION#_SHA256SUMS.sig'
1819
$exporter_download_url = 'https://github.com/prometheus/consul_exporter/releases/download/v#VERSION#/consul_exporter-#VERSION#.linux-amd64.tar.gz'
1920
$exporter_signature_url = 'https://releases.tarmak.io/signatures/consul_exporter/#VERSION#/consul_exporter-#VERSION#.linux-amd64.tar.gz.asc'
21+
$backinator_download_url = 'https://github.com/myENA/consul-backinator/releases/download/v#VERSION#/consul-backinator-#VERSION#-amd64-linux.tar.gz'
22+
$backinator_sha256 = '8ea624487a86007825884685dbc978ba87f7a448f11d59b9eb29fd5b1b2a0e87'
2023
}

puppet/modules/consul/spec/classes/install_spec.rb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@
2828
end
2929

3030
it 'should install consul exporter' do
31-
should contain_file('/opt/consul_exporter-0.3.0').with(
31+
should contain_file('/opt/consul-exporter-0.3.0').with(
3232
:ensure => 'directory',
3333
)
34+
should contain_file('/opt/consul-exporter-0.3.0/consul_exporter').with(
35+
:ensure => 'file',
36+
:mode => '0755',
37+
)
38+
should contain_file('/opt/bin/consul_exporter').with(
39+
:ensure => 'link',
40+
:target => '/opt/consul-exporter-0.3.0/consul_exporter',
41+
)
3442
end
3543

3644
it 'should install consul backup script' do
@@ -43,5 +51,19 @@
4351
:target => '/opt/consul-1.2.1/consul-backup.sh',
4452
)
4553
end
54+
55+
it 'should install consul backinator' do
56+
should contain_file('/opt/consul-backinator-1.3').with(
57+
:ensure => 'directory',
58+
)
59+
should contain_file('/opt/consul-backinator-1.3/consul-backinator').with(
60+
:ensure => 'file',
61+
:mode => '0755',
62+
)
63+
should contain_file('/opt/bin/consul-backinator').with(
64+
:ensure => 'link',
65+
:target => '/opt/consul-backinator-1.3/consul-backinator',
66+
)
67+
end
4668
end
4769
end

0 commit comments

Comments
 (0)