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
@@ -0,0 +1,89 @@
|
|
1
|
+
module Scenarios::Capsule_7_0
|
2
|
+
class Abstract < ForemanMaintain::Scenario
|
3
|
+
def self.upgrade_metadata(&block)
|
4
|
+
metadata do
|
5
|
+
tags :upgrade_scenario
|
6
|
+
confine do
|
7
|
+
feature(:capsule) &&
|
8
|
+
(feature(:capsule).current_minor_version == '6.10' || \
|
9
|
+
ForemanMaintain.upgrade_in_progress == '7.0')
|
10
|
+
end
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def target_version
|
16
|
+
'7.0'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class PreUpgradeCheck < Abstract
|
21
|
+
upgrade_metadata do
|
22
|
+
description 'Checks before upgrading to Capsule 7.0'
|
23
|
+
tags :pre_upgrade_checks
|
24
|
+
run_strategy :fail_slow
|
25
|
+
end
|
26
|
+
|
27
|
+
def compose
|
28
|
+
add_steps(find_checks(:default))
|
29
|
+
add_steps(find_checks(:pre_upgrade))
|
30
|
+
add_step(Checks::Repositories::Validate.new(:version => '7.0'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class PreMigrations < Abstract
|
35
|
+
upgrade_metadata do
|
36
|
+
description 'Procedures before migrating to Capsule 7.0'
|
37
|
+
tags :pre_migrations
|
38
|
+
end
|
39
|
+
|
40
|
+
def compose
|
41
|
+
add_steps(find_procedures(:pre_migrations))
|
42
|
+
add_step(Procedures::Service::Stop.new)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Migrations < Abstract
|
47
|
+
upgrade_metadata do
|
48
|
+
description 'Migration scripts to Capsule 7.0'
|
49
|
+
tags :migrations
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_context_mapping
|
53
|
+
context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def compose
|
57
|
+
add_step(Procedures::Repositories::Setup.new(:version => '7.0'))
|
58
|
+
add_step(Procedures::Packages::UnlockVersions.new)
|
59
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
60
|
+
add_step_with_context(Procedures::Installer::Upgrade)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class PostMigrations < Abstract
|
65
|
+
upgrade_metadata do
|
66
|
+
description 'Procedures after migrating to Capsule 7.0'
|
67
|
+
tags :post_migrations
|
68
|
+
end
|
69
|
+
|
70
|
+
def compose
|
71
|
+
add_step(Procedures::RefreshFeatures)
|
72
|
+
add_step(Procedures::Service::Start.new)
|
73
|
+
add_steps(find_procedures(:post_migrations))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class PostUpgradeChecks < Abstract
|
78
|
+
upgrade_metadata do
|
79
|
+
description 'Checks after upgrading to Capsule 7.0'
|
80
|
+
tags :post_upgrade_checks
|
81
|
+
run_strategy :fail_slow
|
82
|
+
end
|
83
|
+
|
84
|
+
def compose
|
85
|
+
add_steps(find_checks(:default))
|
86
|
+
add_steps(find_checks(:post_upgrade))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Scenarios::Capsule_7_0_z
|
2
|
+
class Abstract < ForemanMaintain::Scenario
|
3
|
+
def self.upgrade_metadata(&block)
|
4
|
+
metadata do
|
5
|
+
tags :upgrade_scenario
|
6
|
+
confine do
|
7
|
+
feature(:capsule) &&
|
8
|
+
(feature(:capsule).current_minor_version == '7.0' || \
|
9
|
+
ForemanMaintain.upgrade_in_progress == '7.0.z')
|
10
|
+
end
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def target_version
|
16
|
+
'7.0.z'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class PreUpgradeCheck < Abstract
|
21
|
+
upgrade_metadata do
|
22
|
+
description 'Checks before upgrading to Capsule 7.0.z'
|
23
|
+
tags :pre_upgrade_checks
|
24
|
+
run_strategy :fail_slow
|
25
|
+
end
|
26
|
+
|
27
|
+
def compose
|
28
|
+
add_steps(find_checks(:default))
|
29
|
+
add_steps(find_checks(:pre_upgrade))
|
30
|
+
add_step(Checks::Repositories::Validate.new(:version => '7.0'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class PreMigrations < Abstract
|
35
|
+
upgrade_metadata do
|
36
|
+
description 'Procedures before migrating to Capsule 7.0.z'
|
37
|
+
tags :pre_migrations
|
38
|
+
end
|
39
|
+
|
40
|
+
def compose
|
41
|
+
add_steps(find_procedures(:pre_migrations))
|
42
|
+
add_step(Procedures::Service::Stop.new)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Migrations < Abstract
|
47
|
+
upgrade_metadata do
|
48
|
+
description 'Migration scripts to Capsule 7.0.z'
|
49
|
+
tags :migrations
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_context_mapping
|
53
|
+
context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def compose
|
57
|
+
add_step(Procedures::Repositories::Setup.new(:version => '7.0'))
|
58
|
+
add_step(Procedures::Packages::UnlockVersions.new)
|
59
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
60
|
+
add_step_with_context(Procedures::Installer::Upgrade)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class PostMigrations < Abstract
|
65
|
+
upgrade_metadata do
|
66
|
+
description 'Procedures after migrating to Capsule 7.0.z'
|
67
|
+
tags :post_migrations
|
68
|
+
end
|
69
|
+
|
70
|
+
def compose
|
71
|
+
add_step(Procedures::RefreshFeatures)
|
72
|
+
add_step(Procedures::Service::Start.new)
|
73
|
+
add_steps(find_procedures(:post_migrations))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class PostUpgradeChecks < Abstract
|
78
|
+
upgrade_metadata do
|
79
|
+
description 'Checks after upgrading to Capsule 7.0.z'
|
80
|
+
tags :post_upgrade_checks
|
81
|
+
run_strategy :fail_slow
|
82
|
+
end
|
83
|
+
|
84
|
+
def compose
|
85
|
+
add_steps(find_checks(:default))
|
86
|
+
add_steps(find_checks(:post_upgrade))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -25,6 +25,7 @@ module Scenarios::Satellite_6_10
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def compose
|
28
|
+
add_step(Checks::Pulpcore::GroupOwnershipCheck)
|
28
29
|
add_step(Checks::Puppet::WarnAboutPuppetRemoval)
|
29
30
|
add_step(Checks::CheckForNewerPackages.new(:packages => [foreman_plugin_name('katello'),
|
30
31
|
'python3-pulp-2to3-migration'],
|
@@ -61,13 +62,6 @@ module Scenarios::Satellite_6_10
|
|
61
62
|
context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
|
62
63
|
end
|
63
64
|
|
64
|
-
def check_var_lib_pulp
|
65
|
-
group_id = File.stat('/var/lib/pulp/').gid
|
66
|
-
if Etc.getgrgid(group_id).name != 'pulp'
|
67
|
-
raise "Please run 'foreman-maintain prep-6.10-upgrade' prior to upgrading."
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
65
|
def pulp3_switchover_steps
|
72
66
|
add_step(Procedures::Service::Enable.
|
73
67
|
new(:only => Features::Pulpcore.pulpcore_migration_services))
|
@@ -79,7 +73,6 @@ module Scenarios::Satellite_6_10
|
|
79
73
|
end
|
80
74
|
|
81
75
|
def compose
|
82
|
-
check_var_lib_pulp
|
83
76
|
unless check_min_version(foreman_plugin_name('katello'), '4.0')
|
84
77
|
pulp3_switchover_steps
|
85
78
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Scenarios::Satellite_7_0
|
2
|
+
class Abstract < ForemanMaintain::Scenario
|
3
|
+
def self.upgrade_metadata(&block)
|
4
|
+
metadata do
|
5
|
+
tags :upgrade_scenario
|
6
|
+
confine do
|
7
|
+
feature(:satellite) &&
|
8
|
+
(feature(:satellite).current_minor_version == '6.10' || \
|
9
|
+
ForemanMaintain.upgrade_in_progress == '7.0')
|
10
|
+
end
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def target_version
|
16
|
+
'7.0'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class PreUpgradeCheck < Abstract
|
21
|
+
upgrade_metadata do
|
22
|
+
description 'Checks before upgrading to Satellite 7.0'
|
23
|
+
tags :pre_upgrade_checks
|
24
|
+
run_strategy :fail_slow
|
25
|
+
end
|
26
|
+
|
27
|
+
def compose
|
28
|
+
add_steps(find_checks(:default))
|
29
|
+
add_steps(find_checks(:pre_upgrade))
|
30
|
+
|
31
|
+
add_step(Checks::Foreman::CheckpointSegments)
|
32
|
+
add_step(Checks::Repositories::Validate.new(:version => '7.0'))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class PreMigrations < Abstract
|
37
|
+
upgrade_metadata do
|
38
|
+
description 'Procedures before migrating to Satellite 7.0'
|
39
|
+
tags :pre_migrations
|
40
|
+
end
|
41
|
+
|
42
|
+
def compose
|
43
|
+
add_steps(find_procedures(:pre_migrations))
|
44
|
+
add_step(Procedures::Service::Stop.new)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Migrations < Abstract
|
49
|
+
upgrade_metadata do
|
50
|
+
description 'Migration scripts to Satellite 7.0'
|
51
|
+
tags :migrations
|
52
|
+
run_strategy :fail_fast
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_context_mapping
|
56
|
+
context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
|
57
|
+
end
|
58
|
+
|
59
|
+
def compose
|
60
|
+
add_step(Procedures::Repositories::Setup.new(:version => '7.0'))
|
61
|
+
add_step(Procedures::Packages::UnlockVersions.new)
|
62
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
63
|
+
add_step_with_context(Procedures::Installer::Upgrade)
|
64
|
+
add_step(Procedures::Installer::UpgradeRakeTask)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class PostMigrations < Abstract
|
69
|
+
upgrade_metadata do
|
70
|
+
description 'Procedures after migrating to Satellite 7.0'
|
71
|
+
tags :post_migrations
|
72
|
+
end
|
73
|
+
|
74
|
+
def compose
|
75
|
+
add_step(Procedures::RefreshFeatures)
|
76
|
+
add_step(Procedures::Service::Start.new)
|
77
|
+
add_steps(find_procedures(:post_migrations))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class PostUpgradeChecks < Abstract
|
82
|
+
upgrade_metadata do
|
83
|
+
description 'Checks after upgrading to Satellite 7.0'
|
84
|
+
tags :post_upgrade_checks
|
85
|
+
run_strategy :fail_slow
|
86
|
+
end
|
87
|
+
|
88
|
+
def compose
|
89
|
+
add_steps(find_checks(:default))
|
90
|
+
add_steps(find_checks(:post_upgrade))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Scenarios::Satellite_7_0_z
|
2
|
+
class Abstract < ForemanMaintain::Scenario
|
3
|
+
def self.upgrade_metadata(&block)
|
4
|
+
metadata do
|
5
|
+
tags :upgrade_scenario
|
6
|
+
confine do
|
7
|
+
feature(:satellite) &&
|
8
|
+
(feature(:satellite).current_minor_version == '7.0' || \
|
9
|
+
ForemanMaintain.upgrade_in_progress == '7.0.z')
|
10
|
+
end
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def target_version
|
16
|
+
'7.0.z'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class PreUpgradeCheck < Abstract
|
21
|
+
upgrade_metadata do
|
22
|
+
description 'Checks before upgrading to Satellite 7.0.z'
|
23
|
+
tags :pre_upgrade_checks
|
24
|
+
run_strategy :fail_slow
|
25
|
+
end
|
26
|
+
|
27
|
+
def compose
|
28
|
+
add_steps(find_checks(:default))
|
29
|
+
add_steps(find_checks(:pre_upgrade))
|
30
|
+
add_step(Checks::Repositories::Validate.new(:version => '7.0'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class PreMigrations < Abstract
|
35
|
+
upgrade_metadata do
|
36
|
+
description 'Procedures before migrating to Satellite 7.0.z'
|
37
|
+
tags :pre_migrations
|
38
|
+
end
|
39
|
+
|
40
|
+
def compose
|
41
|
+
add_steps(find_procedures(:pre_migrations))
|
42
|
+
add_step(Procedures::Service::Stop.new)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Migrations < Abstract
|
47
|
+
upgrade_metadata do
|
48
|
+
description 'Migration scripts to Satellite 7.0.z'
|
49
|
+
tags :migrations
|
50
|
+
end
|
51
|
+
|
52
|
+
def set_context_mapping
|
53
|
+
context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def compose
|
57
|
+
add_step(Procedures::Repositories::Setup.new(:version => '7.0'))
|
58
|
+
add_step(Procedures::Packages::UnlockVersions.new)
|
59
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
60
|
+
add_step_with_context(Procedures::Installer::Upgrade)
|
61
|
+
add_step(Procedures::Installer::UpgradeRakeTask)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class PostMigrations < Abstract
|
66
|
+
upgrade_metadata do
|
67
|
+
description 'Procedures after migrating to Satellite 7.0.z'
|
68
|
+
tags :post_migrations
|
69
|
+
end
|
70
|
+
|
71
|
+
def compose
|
72
|
+
add_step(Procedures::RefreshFeatures)
|
73
|
+
add_step(Procedures::Service::Start.new)
|
74
|
+
add_steps(find_procedures(:post_migrations))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class PostUpgradeChecks < Abstract
|
79
|
+
upgrade_metadata do
|
80
|
+
description 'Checks after upgrading to Satellite 7.0.z'
|
81
|
+
tags :post_upgrade_checks
|
82
|
+
run_strategy :fail_slow
|
83
|
+
end
|
84
|
+
|
85
|
+
def compose
|
86
|
+
add_steps(find_checks(:default))
|
87
|
+
add_steps(find_checks(:post_upgrade))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Cli
|
3
|
+
class PluginCommand < Base
|
4
|
+
subcommand 'purge-puppet', 'Remove the Puppet feature' do
|
5
|
+
option ['-f', '--remove-all-data'], :flag, 'Purge all the Puppet data',
|
6
|
+
:attribute_name => :remove_data
|
7
|
+
|
8
|
+
def execute
|
9
|
+
run_scenarios_and_exit(Scenarios::Puppet::RemovePuppet.new(:remove_data => remove_data?))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -7,11 +7,15 @@ module ForemanMaintain
|
|
7
7
|
|
8
8
|
option ['-i', '--incremental'], :flag, 'Restore an incremental backup',
|
9
9
|
:attribute_name => :incremental, :completion => { :type => :directory }
|
10
|
+
option ['-n', '--dry-run'], :flag,
|
11
|
+
'Check if backup could be restored, without performing the restore',
|
12
|
+
:attribute_name => :dry_run
|
10
13
|
|
11
14
|
def execute
|
12
15
|
scenario = Scenarios::Restore.new(
|
13
16
|
:backup_dir => @backup_dir,
|
14
|
-
:incremental_backup => @incremental || incremental_backup
|
17
|
+
:incremental_backup => @incremental || incremental_backup?,
|
18
|
+
:dry_run => @dry_run
|
15
19
|
)
|
16
20
|
rescue_scenario = Scenarios::RestoreRescue.new
|
17
21
|
run_scenario(scenario, rescue_scenario)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Cli
|
3
|
+
class SelfUpgradeCommand < Base
|
4
|
+
option ['--target-version'], 'TARGET_VERSION',\
|
5
|
+
'Major version of the Satellite or Capsule'\
|
6
|
+
', e.g 7.0', :required => true
|
7
|
+
def execute
|
8
|
+
allow_major_version_upgrade_only
|
9
|
+
run_scenario(upgrade_scenario, upgrade_rescue_scenario)
|
10
|
+
end
|
11
|
+
|
12
|
+
def upgrade_scenario
|
13
|
+
Scenarios::SelfUpgrade.new(target_version: target_version)
|
14
|
+
end
|
15
|
+
|
16
|
+
def upgrade_rescue_scenario
|
17
|
+
Scenarios::SelfUpgradeRescue.new(target_version: target_version)
|
18
|
+
end
|
19
|
+
|
20
|
+
def current_downstream_version
|
21
|
+
ForemanMaintain.detector.feature(:instance).downstream.current_version
|
22
|
+
end
|
23
|
+
|
24
|
+
def allow_major_version_upgrade_only
|
25
|
+
begin
|
26
|
+
next_version = Gem::Version.new(target_version)
|
27
|
+
rescue ArgumentError => err
|
28
|
+
raise Error::UsageError, "Invalid version! #{err}"
|
29
|
+
end
|
30
|
+
if current_downstream_version >= next_version
|
31
|
+
message = "The target-version #{target_version} should be "\
|
32
|
+
"greater than existing version #{current_downstream_version}!"
|
33
|
+
raise Error::UsageError, message
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/foreman_maintain/cli.rb
CHANGED
@@ -11,6 +11,8 @@ require 'foreman_maintain/cli/restore_command'
|
|
11
11
|
require 'foreman_maintain/cli/maintenance_mode_command'
|
12
12
|
require 'foreman_maintain/cli/packages_command'
|
13
13
|
require 'foreman_maintain/cli/content_command'
|
14
|
+
require 'foreman_maintain/cli/plugin_command'
|
15
|
+
require 'foreman_maintain/cli/self_upgrade_command'
|
14
16
|
|
15
17
|
module ForemanMaintain
|
16
18
|
module Cli
|
@@ -25,6 +27,8 @@ module ForemanMaintain
|
|
25
27
|
subcommand 'packages', 'Lock/Unlock package protection, install, update', PackagesCommand
|
26
28
|
subcommand 'advanced', 'Advanced tools for server maintenance', AdvancedCommand
|
27
29
|
subcommand 'content', 'Content related commands', ContentCommand
|
30
|
+
subcommand 'plugin', 'Manage optional plugins on your server', PluginCommand
|
31
|
+
subcommand 'self-upgrade', 'Perform major version self upgrade', SelfUpgradeCommand
|
28
32
|
subcommand 'maintenance-mode', 'Control maintenance-mode for application',
|
29
33
|
MaintenanceModeCommand
|
30
34
|
if ForemanMaintain.detector.feature(:satellite) &&
|
@@ -17,6 +17,10 @@ module ForemanMaintain
|
|
17
17
|
current_version.to_s[/^\d+\.\d+/]
|
18
18
|
end
|
19
19
|
|
20
|
+
def repository_manager
|
21
|
+
ForemanMaintain.repository_manager
|
22
|
+
end
|
23
|
+
|
20
24
|
# TODO: Modify activation_key changes as per server
|
21
25
|
def setup_repositories(version)
|
22
26
|
activation_key = ENV['EXTERNAL_SAT_ACTIVATION_KEY']
|
@@ -26,18 +30,14 @@ module ForemanMaintain
|
|
26
30
|
execute!(%(subscription-manager register #{org_options}\
|
27
31
|
--activationkey #{shellescape(activation_key)} --force))
|
28
32
|
else
|
29
|
-
|
30
|
-
|
31
|
-
execute!(%(subscription-manager repos #{enable_options}))
|
33
|
+
repository_manager.rhsm_disable_repos('*')
|
34
|
+
repository_manager.rhsm_enable_repos(rh_repos(version))
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
38
|
def absent_repos(version)
|
36
|
-
all_repo_lines = execute(%(LANG=en_US.utf-8 subscription-manager repos --list 2>&1 | ) +
|
37
|
-
%(grep '^Repo ID:')).split("\n")
|
38
|
-
all_repos = all_repo_lines.map { |line| line.split(/\s+/).last }
|
39
39
|
repos_required = rh_repos(version)
|
40
|
-
repos_found = repos_required &
|
40
|
+
repos_found = repos_required & repository_manager.rhsm_list_repos.keys
|
41
41
|
repos_required - repos_found
|
42
42
|
end
|
43
43
|
|
@@ -74,21 +74,36 @@ module ForemanMaintain
|
|
74
74
|
|
75
75
|
def ansible_repo(server_version)
|
76
76
|
if server_version >= version('6.8')
|
77
|
-
|
77
|
+
ansible_version = '2.9'
|
78
78
|
elsif server_version >= version('6.6')
|
79
|
-
|
79
|
+
ansible_version = '2.8'
|
80
80
|
elsif server_version >= version('6.4')
|
81
|
-
|
81
|
+
ansible_version = '2.6'
|
82
|
+
end
|
83
|
+
|
84
|
+
if el7?
|
85
|
+
"rhel-#{el_major_version}-server-ansible-#{ansible_version}-rpms"
|
86
|
+
else
|
87
|
+
"ansible-#{ansible_version}-for-rhel-#{el_major_version}-x86_64-rpms"
|
82
88
|
end
|
83
89
|
end
|
84
90
|
|
91
|
+
def use_beta_repos?
|
92
|
+
ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
|
93
|
+
end
|
94
|
+
|
85
95
|
def product_specific_repos(full_version)
|
86
|
-
|
87
|
-
repos
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
96
|
+
maj_version = full_version[0]
|
97
|
+
repos = if el7? && use_beta_repos?
|
98
|
+
["rhel-server-#{el_major_version}-#{package_name}-#{maj_version}-beta-rpms"]
|
99
|
+
elsif el7?
|
100
|
+
["rhel-#{el_major_version}-server-#{package_name}-#{full_version}-rpms"]
|
101
|
+
elsif use_beta_repos?
|
102
|
+
["#{package_name}-#{maj_version}-beta-for-rhel-#{el_major_version}-x86_64-rpms"]
|
103
|
+
else
|
104
|
+
["#{package_name}-#{full_version}-for-rhel-#{el_major_version}-x86_64-rpms"]
|
105
|
+
end
|
106
|
+
|
92
107
|
repos << puppet4_repo(full_version) unless puppet4_repo(full_version).nil?
|
93
108
|
repos.concat(common_repos(full_version))
|
94
109
|
end
|
@@ -101,22 +116,35 @@ module ForemanMaintain
|
|
101
116
|
end
|
102
117
|
|
103
118
|
def common_repos(full_version)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
119
|
+
sat_maint_version = if version(full_version) >= version('7.0') && !use_beta_repos?
|
120
|
+
full_version
|
121
|
+
else
|
122
|
+
full_version[0]
|
123
|
+
end
|
124
|
+
|
125
|
+
# rubocop:disable Metrics/LineLength
|
126
|
+
repos = if el7? && use_beta_repos?
|
127
|
+
["rhel-#{el_major_version}-server-satellite-maintenance-#{sat_maint_version}-beta-rpms"]
|
128
|
+
elsif el7?
|
129
|
+
["rhel-#{el_major_version}-server-satellite-maintenance-#{sat_maint_version}-rpms"]
|
130
|
+
elsif use_beta_repos?
|
131
|
+
["satellite-maintenance-#{sat_maint_version}-beta-for-rhel-#{el_major_version}-x86_64-rpms"]
|
132
|
+
else
|
133
|
+
["satellite-maintenance-#{sat_maint_version}-for-rhel-#{el_major_version}-x86_64-rpms"]
|
134
|
+
end
|
135
|
+
# rubocop:enable Metrics/LineLength
|
136
|
+
|
137
|
+
repos
|
115
138
|
end
|
116
139
|
|
117
140
|
def main_rh_repos
|
118
|
-
|
119
|
-
|
141
|
+
if el7?
|
142
|
+
["rhel-#{el_major_version}-server-rpms",
|
143
|
+
"rhel-server-rhscl-#{el_major_version}-rpms"]
|
144
|
+
else
|
145
|
+
["rhel-#{el_major_version}-for-x86_64-baseos-rpms",
|
146
|
+
"rhel-#{el_major_version}-for-x86_64-appstream-rpms"]
|
147
|
+
end
|
120
148
|
end
|
121
149
|
|
122
150
|
def version_from_source
|
@@ -185,6 +185,10 @@ module ForemanMaintain
|
|
185
185
|
ForemanMaintain.package_manager
|
186
186
|
end
|
187
187
|
|
188
|
+
def repository_manager
|
189
|
+
ForemanMaintain.repository_manager
|
190
|
+
end
|
191
|
+
|
188
192
|
def ruby_prefix(scl = true)
|
189
193
|
if debian?
|
190
194
|
'ruby-'
|
@@ -196,15 +200,13 @@ module ForemanMaintain
|
|
196
200
|
end
|
197
201
|
|
198
202
|
def foreman_plugin_name(plugin)
|
199
|
-
if debian?
|
200
|
-
plugin.tr!('_', '-')
|
201
|
-
end
|
203
|
+
plugin = plugin.tr('_', '-') if debian?
|
202
204
|
ruby_prefix + plugin
|
203
205
|
end
|
204
206
|
|
205
207
|
def proxy_plugin_name(plugin)
|
206
208
|
if debian?
|
207
|
-
plugin.tr
|
209
|
+
plugin = plugin.tr('_', '-')
|
208
210
|
proxy_plugin_prefix = 'smart-proxy-'
|
209
211
|
else
|
210
212
|
proxy_plugin_prefix = 'smart_proxy_'
|
@@ -213,6 +215,11 @@ module ForemanMaintain
|
|
213
215
|
ruby_prefix(scl) + proxy_plugin_prefix + plugin
|
214
216
|
end
|
215
217
|
|
218
|
+
def hammer_plugin_name(plugin)
|
219
|
+
plugin = plugin.tr('_', '-') if debian?
|
220
|
+
[hammer_package, plugin].join(debian? ? '-' : '_')
|
221
|
+
end
|
222
|
+
|
216
223
|
def hammer_package
|
217
224
|
hammer_prefix = if debian?
|
218
225
|
'hammer-cli'
|