Skip to content

Commit

Permalink
Drop support for Puppet 3 (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoppe authored Mar 31, 2020
1 parent 812878e commit b698132
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 83 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

group :tests do
puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['>= 2.7.0', '< 7.0']
puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['>= 4.10.0', '< 7.0']
gem 'puppet', puppetversion
gem 'rake'
gem 'puppet-lint'
Expand Down
19 changes: 5 additions & 14 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,11 @@
# Make sure the Java package is only installed once.
anchor { 'zookeeper::install::java': }

# parameter allow_virtual is not supported before Puppet 3.6
if versioncmp($::puppetversion, '3.6.0') >= 0 {
ensure_resource('package', $::zookeeper::java_package,
{'ensure' => $::zookeeper::ensure, 'allow_virtual' => true,
'before' => Anchor['zookeeper::install::intermediate'],
'require' => Anchor['zookeeper::install::begin']}
)
} else {
ensure_resource('package', $::zookeeper::java_package,
{'ensure' => $::zookeeper::ensure,
'before' => Anchor['zookeeper::install::intermediate'],
'require' => Anchor['zookeeper::install::begin']}
)
}
ensure_resource('package', $::zookeeper::java_package,
{'ensure' => $::zookeeper::ensure, 'allow_virtual' => true,
'before' => Anchor['zookeeper::install::intermediate'],
'require' => Anchor['zookeeper::install::begin']}
)
}

anchor { 'zookeeper::install::intermediate': }
Expand Down
74 changes: 19 additions & 55 deletions manifests/install/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,13 @@
fail("CDH version'${::zookeeper::cdhver}' is not a supported cloudera repo.")
}
}
# Parameter ensure is not supported before Puppet 3.5
# Puppet 4 compatibility: force variable to be a String
if versioncmp("${::puppetversion}", '3.5.0') >= 0 { # lint:ignore:only_variable_string
yumrepo { "cloudera-cdh${::zookeeper::cdhver}":
ensure => $::zookeeper::ensure,
descr => "Cloudera's Distribution for Hadoop, Version ${::zookeeper::cdhver}",
baseurl => "http://archive.cloudera.com/cdh${::zookeeper::cdhver}/redhat/${release}/${os_hardware}/cdh/${::zookeeper::cdhver}/",
gpgkey => "http://archive.cloudera.com/cdh${::zookeeper::cdhver}/redhat/${release}/${os_hardware}/cdh/RPM-GPG-KEY-cloudera",
gpgcheck => 1
}
} else {
yumrepo { "cloudera-cdh${::zookeeper::cdhver}":
descr => "Cloudera's Distribution for Hadoop, Version ${::zookeeper::cdhver}",
baseurl => "http://archive.cloudera.com/cdh${::zookeeper::cdhver}/redhat/${os_release}/${os_hardware}/cdh/${::zookeeper::cdhver}/",
gpgkey => "http://archive.cloudera.com/cdh${::zookeeper::cdhver}/redhat/${os_release}/${os_hardware}/cdh/RPM-GPG-KEY-cloudera",
gpgcheck => 1
}
yumrepo { "cloudera-cdh${::zookeeper::cdhver}":
ensure => $::zookeeper::ensure,
descr => "Cloudera's Distribution for Hadoop, Version ${::zookeeper::cdhver}",
baseurl => "http://archive.cloudera.com/cdh${::zookeeper::cdhver}/redhat/${release}/${os_hardware}/cdh/${::zookeeper::cdhver}/",
gpgkey => "http://archive.cloudera.com/cdh${::zookeeper::cdhver}/redhat/${release}/${os_hardware}/cdh/RPM-GPG-KEY-cloudera",
gpgcheck => 1
}
}
'custom':{
Expand All @@ -81,45 +71,19 @@
case $os_release {
'6', '7': {
# Puppet 4 compatibility: force variable to be a String
if versioncmp("${::puppetversion}", '3.0.0') < 0 { # lint:ignore:only_variable_string
# parameter 'sslverify' is not supported before puppet 3.0
yumrepo { $_config['name']:
descr => $_config['descr'],
baseurl => $_config['url'],
enabled => 1,
gpgcheck => 0
}
# Puppet 4 compatibility: force variable to be a String
} elsif versioncmp("${::puppetversion}", '3.5.0') >= 0 { # lint:ignore:only_variable_string
# Parameter ensure is not supported before Puppet 3.5
yumrepo { $_config['name']:
ensure => $::zookeeper::ensure,
descr => $_config['descr'],
baseurl => $_config['url'],
enabled => 1,
sslverify => empty($_config['sslverify']) ? {
true => 0,
false => $_config['sslverify']
},
gpgcheck => empty($_config['gpgcheck']) ? {
true => 0,
false => $_config['gpgcheck']
},
}
} else {
yumrepo { $_config['name']:
descr => $_config['descr'],
baseurl => $_config['url'],
enabled => 1,
sslverify => empty($_config['sslverify']) ? {
true => 0,
false => $_config['sslverify']
},
gpgcheck => empty($_config['gpgcheck']) ? {
true => 0,
false => $_config['gpgcheck']
},
}
yumrepo { $_config['name']:
ensure => $::zookeeper::ensure,
descr => $_config['descr'],
baseurl => $_config['url'],
enabled => 1,
sslverify => empty($_config['sslverify']) ? {
true => 0,
false => $_config['sslverify']
},
gpgcheck => empty($_config['gpgcheck']) ? {
true => 0,
false => $_config['gpgcheck']
},
}
}
default: {
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 3.8.0 < 7.0.0"
"version_requirement": ">= 4.10.0 < 7.0.0"
}
]
}
1 change: 0 additions & 1 deletion spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@
let(:facts) do
os_facts.merge({
:ipaddress => '192.168.1.1',
:puppetversion => Puppet.version,
})
end

Expand Down
1 change: 0 additions & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
let(:facts) do
os_facts.merge({
:ipaddress => '192.168.1.1',
:puppetversion => Puppet.version,
})
end

Expand Down
6 changes: 1 addition & 5 deletions spec/classes/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,13 @@
end

describe 'zookeeper::install' do
puppet = `puppet --version`

let(:user) { 'zookeeper' }
let(:group) { 'zookeeper' }

on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) do
os_facts.merge({
:puppetversion => puppet,
})
os_facts
end

include_examples 'zookeeper install', os_facts
Expand Down
3 changes: 0 additions & 3 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
let(:facts) do
os_facts.merge({
:ipaddress => '192.168.1.1',
:puppetversion => Puppet.version,
})
end

Expand All @@ -113,7 +112,6 @@
let(:facts) do
os_facts.merge({
:ipaddress => '192.168.1.1',
:puppetversion => Puppet.version,
})
end

Expand All @@ -138,7 +136,6 @@
let(:facts) do
os_facts.merge({
:ipaddress => '192.168.1.1',
:puppetversion => Puppet.version,
})
end

Expand Down
1 change: 0 additions & 1 deletion spec/classes/sasl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
let(:facts) do
os_facts.merge({
:ipaddress => '192.168.1.1',
:puppetversion => Puppet.version,
})
end

Expand Down
1 change: 0 additions & 1 deletion spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@
let(:facts) do
os_facts.merge({
:ipaddress => '192.168.1.1',
:puppetversion => Puppet.version,
})
end

Expand Down

0 comments on commit b698132

Please sign in to comment.