Skip to content

Commit

Permalink
Fixes danieldreier#2 - use puppetserver_gem when installing on JVM pu…
Browse files Browse the repository at this point in the history
…ppetserver
  • Loading branch information
logicminds committed May 14, 2020
1 parent b1e77bb commit 994e8ee
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
puppetserver_gem: 'https://github.com/puppetlabs/puppetlabs-puppetserver_gem'
symlinks:
autosign: "#{source_dir}"
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#
class autosign (
String $ensure = $::autosign::params::ensure,
String $puppetserver_ensure = 'present',
Optional[String] $gem_source = undef,
String $package_name = $::autosign::params::package_name,
Stdlib::Absolutepath $configfile = $::autosign::params::configfile,
String $user = $::autosign::params::user,
Expand Down
16 changes: 13 additions & 3 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@

# install the autosign gem
if $::autosign::manage_package {
package { $::autosign::package_name:
ensure => $::autosign::ensure,
provider => $::autosign::gem_provider,
package {
default:
name => $::autosign::package_name,
source => $::autosign::gem_source,
;
'autosign via puppet_gem':
ensure => $::autosign::ensure,
provider => $::autosign::gem_provider,
;
'autosign via puppetserver_gem':
ensure => $::autosign::puppetserver_ensure,
provider => 'puppetserver_gem',
;
}
}

Expand Down
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
{
"name": "puppetlabs-stdlib",
"version_requirement": ">= 4.0.0 < 7.0.0"
},
{
"name": "puppetlabs-puppetserver_gem",
"version_requirement": ">= 1.1.1 < 2.0.0"
}
],
"operatingsystem_support": [
Expand Down
30 changes: 23 additions & 7 deletions spec/classes/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
let(:params) { {} }

it_behaves_like 'base case'
it { is_expected.to contain_package('autosign').with_ensure('present') }
it { is_expected.to contain_package('autosign via puppet_gem').with_ensure('present') }
it { is_expected.to contain_package('autosign via puppetserver_gem').with_ensure('present') }
end
end
end
Expand All @@ -28,6 +29,8 @@
let(:params) do
{
ensure: 'latest',
puppetserver_ensure: 'latest',
gem_source: 'https://rubygems.org',
config: { 'jwt_token' => { 'secret' => 'hunter2' } },
}
end
Expand All @@ -42,7 +45,20 @@

it_behaves_like 'base case'

it { is_expected.to contain_package('autosign').with_ensure('latest') }
it do
is_expected.to contain_package('autosign via puppet_gem')
.with({
'ensure' => 'latest',
'gem_source' => 'https://rubygems.org'
})
end
it do
is_expected.to contain_package('autosign via puppetserver_gem')
.with({
'ensure' => 'latest',
'gem_source' => 'https://rubygems.org'
})
end
it { is_expected.to contain_file("#{base_configpath}/autosign.conf").with_ensure('file') }
it { is_expected.to contain_file("#{base_journalpath}/autosign.journal").with_ensure('file') }
it { is_expected.to contain_file('/var/log/autosign.log').with_ensure('file') }
Expand All @@ -59,8 +75,7 @@
operatingsystem: 'Nexenta',
}
end

it { expect { is_expected.to contain_package('autosign') }.to raise_error(Puppet::Error, %r{Nexenta not supported}) }
it { expect { is_expected.to contain_package('autosign via puppet_gem') }.to raise_error(Puppet::Error, %r{Nexenta not supported}) }
end
end

Expand All @@ -73,7 +88,8 @@
let(:params) { {} }

it_behaves_like 'base case'
it { is_expected.to contain_package('autosign').with_ensure('present') }
it { is_expected.to contain_package('autosign via puppet_gem').with_ensure('present') }
it { is_expected.to contain_package('autosign via puppetserver_gem').with_ensure('present') }
it { is_expected.to contain_file('/var/log/puppetlabs/puppetserver/autosign.log').with_ensure('file') }
it { is_expected.to contain_file('/etc/puppetlabs/puppetserver/autosign.conf').with_ensure('file') }
it { is_expected.to contain_file('/opt/puppetlabs/server/autosign/autosign.journal').with_ensure('file') }
Expand All @@ -96,7 +112,7 @@
end

it_behaves_like 'base case'
it { is_expected.to contain_package('autosign').with_ensure('0.1.0') }
it { is_expected.to contain_package('autosign via puppet_gem').with_ensure('0.1.0') }
it { is_expected.to contain_file('/etc/autosign1.conf').with_ensure('file') }
it { is_expected.not_to contain_file('/var/lib/autosign/autosign.journal') }
it { is_expected.not_to contain_file('/var/log/autosign.log') }
Expand All @@ -115,7 +131,7 @@
}
end

it { is_expected.not_to contain_package('autosign') }
it { is_expected.not_to contain_package('autosign via puppet_gem') }
end
end
end
Expand Down

0 comments on commit 994e8ee

Please sign in to comment.