Skip to content

Commit

Permalink
Merge pull request #40 from voxpupuli/upstream_repo
Browse files Browse the repository at this point in the history
adding the option to setup the upstream HashiCorp repository
  • Loading branch information
attachmentgenie authored Jan 18, 2021
2 parents f363f51 + f895eee commit 4c06d90
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
apt: "https://github.com/puppetlabs/puppetlabs-apt.git"
archive: "https://github.com/voxpupuli/puppet-archive.git"
hashi_stack: "https://github.com/voxpupuli/puppet-hashi_stack.git"
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
systemd: "https://github.com/camptocamp/puppet-systemd.git"
yumrepo_core:
repo: "https://github.com/puppetlabs/puppetlabs-yumrepo_core.git"
puppet_version: ">= 6.0.0"
2 changes: 1 addition & 1 deletion example/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'region' => 'us-west',
'datacenter' => 'ptk',
'log_level' => 'INFO',
'bind_dir' => '0.0.0.0',
'bind_addr' => '0.0.0.0',
'data_dir' => '/var/lib/nomad',
'server' => {
'enabled' => true,
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
# default set of config settings
# @param config_mode
# Use this to set the JSON config file mode for nomad.
# @param manage_repo
# Configure the upstream HashiCorp repository. Only relevant when $nomad::install_method = 'package'.
# @param manage_service
# manage the nomad service
# @param pretty_config
Expand Down Expand Up @@ -165,6 +167,7 @@
Integer $pretty_config_indent = 4,
Boolean $service_enable = true,
Stdlib::Ensure::Service $service_ensure = 'running',
Boolean $manage_repo = true,
Boolean $manage_service = true,
Boolean $restart_on_change = true,
Variant[Enum['systemd', 'launchd'], Boolean] $init_style = $facts['service_provider'],
Expand Down
4 changes: 4 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
}
}
'package': {
if $nomad::manage_repo {
include hashi_stack::repo
Class['hashi_stack::repo'] -> Package[$nomad::package_name]
}
package { $nomad::package_name:
ensure => $nomad::package_ensure,
}
Expand Down
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"name": "puppet/archive",
"version_requirement": ">=1.0.0 <5.0.0"
},
{
"name": "puppet/hashi_stack",
"version_requirement": ">=1.0.0 <2.0.0"
},
{
"name": "camptocamp/systemd",
"version_requirement": ">= 1.1.1 < 3.0.0"
Expand Down
6 changes: 3 additions & 3 deletions spec/acceptance/standard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class { 'nomad':
"region" => 'us-west',
"datacenter" => 'ptk',
"log_level" => 'INFO',
"bind_dir" => "0.0.0.0",
"bind_addr" => "0.0.0.0",
"data_dir" => "/var/lib/nomad",
"server" => {
"enabled" => true,
Expand All @@ -22,8 +22,8 @@ class { 'nomad':
EOS

# Run it twice and test for idempotency
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe file('/var/lib/nomad') do
Expand Down
41 changes: 41 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,47 @@
it { should_not contain_exec('join nomad wan') }
end

context "When asked not to manage the repo" do
let(:params) {{
:manage_repo => false
}}

case os_facts[:os]['family']
when 'Debian'
it { should_not contain_apt__source('HashiCorp') }
when 'RedHat'
it { should_not contain_yumrepo('HashiCorp') }
end
end

context "When asked to manage the repo but not to install using package" do
let(:params) {{
:install_method => 'url',
:manage_repo => true
}}

case os_facts[:os]['family']
when 'Debian'
it { should_not contain_apt__source('HashiCorp') }
when 'RedHat'
it { should_not contain_yumrepo('HashiCorp') }
end
end

context "When asked to manage the repo and to install as package" do
let(:params) {{
:install_method => 'package',
:manage_repo => true
}}

case os_facts[:os]['family']
when 'Debian'
it { should contain_apt__source('HashiCorp') }
when 'RedHat'
it { should contain_yumrepo('HashiCorp') }
end
end

context 'When requesting to install via a package with defaults' do
let(:params) {{
:install_method => 'package'
Expand Down

0 comments on commit 4c06d90

Please sign in to comment.