Skip to content

Commit

Permalink
Merge pull request #560 from attachmentgenie/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
solarkennedy committed Jan 17, 2021
2 parents e01ec49 + 61f3bfa commit bee751a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
archive: "https://github.com/voxpupuli/puppet-archive.git"
hashi_stack: "https://github.com/voxpupuli/puppet-hashi_stack.git"
systemd: "https://github.com/camptocamp/puppet-systemd.git"
apt: "https://github.com/puppetlabs/puppetlabs-apt.git"
yum: "https://github.com/voxpupuli/puppet-yum.git"
yumrepo_core:
repo: "https://github.com/puppetlabs/puppetlabs-yumrepo_core.git"
puppet_version: ">= 6.0.0"
symlinks:
consul: "#{source_dir}"
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
# [*manage_group*]
# Whether to create/manage the group that should own the consul configuration files.
#
# [*manage_repo*]
# Configure the upstream HashiCorp repository. Only relevant when $nomad::install_method = 'package'.
#
# [*manage_service*]
# Whether to manage the consul service.
#
Expand Down Expand Up @@ -221,6 +224,7 @@
String[1] $install_method = 'url',
Optional[String[1]] $join_wan = undef,
Boolean $manage_group = $consul::params::manage_group,
Boolean $manage_repo = $consul::params::manage_repo,
Boolean $manage_service = true,
Boolean $manage_user = $consul::params::manage_user,
Boolean $manage_data_dir = true,
Expand Down
4 changes: 4 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
}
}
'package': {
if $consul::manage_repo{
include hashi_stack::repo
Class['hashi_stack::repo'] -> Package[$consul::package_name]
}
package { $consul::package_name:
ensure => $consul::package_ensure,
notify => $do_notify_service,
Expand Down
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#
class consul::params {

$manage_repo = false

case $facts['architecture'] {
'x86_64', 'x64', 'amd64': { $arch = 'amd64' }
'i386': { $arch = '386' }
Expand Down
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"name": "puppet/archive",
"version_requirement": ">= 2.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
41 changes: 41 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,47 @@
it { should_not contain_exec('join consul wan') }
end

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

case 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 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 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 bee751a

Please sign in to comment.