This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #18301 - Reset values don't persist in answers
This required resetting parameters separately from the tasks that install the new puppet bits. The puppet packages need to be performed during the init phase, before Kafo reads in the default values coming from the puppet modules. By installing Puppet 4 prior to getting the default values, the puppet puppet module will see the puppetversion fact as greater than version 4 and set the defaults based upon that. During pre_validation, is when the params need to use unset_value to force Kafo to use the new Puppet 4 defaults.
- Loading branch information
Showing
3 changed files
with
72 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
def puppet4_available? | ||
success = [] | ||
success << Kafo::Helpers.execute('yum info puppet-agent') | ||
success << Kafo::Helpers.execute('yum info puppetserver') | ||
!success.include?(false) | ||
end | ||
|
||
def stop_services | ||
Kafo::Helpers.execute('katello-service stop') | ||
end | ||
|
||
def upgrade_puppet_package | ||
Kafo::Helpers.execute('yum remove -y puppet-server') | ||
Kafo::Helpers.execute('yum install -y puppetserver') | ||
Kafo::Helpers.execute('yum install -y puppet-agent') | ||
end | ||
|
||
def start_httpd | ||
Kafo::Helpers.execute('katello-service start --only httpd') | ||
end | ||
|
||
def remove_puppet_port_httpd | ||
Kafo::Helpers.execute('sed -i "/^Listen 8140$/d" /etc/httpd/conf/ports.conf') | ||
end | ||
|
||
def copy_data | ||
success = [] | ||
success << Kafo::Helpers.execute('cp -rfp /etc/puppet/environments /etc/puppetlabs/code/environments') if File.directory?('/etc/puppet/environments') | ||
success << Kafo::Helpers.execute('cp -rfp /var/lib/puppet/ssl /etc/puppetlabs/puppet') if File.directory?('/var/lib/puppet/ssl') | ||
success << Kafo::Helpers.execute('cp -rfp /var/lib/puppet/foreman_cache_data /opt/puppetlabs/puppet/cache/') if File.directory?('/var/lib/puppet/foreman_cache_data') | ||
!success.include?(false) | ||
end | ||
|
||
def upgrade_step(step) | ||
noop = app_value(:noop) ? ' (noop)' : '' | ||
|
||
Kafo::Helpers.log_and_say :info, "Upgrade Step: #{step}#{noop}..." | ||
unless app_value(:noop) | ||
status = send(step) | ||
fail_and_exit "Upgrade step #{step} failed. Check logs for more information." unless status | ||
end | ||
end | ||
|
||
def fail_and_exit(message) | ||
Kafo::Helpers.log_and_say :error, message | ||
kafo.class.exit 1 | ||
end | ||
|
||
if app_value(:upgrade_puppet) | ||
PUPPET_UPGRADE_COMPLETE = '/etc/foreman-installer/.puppet_4_upgrade'.freeze | ||
|
||
fail_and_exit 'Puppet already installed and upgraded. Skipping.' if File.exist?(PUPPET_UPGRADE_COMPLETE) | ||
|
||
katello = Kafo::Helpers.module_enabled?(@kafo, 'katello') | ||
foreman_proxy_content = @kafo.param('foreman_proxy_plugin_pulp', 'pulpnode_enabled').value | ||
|
||
fail_and_exit 'Puppet 3 to 4 upgrade is not currently supported for the chosen scenario.' unless katello || foreman_proxy_content | ||
|
||
Kafo::Helpers.log_and_say :info, 'Upgrading puppet...' | ||
fail_and_exit 'Unable to find Puppet 4 packages, is the repository enabled?' unless puppet4_available? | ||
|
||
upgrade_step :upgrade_puppet_package | ||
upgrade_step :stop_services | ||
upgrade_step :copy_data | ||
upgrade_step :remove_puppet_port_httpd | ||
upgrade_step :start_httpd | ||
|
||
Kafo::Helpers.log_and_say :info, "Puppet 3 to 4 upgrade initialization complete, continuing with installation" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters