Skip to content

Commit

Permalink
(PE-14495) Remove pluginsync setting if upgrading to 1.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tphoney authored and Michael Smith committed Apr 5, 2016
1 parent 429eb85 commit 86457d1
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 94 deletions.
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

class { '::puppet_agent::prepare':
package_file_name => $_package_file_name,
package_version => $package_version,
} ->
class { '::puppet_agent::install':
package_file_name => $_package_file_name,
Expand Down
12 changes: 8 additions & 4 deletions manifests/prepare.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#
class puppet_agent::prepare(
$package_file_name = undef,
$package_version = undef,
){
include puppet_agent::params
$_windows_client = downcase($::osfamily) == 'windows'
Expand All @@ -39,17 +40,20 @@

$_osfamily_class = downcase("::puppet_agent::osfamily::${::osfamily}")

# Manage deprecating configuration settings.
class { 'puppet_agent::prepare::puppet_config':
package_version => $package_version,
before => Class[$_osfamily_class],
}
contain puppet_agent::prepare::puppet_config

if versioncmp("${::clientversion}", '4.0.0') < 0 {
# Migrate old files; assumes user Puppet runs under won't change during upgrade
# We assume the current Puppet settings are authoritative; if anything exists
# in the destination but not the source, it'll be overwritten.
file { $::puppet_agent::params::puppetdirs:
ensure => directory,
}
class { 'puppet_agent::prepare::puppet_config':
before => Class[$_osfamily_class],
}
contain puppet_agent::prepare::puppet_config

if !$_windows_client { #Windows didn't change only nix systems
class { 'puppet_agent::prepare::ssl':
Expand Down
71 changes: 46 additions & 25 deletions manifests/prepare/puppet_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,58 @@
#
# Private class called from puppet_agent::prepare class
#
class puppet_agent::prepare::puppet_config {
class puppet_agent::prepare::puppet_config (
$package_version
) {
assert_private()
$old_packages = (versioncmp("${::clientversion}", '4.0.0') < 0)

$puppetconf = $::puppet_agent::params::config
file { $puppetconf:
ensure => file,
source => $::puppet_config,
if $old_packages {
$puppetconf = $::puppet_agent::params::config
file { $puppetconf:
ensure => file,
source => $::puppet_config,
}
}

# manage puppet.conf contents, using inifile module
# manage puppet.conf contents, using inifile module
['', 'master', 'agent', 'main'].each |$loop_section| {
$section = $loop_section
[# Removed settings
'allow_variables_with_dashes', 'async_storeconfigs', 'binder', 'catalog_format', 'certdnsnames',
'certificate_expire_warning', 'couchdb_url', 'dbadapter', 'dbconnections', 'dblocation', 'dbmigrate', 'dbname',
'dbpassword', 'dbport', 'dbserver', 'dbsocket', 'dbuser', 'dynamicfacts', 'http_compression', 'httplog',
'ignoreimport', 'immutable_node_data', 'inventory_port', 'inventory_server', 'inventory_terminus',
'legacy_query_parameter_serialization', 'listen', 'localconfig', 'manifestdir', 'masterlog', 'parser',
'preview_outputdir', 'puppetport', 'queue_source', 'queue_type', 'rails_loglevel', 'railslog',
'report_serialization_format', 'reportfrom', 'rrddir', 'rrdinterval', 'sendmail', 'smtphelo', 'smtpport',
'smtpserver', 'stringify_facts', 'tagmap', 'templatedir', 'thin_storeconfigs', 'trusted_node_data', 'zlib',
# Deprecated for global config
'config_version', 'manifest', 'modulepath',
# Settings that should be reset to defaults
'disable_warnings', 'vardir', 'rundir', 'libdir', 'confdir', 'ssldir', 'classfile'].each |$setting| {
ini_setting { "${section}/${setting}":
ensure => absent,
section => $section,
setting => $setting,
path => $puppetconf,
require => File[$puppetconf],

if versioncmp("${::clientversion}", '4.0.0') < 0 {
$_removedSettings = [# Removed settings
'allow_variables_with_dashes', 'async_storeconfigs', 'binder', 'catalog_format', 'certdnsnames',
'certificate_expire_warning', 'couchdb_url', 'dbadapter', 'dbconnections', 'dblocation', 'dbmigrate', 'dbname',
'dbpassword', 'dbport', 'dbserver', 'dbsocket', 'dbuser', 'dynamicfacts', 'http_compression', 'httplog',
'ignoreimport', 'immutable_node_data', 'inventory_port', 'inventory_server', 'inventory_terminus',
'legacy_query_parameter_serialization', 'listen', 'localconfig', 'manifestdir', 'masterlog', 'parser',
'preview_outputdir', 'puppetport', 'queue_source', 'queue_type', 'rails_loglevel', 'railslog',
'report_serialization_format', 'reportfrom', 'rrddir', 'rrdinterval', 'sendmail', 'smtphelo', 'smtpport',
'smtpserver', 'stringify_facts', 'tagmap', 'templatedir', 'thin_storeconfigs', 'trusted_node_data', 'zlib',
# Deprecated for global config
'config_version', 'manifest', 'modulepath',
# Settings that should be reset to defaults
'disable_warnings', 'vardir', 'rundir', 'libdir', 'confdir', 'ssldir', 'classfile']
} else {
$_removedSettings = []
}

# When upgrading to 1.4.x or later remove pluginsync
if ($package_version == undef and $old_packages) or (versioncmp($package_version, '1.4.0') >= 0) {
$removedSettings = $_removedSettings + ['pluginsync']
} else {
$removedSettings = $_removedSettings
}

if $removedSettings {
$removedSettings.each |$setting| {
ini_setting { "${section}/${setting}":
ensure => absent,
section => $section,
setting => $setting,
path => $puppetconf,
require => File[$puppetconf],
}
}
}
}
Expand Down
150 changes: 85 additions & 65 deletions spec/classes/puppet_agent_prepare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,80 +152,100 @@
'source' => '/dev/null/ssl/crl.pem',
'backup' => 'false',
}) }
end

['', 'agent', 'main', 'master'].each do |section|
['allow_variables_with_dashes',
'async_storeconfigs',
'binder',
'catalog_format',
'certdnsnames',
'certificate_expire_warning',
'couchdb_url',
'dbadapter',
'dbconnections',
'dblocation',
'dbmigrate',
'dbname',
'dbpassword',
'dbport',
'dbserver',
'dbsocket',
'dbuser',
'dynamicfacts',
'http_compression',
'httplog',
'ignoreimport',
'immutable_node_data',
'inventory_port',
'inventory_server',
'inventory_terminus',
'legacy_query_parameter_serialization',
'listen',
'localconfig',
'manifestdir',
'masterlog',
'parser',
'preview_outputdir',
'puppetport',
'queue_source',
'queue_type',
'rails_loglevel',
'railslog',
'report_serialization_format',
'reportfrom',
'rrddir',
'rrdinterval',
'sendmail',
'smtphelo',
'smtpport',
'smtpserver',
'ssldir',
'stringify_facts',
'tagmap',
'templatedir',
'thin_storeconfigs',
'trusted_node_data',
'zlib',
'config_version',
'manifest',
'modulepath',
'disable_warnings',
'vardir',
'rundir',
'libdir',
'confdir',
'classfile'].each do |setting|
if Puppet.version >= '4.0.0'
it { is_expected.not_to contain_ini_setting("#{section}/#{setting}") }
else
it { is_expected.to contain_ini_setting("#{section}/#{setting}").with_ensure('absent') }
end
end

if Puppet.version < '4.0.0'
it { is_expected.to contain_ini_setting("#{section}/pluginsync").with_ensure('absent') }
else
context 'upgrading to puppet-agent < 1.4.0' do
let(:params) {{ :package_version => '1.3.0' }}

['', 'agent', 'main', 'master'].each do |section|
['allow_variables_with_dashes',
'async_storeconfigs',
'binder',
'catalog_format',
'certdnsnames',
'certificate_expire_warning',
'couchdb_url',
'dbadapter',
'dbconnections',
'dblocation',
'dbmigrate',
'dbname',
'dbpassword',
'dbport',
'dbserver',
'dbsocket',
'dbuser',
'dynamicfacts',
'http_compression',
'httplog',
'ignoreimport',
'immutable_node_data',
'inventory_port',
'inventory_server',
'inventory_terminus',
'legacy_query_parameter_serialization',
'listen',
'localconfig',
'manifestdir',
'masterlog',
'parser',
'preview_outputdir',
'puppetport',
'queue_source',
'queue_type',
'rails_loglevel',
'railslog',
'report_serialization_format',
'reportfrom',
'rrddir',
'rrdinterval',
'sendmail',
'smtphelo',
'smtpport',
'smtpserver',
'ssldir',
'stringify_facts',
'tagmap',
'templatedir',
'thin_storeconfigs',
'trusted_node_data',
'zlib',
'config_version',
'manifest',
'modulepath',
'disable_warnings',
'vardir',
'rundir',
'libdir',
'confdir',
'classfile'].each do |setting|
it { is_expected.to contain_ini_setting("#{section}/#{setting}").with_ensure('absent') }
end
it { is_expected.not_to contain_ini_setting("#{section}/pluginsync") }
end

context 'upgrading to puppet-agent >= 1.4.0' do
let(:params) {{ :package_version => '1.4.0' }}

it { is_expected.to contain_ini_setting("#{section}/pluginsync").with_ensure('absent') }
end
end
end

if Puppet.version >= "4.0.0"
it { is_expected.not_to contain_class("puppet_agent::prepare::puppet_config") }
it { is_expected.not_to contain_class("puppet_agent::prepare::ssl") }
it { is_expected.not_to contain_class("puppet_agent::prepare::mco_client_config") }
end

it { is_expected.to contain_class("puppet_agent::prepare::puppet_config") }
it { is_expected.to contain_class("puppet_agent::osfamily::#{facts[:osfamily]}") }
end
end
Expand Down

0 comments on commit 86457d1

Please sign in to comment.