foreman_maintain 0.9.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/checks/check_for_newer_packages.rb +5 -3
- data/definitions/checks/disk/performance.rb +19 -8
- data/definitions/checks/foreman/check_puppet_capsules.rb +43 -0
- data/definitions/checks/foreman_proxy/check_tftp_storage.rb +3 -1
- data/definitions/checks/pulpcore/group_ownership_check.rb +18 -0
- data/definitions/checks/repositories/check_non_rh_repository.rb +9 -4
- data/definitions/checks/repositories/check_upstream_repository.rb +4 -4
- data/definitions/features/candlepin.rb +1 -2
- data/definitions/features/foreman_tasks.rb +11 -0
- data/definitions/features/pulpcore.rb +2 -1
- data/definitions/features/upstream_repositories.rb +23 -0
- data/definitions/procedures/content/prepare.rb +1 -1
- data/definitions/procedures/installer/upgrade_rake_task.rb +3 -1
- data/definitions/procedures/pulp/remove.rb +12 -0
- data/definitions/procedures/pulpcore/migrate.rb +1 -1
- data/definitions/procedures/puppet/remove_puppet.rb +50 -0
- data/definitions/procedures/puppet/remove_puppet_data.rb +21 -0
- data/definitions/procedures/repositories/backup_enabled_repos.rb +16 -0
- data/definitions/procedures/repositories/disable.rb +1 -1
- data/definitions/procedures/repositories/enable.rb +13 -0
- data/definitions/scenarios/puppet.rb +21 -0
- data/definitions/scenarios/restore.rb +13 -2
- data/definitions/scenarios/self_upgrade.rb +102 -0
- data/definitions/scenarios/upgrade_to_capsule_7_0.rb +89 -0
- data/definitions/scenarios/upgrade_to_capsule_7_0_z.rb +89 -0
- data/definitions/scenarios/upgrade_to_satellite_6_10.rb +1 -8
- data/definitions/scenarios/upgrade_to_satellite_7_0.rb +93 -0
- data/definitions/scenarios/upgrade_to_satellite_7_0_z.rb +90 -0
- data/lib/foreman_maintain/cli/plugin_command.rb +14 -0
- data/lib/foreman_maintain/cli/restore_command.rb +5 -1
- data/lib/foreman_maintain/cli/self_upgrade_command.rb +38 -0
- data/lib/foreman_maintain/cli.rb +4 -0
- data/lib/foreman_maintain/concerns/downstream.rb +57 -29
- data/lib/foreman_maintain/concerns/system_helpers.rb +11 -4
- data/lib/foreman_maintain/repository_manager/el.rb +85 -0
- data/lib/foreman_maintain/repository_manager.rb +13 -0
- data/lib/foreman_maintain/utils/backup.rb +1 -1
- data/lib/foreman_maintain/utils/command_runner.rb +2 -1
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +1 -0
- metadata +19 -3
- data/definitions/features/system_repos.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e70bdc300a891fd04cb9e489737a0a96a46d83977f192eddc1ee14a8deff7b9b
|
4
|
+
data.tar.gz: ac5dc055fc90930f91c844f7c7bd411d156c943d911b56d9df5aafab4262481a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce61614ae7a224595e48ef2cf4a8e0f268e3a7f1f59b8bc67af8ea19c7926ee6fe2d1f6474a8a13fb758627e7c2aa87d272163a064298c208a97e6e3279978da
|
7
|
+
data.tar.gz: 983efdf31d1fdfc9dedca4c66374d178ef34310da40900e60af7f85550627d0416f88713316c93551f66c75bc775d7a533524b38b1e28e603944c6edf3d8bb6d
|
@@ -33,9 +33,11 @@ class Checks::CheckForNewerPackages < ForemanMaintain::Check
|
|
33
33
|
end
|
34
34
|
|
35
35
|
unless packages_with_updates.empty?
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
command = ForemanMaintain.pkg_and_cmd_name[1]
|
37
|
+
fail! 'Required updates for some packages detected.'\
|
38
|
+
"\nPlease update to the latest #{@manual_confirmation_version}.z release "\
|
39
|
+
'before proceeding, using:'\
|
40
|
+
"\n# #{command} upgrade run --target-version #{@manual_confirmation_version}.z"
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -39,8 +39,8 @@ module Checks
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
@
|
42
|
+
def data_dirs
|
43
|
+
@data_dirs ||= %i[pulpcore_database mongo foreman_database].inject({}) do |dirs, f|
|
44
44
|
if feature(f) && File.directory?(feature(f).data_dir)
|
45
45
|
dirs[feature(f).label_dashed] = feature(f).data_dir
|
46
46
|
end
|
@@ -48,20 +48,32 @@ module Checks
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
def pulp_dir
|
52
|
+
@pulp_dir ||= begin
|
53
|
+
pulp_feature = feature(:pulp2) || feature(:pulpcore_database)
|
54
|
+
{ pulp_feature.label_dashed => pulp_feature.pulp_data_dir }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
51
58
|
def description
|
52
|
-
|
59
|
+
'Check recommended disk speed for '\
|
60
|
+
"#{[data_dirs.keys | pulp_dir.keys].join(', ')} directories."
|
61
|
+
end
|
62
|
+
|
63
|
+
def all_dirs
|
64
|
+
data_dirs.values | pulp_dir.values
|
53
65
|
end
|
54
66
|
|
55
67
|
def check_only_single_device?
|
56
|
-
|
68
|
+
all_dirs.each do |dir|
|
57
69
|
ForemanMaintain::Utils::Disk::Device.new(dir).name
|
58
70
|
end.uniq.length <= 1
|
59
71
|
end
|
60
72
|
|
61
73
|
def dirs_to_check
|
62
|
-
return
|
74
|
+
return all_dirs.first(1) if check_only_single_device?
|
63
75
|
|
64
|
-
|
76
|
+
all_dirs
|
65
77
|
end
|
66
78
|
|
67
79
|
private
|
@@ -74,11 +86,10 @@ module Checks
|
|
74
86
|
def compute_disk_speed(spinner)
|
75
87
|
success = true
|
76
88
|
io_obj = ForemanMaintain::Utils::Disk::NilDevice.new
|
77
|
-
|
78
89
|
dirs_to_check.each do |dir|
|
79
90
|
io_obj = ForemanMaintain::Utils::Disk::Device.new(dir)
|
80
91
|
|
81
|
-
spinner.update("[Speed check In-Progress] device
|
92
|
+
spinner.update("[Speed check In-Progress] device:#{io_obj.name}")
|
82
93
|
stats << io_obj
|
83
94
|
|
84
95
|
next if io_obj.read_speed >= EXPECTED_IO
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Checks
|
2
|
+
class CheckPuppetCapsules < ForemanMaintain::Check
|
3
|
+
metadata do
|
4
|
+
label :puppet_capsules
|
5
|
+
for_feature :foreman_database
|
6
|
+
description 'Check for Puppet capsules from the database'
|
7
|
+
manual_detection
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
puppet_proxies = find_puppet_proxies.reject { |proxy| local_proxy?(proxy['url']) }
|
12
|
+
unless puppet_proxies.empty?
|
13
|
+
names = puppet_proxies.map { |proxy| proxy['name'] }
|
14
|
+
print('You have proxies with Puppet feature enabled, '\
|
15
|
+
"please disable Puppet on all proxies first.\n"\
|
16
|
+
"The following proxies have Puppet feature: #{names.join(', ')}.")
|
17
|
+
abort!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_puppet_proxies
|
22
|
+
feature(:foreman_database).query(puppet_proxies_query)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def local_proxy?(url)
|
28
|
+
URI.parse(url).hostname.casecmp(hostname) == 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def puppet_proxies_query
|
32
|
+
<<-SQL
|
33
|
+
SELECT \"smart_proxies\".*
|
34
|
+
FROM \"smart_proxies\"
|
35
|
+
INNER JOIN \"smart_proxy_features\"
|
36
|
+
ON \"smart_proxies\".\"id\" = \"smart_proxy_features\".\"smart_proxy_id\"
|
37
|
+
INNER JOIN \"features\"
|
38
|
+
ON \"features\".\"id\" = \"smart_proxy_features\".\"feature_id\"
|
39
|
+
WHERE \"features\".\"name\" = 'Puppet'
|
40
|
+
SQL
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -44,7 +44,9 @@ module Checks::ForemanProxy
|
|
44
44
|
def self.lookup_token_duration
|
45
45
|
data = feature(:foreman_database). \
|
46
46
|
query("select s.value, s.default from settings s \
|
47
|
-
where category
|
47
|
+
where category IN ('Setting::Provisioning','Setting') \
|
48
|
+
and name = 'token_duration'")
|
49
|
+
|
48
50
|
YAML.load(data[0]['value'] || data[0]['default'])
|
49
51
|
end
|
50
52
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Checks
|
2
|
+
module Pulpcore
|
3
|
+
class GroupOwnershipCheck < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
description 'Check the group owner of /var/lib/pulp directory'
|
6
|
+
label :group_ownership_check_of_pulp_content
|
7
|
+
manual_detection
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
group_id = File.stat('/var/lib/pulp/').gid
|
12
|
+
if Etc.getgrgid(group_id).name != 'pulp'
|
13
|
+
fail! "Please run 'foreman-maintain prep-6.10-upgrade' prior to upgrading."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -11,13 +11,18 @@ module Checks::Repositories
|
|
11
11
|
|
12
12
|
def run
|
13
13
|
with_spinner('Checking repositories enabled on the system') do
|
14
|
-
assert(
|
14
|
+
assert(epel_not_enabled?, 'System is subscribed to non Red Hat repositories')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
system_repos =
|
20
|
-
system_repos.
|
18
|
+
def epel_not_enabled?
|
19
|
+
system_repos = repository_manager.enabled_repos
|
20
|
+
system_repos.each do |repoid, repourl|
|
21
|
+
unless repoid.match(/\bepel\b/i).nil? || repourl.match(/\bepel\b/i).nil?
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
true
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -14,10 +14,10 @@ class Checks::CheckUpstreamRepository < ForemanMaintain::Check
|
|
14
14
|
|
15
15
|
def run
|
16
16
|
with_spinner('Checking for presence of upstream repositories') do
|
17
|
-
|
18
|
-
assert(
|
19
|
-
"System has upstream #{
|
20
|
-
:next_steps => Procedures::Repositories::Disable.new(:repos =>
|
17
|
+
enabled_repo_ids = feature(:upstream_repositories).repoids_and_urls.keys
|
18
|
+
assert(enabled_repo_ids.empty?,
|
19
|
+
"System has upstream #{enabled_repo_ids.join(',')} repositories enabled",
|
20
|
+
:next_steps => Procedures::Repositories::Disable.new(:repos => enabled_repo_ids))
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -17,6 +17,17 @@ class Features::ForemanTasks < ForemanMaintain::Feature
|
|
17
17
|
Actions::Candlepin::ListenOnCandlepinEvents
|
18
18
|
Actions::Katello::EventQueue::Monitor
|
19
19
|
Actions::Insights::EmailPoller
|
20
|
+
ForemanInventoryUpload::Async::GenerateReportJob
|
21
|
+
ForemanInventoryUpload::Async::QueueForUploadJob
|
22
|
+
ForemanInventoryUpload::Async::UploadReportJob
|
23
|
+
InsightsCloud::Async::InsightsClientStatusAging
|
24
|
+
InsightsCloud::Async::InsightsFullSync
|
25
|
+
InsightsCloud::Async::InsightsResolutionsSync
|
26
|
+
InsightsCloud::Async::InsightsRulesSync
|
27
|
+
InventorySync::Async::InventoryFullSync
|
28
|
+
InventorySync::Async::InventoryHostsSync
|
29
|
+
InventorySync::Async::InventoryScheduledSync
|
30
|
+
InventorySync::Async::InventorySelfHostSync
|
20
31
|
].freeze
|
21
32
|
|
22
33
|
metadata do
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Features::UpstreamRepositories < ForemanMaintain::Feature
|
2
|
+
metadata do
|
3
|
+
label :upstream_repositories
|
4
|
+
description 'Feature for operations on upstream repositories'
|
5
|
+
end
|
6
|
+
|
7
|
+
def repoids_and_urls
|
8
|
+
repoids_and_urls = {}
|
9
|
+
repository_manager.enabled_repos.each do |repo, url|
|
10
|
+
repo_urls.each do |regex|
|
11
|
+
repoids_and_urls[repo] = url if url =~ regex
|
12
|
+
end
|
13
|
+
end
|
14
|
+
repoids_and_urls
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def repo_urls
|
20
|
+
[%r{yum.theforeman.org\/*},
|
21
|
+
%r{yum.puppetlabs.com\/*}]
|
22
|
+
end
|
23
|
+
end
|
@@ -10,7 +10,7 @@ module Procedures::Content
|
|
10
10
|
sleep(20) # in satellite 6.9 the services are still coming up
|
11
11
|
# use interactive to get realtime output
|
12
12
|
env_vars = @quiet ? '' : 'preserve_output=true '
|
13
|
-
|
13
|
+
execute!("#{env_vars}foreman-rake katello:pulp3_migration", :interactive => true)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,7 +5,9 @@ module Procedures::Installer
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run
|
8
|
-
|
8
|
+
# only run this in the Satellite scenario, as in others
|
9
|
+
# the installer runs this rake task for us already
|
10
|
+
execute!('foreman-rake upgrade:run') if feature(:satellite)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -86,6 +86,8 @@ module Procedures::Pulp
|
|
86
86
|
drop_migrations
|
87
87
|
|
88
88
|
delete_pulp_data(rm_cmds) if rm_cmds.any?
|
89
|
+
|
90
|
+
restart_pulpcore_services
|
89
91
|
end
|
90
92
|
|
91
93
|
def remove_pulp
|
@@ -168,5 +170,15 @@ module Procedures::Pulp
|
|
168
170
|
spinner.update('Done deleting pulp2 data directories')
|
169
171
|
end
|
170
172
|
end
|
173
|
+
|
174
|
+
def restart_pulpcore_services
|
175
|
+
with_spinner('Restarting pulpcore services') do |spinner|
|
176
|
+
pulp_services = feature(:pulpcore).services
|
177
|
+
|
178
|
+
feature(:service).handle_services(spinner, 'stop', :only => pulp_services)
|
179
|
+
feature(:service).handle_services(spinner, 'start', :only => pulp_services)
|
180
|
+
spinner.update('Done restarting pulpcore services')
|
181
|
+
end
|
182
|
+
end
|
171
183
|
end
|
172
184
|
end
|
@@ -18,7 +18,7 @@ module Procedures::Pulpcore
|
|
18
18
|
spinner.update('Migrating pulpcore database')
|
19
19
|
execute!('sudo PULP_SETTINGS=/etc/pulp/settings.py '\
|
20
20
|
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings '\
|
21
|
-
'
|
21
|
+
'pulpcore-manager migrate --noinput')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Procedures::Puppet
|
2
|
+
class RemovePuppet < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Remove Puppet feature'
|
5
|
+
confine do
|
6
|
+
feature(:puppet_server) &&
|
7
|
+
(check_min_version('foreman', '3.0') || check_min_version('foreman-proxy', '3.0'))
|
8
|
+
end
|
9
|
+
advanced_run false
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
services = feature(:foreman_server).services + feature(:dynflow_sidekiq).services
|
14
|
+
Procedures::Service::Stop.new(:only => services)
|
15
|
+
execute!('foreman-rake db:migrate VERSION=0 SCOPE=foreman_puppet') if server_with_puppet?
|
16
|
+
feature(:installer).run(installer_arguments_disabling_puppet.join(' '), :interactive => false)
|
17
|
+
packages_action(:remove, packages_to_remove, :assumeyes => true)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def server_with_puppet?
|
23
|
+
find_package(foreman_plugin_name('foreman_puppet'))
|
24
|
+
end
|
25
|
+
|
26
|
+
def installer_arguments_disabling_puppet
|
27
|
+
answers = feature(:installer).answers
|
28
|
+
|
29
|
+
options = []
|
30
|
+
options << '--no-enable-puppet' if answers.key?('puppet')
|
31
|
+
options << '--no-enable-foreman-plugin-puppet' if answers['foreman::plugin::puppet']
|
32
|
+
options << '--no-enable-foreman-cli-puppet' if answers['foreman::cli::puppet']
|
33
|
+
if answers['foreman_proxy']
|
34
|
+
options << '--foreman-proxy-puppet false'
|
35
|
+
options << '--foreman-proxy-puppetca false'
|
36
|
+
end
|
37
|
+
options << '--foreman-proxy-content-puppet false' if answers.key?('foreman_proxy_content')
|
38
|
+
options
|
39
|
+
end
|
40
|
+
|
41
|
+
def packages_to_remove
|
42
|
+
packages = ['puppetserver']
|
43
|
+
if server_with_puppet?
|
44
|
+
packages << foreman_plugin_name('foreman_puppet')
|
45
|
+
packages << hammer_plugin_name('foreman_puppet')
|
46
|
+
end
|
47
|
+
packages
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Procedures::Puppet
|
2
|
+
class RemovePuppetData < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Remove Puppet data'
|
5
|
+
end
|
6
|
+
|
7
|
+
def run
|
8
|
+
execute!('foreman-rake purge:puppet')
|
9
|
+
execute!('rm -r ' + files_to_purge.join(' '))
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def files_to_purge
|
15
|
+
%w[
|
16
|
+
/etc/puppetlabs
|
17
|
+
/opt/puppetlabs/server/data
|
18
|
+
]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Procedures::Repositories
|
2
|
+
class BackupEnabledRepos < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
label :backup_enabled_repos
|
5
|
+
description 'Stores enabled repositories in yaml file'
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
enabled_repos_ids = repository_manager.enabled_repos.keys
|
10
|
+
unless enabled_repos_ids.empty?
|
11
|
+
backup_dir = File.expand_path(ForemanMaintain.config.backup_dir)
|
12
|
+
File.write(File.join(backup_dir, 'enabled_repos.yml'), enabled_repos_ids.to_yaml)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Procedures::Repositories
|
2
|
+
class Enable < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
param :repos, 'List of repositories to enable'
|
5
|
+
description 'Enable repositories'
|
6
|
+
end
|
7
|
+
def run
|
8
|
+
with_spinner('Enabling repositories') do
|
9
|
+
repository_manager.enable_repos(@repos)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ForemanMaintain::Scenarios
|
2
|
+
module Puppet
|
3
|
+
class RemovePuppet < ForemanMaintain::Scenario
|
4
|
+
metadata do
|
5
|
+
description 'Remove Puppet feature'
|
6
|
+
tags :puppet_disable
|
7
|
+
label :puppet_disable
|
8
|
+
param :remove_data, 'Purge the Puppet data after disabling plugin'
|
9
|
+
manual_detection
|
10
|
+
end
|
11
|
+
|
12
|
+
def compose
|
13
|
+
if check_min_version('foreman', '3.0') || check_min_version('foreman-proxy', '3.0')
|
14
|
+
add_step(Checks::CheckPuppetCapsules) if server?
|
15
|
+
add_step(Procedures::Puppet::RemovePuppet)
|
16
|
+
add_step(Procedures::Puppet::RemovePuppetData) if context.get(:remove_data)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -6,19 +6,27 @@ module ForemanMaintain::Scenarios
|
|
6
6
|
description 'Restore backup'
|
7
7
|
param :backup_dir, 'Path to backup directory'
|
8
8
|
param :incremental_backup, 'Is the backup incremental?'
|
9
|
+
param :dry_run, 'Check if backup could be restored, without performing the restore'
|
9
10
|
manual_detection
|
10
11
|
end
|
11
12
|
|
12
13
|
# rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
14
|
+
# rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
13
15
|
def compose
|
14
16
|
backup = ForemanMaintain::Utils::Backup.new(context.get(:backup_dir))
|
15
17
|
|
16
18
|
add_steps(find_checks(:root_user))
|
17
19
|
supported_version_check
|
18
20
|
add_steps_with_context(Checks::Restore::ValidateBackup,
|
19
|
-
Procedures::Restore::Confirmation,
|
20
21
|
Checks::Restore::ValidateHostname,
|
21
|
-
Checks::Restore::ValidateInterfaces
|
22
|
+
Checks::Restore::ValidateInterfaces)
|
23
|
+
|
24
|
+
if context.get(:dry_run)
|
25
|
+
self.class.metadata[:run_strategy] = :fail_slow
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
add_steps_with_context(Procedures::Restore::Confirmation,
|
22
30
|
Procedures::Selinux::SetFileSecurity,
|
23
31
|
Procedures::Restore::Configs)
|
24
32
|
add_step_with_context(Procedures::Crond::Stop) if feature(:cron)
|
@@ -43,9 +51,12 @@ module ForemanMaintain::Scenarios
|
|
43
51
|
add_steps_with_context(Procedures::Restore::RegenerateQueues) if backup.online_backup?
|
44
52
|
add_steps_with_context(Procedures::Service::Start,
|
45
53
|
Procedures::Service::DaemonReload)
|
54
|
+
add_step(Procedures::Installer::Upgrade.new(:assumeyes => true))
|
55
|
+
add_step_with_context(Procedures::Installer::UpgradeRakeTask)
|
46
56
|
add_step_with_context(Procedures::Crond::Start) if feature(:cron)
|
47
57
|
end
|
48
58
|
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize
|
59
|
+
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
49
60
|
|
50
61
|
def drop_dbs(backup)
|
51
62
|
if backup.file_map[:candlepin_dump][:present] ||
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module ForemanMaintain::Scenarios
|
2
|
+
class SelfUpgradeBase < ForemanMaintain::Scenario
|
3
|
+
def enabled_system_repos_id
|
4
|
+
repository_manager.enabled_repos.keys
|
5
|
+
end
|
6
|
+
|
7
|
+
def enable_repos(repo_ids = stored_enabled_repos_ids)
|
8
|
+
add_step(Procedures::Repositories::Enable.new(repos: repo_ids))
|
9
|
+
end
|
10
|
+
|
11
|
+
def disable_repos(repo_ids = stored_enabled_repos_ids)
|
12
|
+
add_step(Procedures::Repositories::Disable.new(repos: repo_ids))
|
13
|
+
end
|
14
|
+
|
15
|
+
def target_version
|
16
|
+
@target_version ||= context.get(:target_version)
|
17
|
+
end
|
18
|
+
|
19
|
+
def current_version
|
20
|
+
feature(:instance).downstream.current_minor_version
|
21
|
+
end
|
22
|
+
|
23
|
+
def maintenance_repo_id(version)
|
24
|
+
if (repo = ENV['maintenance_repo'])
|
25
|
+
return repo unless repo.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
maintenance_repo(version)
|
29
|
+
end
|
30
|
+
|
31
|
+
def maintenance_repo(version)
|
32
|
+
if el7?
|
33
|
+
"rhel-#{el_major_version}-server-satellite-maintenance-#{version}-rpms"
|
34
|
+
else
|
35
|
+
"satellite-maintenance-#{version}-for-rhel-#{el_major_version}-x86_64-rpms"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def maintenance_repo_version
|
40
|
+
return '6' if current_version == '6.10'
|
41
|
+
|
42
|
+
current_version
|
43
|
+
end
|
44
|
+
|
45
|
+
def stored_enabled_repos_ids
|
46
|
+
@stored_enabled_repos_ids ||= begin
|
47
|
+
path = File.expand_path('enabled_repos.yml', ForemanMaintain.config.backup_dir)
|
48
|
+
@stored_enabled_repos_ids = File.file?(path) ? YAML.load(File.read(path)) : []
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def all_maintenance_repos
|
53
|
+
repo_regex = if el7?
|
54
|
+
/rhel-\d-server-satellite-maintenance-\d.\d-rpms/
|
55
|
+
else
|
56
|
+
/satellite-maintenance-\d.\d-for-rhel-\d-x86_64-rpms/
|
57
|
+
end
|
58
|
+
stored_enabled_repos_ids.select { |id| !id.match(repo_regex).nil? }
|
59
|
+
end
|
60
|
+
|
61
|
+
def repos_ids_to_reenable
|
62
|
+
repos_ids_to_reenable = stored_enabled_repos_ids - all_maintenance_repos
|
63
|
+
repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class SelfUpgrade < SelfUpgradeBase
|
68
|
+
metadata do
|
69
|
+
label :self_upgrade_foreman_maintain
|
70
|
+
description "Enables the specified version's maintenance repository and, "\
|
71
|
+
'updates the foreman-maintain packages'
|
72
|
+
manual_detection
|
73
|
+
end
|
74
|
+
|
75
|
+
def compose
|
76
|
+
if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
|
77
|
+
pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
|
78
|
+
add_step(Procedures::Repositories::BackupEnabledRepos.new)
|
79
|
+
disable_repos
|
80
|
+
add_step(Procedures::Repositories::Enable.new(repos: [maintenance_repo_id(target_version)]))
|
81
|
+
add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true))
|
82
|
+
enable_repos(repos_ids_to_reenable)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class SelfUpgradeRescue < SelfUpgradeBase
|
88
|
+
metadata do
|
89
|
+
label :rescue_self_upgrade
|
90
|
+
description 'Disables all version specific maintenance repos and,'\
|
91
|
+
' enables the repositories which were configured prior to self upgrade'
|
92
|
+
manual_detection
|
93
|
+
run_strategy :fail_slow
|
94
|
+
end
|
95
|
+
|
96
|
+
def compose
|
97
|
+
if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
|
98
|
+
enable_repos(repos_ids_to_reenable)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|