Skip to content

Commit b0bbf02

Browse files
attachmentgeniejsok
authored andcommitted
adding the option to setup the upstream HashiCorp repository
1 parent ffb58f1 commit b0bbf02

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

.fixtures.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ fixtures:
22
repositories:
33
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
44
archive: "git://github.com/voxpupuli/puppet-archive.git"
5+
hashi_stack: "https://github.com/voxpupuli/puppet-hashi_stack.git"
56
systemd: "git://github.com/camptocamp/puppet-systemd.git"
67
file_capability: "git://github.com/smoeding/puppet-file_capability.git"
8+
apt: "https://github.com/puppetlabs/puppetlabs-apt.git"
9+
yum: "https://github.com/voxpupuli/puppet-yum.git"
10+
yumrepo_core:
11+
repo: "https://github.com/puppetlabs/puppetlabs-yumrepo_core.git"
12+
puppet_version: ">= 6.0.0"
713
symlinks:
814
vault: "#{source_dir}"

manifests/init.pp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
# * `service_options`
5151
# Extra argument to pass to `vault server`, as per:
5252
# `vault server --help`
53-
53+
#
54+
# * `manage_repo`
55+
# Configure the upstream HashiCorp repository. Only relevant when $nomad::install_method = 'repo'.
56+
#
5457
# * `manage_service`
5558
# Instruct puppet to manage service or not
5659
#
@@ -88,6 +91,7 @@
8891
$service_enable = $::vault::params::service_enable,
8992
$service_ensure = $::vault::params::service_ensure,
9093
$service_provider = $::vault::params::service_provider,
94+
Boolean $manage_repo = $::vault::params::manage_repo,
9195
$manage_service = $::vault::params::manage_service,
9296
$manage_service_file = $::vault::params::manage_service_file,
9397
Hash $storage = $::vault::params::storage,

manifests/install.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
}
2626

2727
'repo': {
28+
if $vault::manage_repo{
29+
include hashi_stack::repo
30+
}
2831
package { $::vault::package_name:
2932
ensure => $::vault::package_ensure,
3033
}

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@
6969
$install_method = 'repo'
7070
$bin_dir = '/bin'
7171
$manage_service_file = true
72+
$manage_repo = false
7273
}
7374
default: {
7475
$install_method = 'archive'
7576
$bin_dir = '/usr/local/bin'
7677
$manage_service_file = undef
78+
$manage_repo = true
7779
}
7880
}
7981
$os = downcase($facts['kernel'])

metadata.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"name": "puppet-archive",
2222
"version_requirement": ">= 2.0.0 < 5.0.0"
2323
},
24+
{
25+
"name": "puppet/hashi_stack",
26+
"version_requirement": ">=1.0.0 <2.0.0"
27+
},
2428
{
2529
"name": "camptocamp-systemd",
2630
"version_requirement": ">= 1.1.1 < 3.0.0"

spec/classes/vault_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,47 @@
201201
end
202202
end
203203

204+
context "When asked not to manage the repo" do
205+
let(:params) {{
206+
:manage_repo => false
207+
}}
208+
209+
case facts[:os]['family']
210+
when 'Debian'
211+
it { should_not contain_apt__source('HashiCorp') }
212+
when 'RedHat'
213+
it { should_not contain_yumrepo('HashiCorp') }
214+
end
215+
end
216+
217+
context "When asked to manage the repo but not to install using repo" do
218+
let(:params) {{
219+
:install_method => 'archive',
220+
:manage_repo => true
221+
}}
222+
223+
case facts[:os]['family']
224+
when 'Debian'
225+
it { should_not contain_apt__source('HashiCorp') }
226+
when 'RedHat'
227+
it { should_not contain_yumrepo('HashiCorp') }
228+
end
229+
end
230+
231+
context "When asked to manage the repo and to install as repo" do
232+
let(:params) {{
233+
:install_method => 'repo',
234+
:manage_repo => true
235+
}}
236+
237+
case facts[:os]['family']
238+
when 'Debian'
239+
it { should contain_apt__source('HashiCorp') }
240+
when 'RedHat'
241+
it { should contain_yumrepo('HashiCorp') }
242+
end
243+
end
244+
204245
context 'when installed from package repository' do
205246
let(:params) do
206247
{

0 commit comments

Comments
 (0)