Skip to content

Commit

Permalink
adding the option to setup the upstream HashiCorp repository
Browse files Browse the repository at this point in the history
  • Loading branch information
attachmentgenie committed Jan 14, 2021
1 parent 3d490c7 commit b126110
Show file tree
Hide file tree
Showing 6 changed files with 65 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 @@ -105,6 +105,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 @@ -217,6 +220,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
3 changes: 3 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
}
}
'package': {
if $consul::manage_repo{
include hashi_stack::repo
}
package { $consul::package_name:
ensure => $consul::package_ensure,
notify => $do_notify_service,
Expand Down
7 changes: 7 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,31 @@
case $facts['os']['name'] {
'Ubuntu': {
$shell = '/usr/sbin/nologin'
$manage_repo = true
}
'RedHat': {
$shell = '/sbin/nologin'
$manage_repo = true
}
'Debian': {
$shell = '/usr/sbin/nologin'
$manage_repo = true
}
'Archlinux': {
$shell = '/sbin/nologin'
$manage_repo = false
}
'OpenSuSE': {
$shell = '/usr/sbin/nologin'
$manage_repo = false
}
/SLE[SD]/: {
$shell = '/usr/sbin/nologin'
$manage_repo = false
}
default: {
$shell = undef
$manage_repo = false
}
}

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 b126110

Please sign in to comment.