foreman_maintain 1.0.5 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/features/foreman_tasks.rb +14 -7
- data/definitions/procedures/packages/enable_version_locking.rb +5 -1
- data/definitions/procedures/packages/lock_versions.rb +3 -1
- data/definitions/procedures/packages/locking_status.rb +3 -1
- data/definitions/procedures/packages/unlock_versions.rb +3 -1
- data/definitions/scenarios/self_upgrade.rb +12 -3
- data/definitions/scenarios/{upgrade_to_capsule_7_0.rb → upgrade_to_capsule_6_11.rb} +10 -10
- data/definitions/scenarios/{upgrade_to_capsule_7_0_z.rb → upgrade_to_capsule_6_11_z.rb} +11 -11
- data/definitions/scenarios/{upgrade_to_satellite_7_0.rb → upgrade_to_satellite_6_11.rb} +10 -10
- data/definitions/scenarios/{upgrade_to_satellite_7_0_z.rb → upgrade_to_satellite_6_11_z.rb} +11 -11
- data/extras/foreman_protector/dnf/foreman-protector.py +77 -0
- data/extras/foreman_protector/foreman-protector.whitelist +3 -0
- data/extras/foreman_protector/{foreman-protector.py → yum/foreman-protector.py} +0 -0
- data/lib/foreman_maintain/cli/self_upgrade_command.rb +9 -24
- data/lib/foreman_maintain/concerns/downstream.rb +1 -1
- data/lib/foreman_maintain/package_manager/base.rb +2 -7
- data/lib/foreman_maintain/package_manager/dnf.rb +4 -0
- data/lib/foreman_maintain/package_manager/yum.rb +11 -18
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +8 -8
- data/definitions/checks/version_locking_enabled.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbe5e2f041a482d1800b74195b3d0cbaeb504d14345c86402d4ee9402f052999
|
4
|
+
data.tar.gz: 96420eefe94c8632ec43a52d105af613aaf7b30107e59f6a69abc9549a02200b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2207cfef121cf8a15ce12c0c961b249b31ac3fb92b2275c15df58b245fc987261c634d53bd0fad5cfe8de3c71106fd30016f76fa7ffac67da2b5ab593fb02347
|
7
|
+
data.tar.gz: a121716d79737dbe7e480bca7aa767dd17090226d8ef51f19c9f49e8ce82b7b8620416bc5cecc2a654068f7a7e0d0ed8ba93dbf2eedac71ccbbb36517f7bbd0b
|
@@ -82,15 +82,22 @@ class Features::ForemanTasks < ForemanMaintain::Feature
|
|
82
82
|
def delete(state)
|
83
83
|
tasks_condition = condition(state)
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
85
|
+
sql = <<-SQL
|
86
|
+
DELETE FROM dynflow_steps USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid::varchar) AND #{tasks_condition};
|
87
|
+
DELETE FROM dynflow_actions USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid::varchar) AND #{tasks_condition};
|
88
|
+
DELETE FROM dynflow_execution_plans USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid::varchar) AND #{tasks_condition};
|
89
|
+
DELETE FROM foreman_tasks_tasks WHERE #{tasks_condition};
|
90
|
+
-- Delete locks and links which may now be orphaned
|
91
|
+
DELETE FROM foreman_tasks_locks as ftl where ftl.task_id NOT IN (SELECT id FROM foreman_tasks_tasks);
|
92
92
|
SQL
|
93
93
|
|
94
|
+
if check_min_version(foreman_plugin_name('foreman-tasks'), '4.0.0')
|
95
|
+
sql += 'DELETE FROM foreman_tasks_links as ftl ' \
|
96
|
+
'where ftl.task_id NOT IN (SELECT id FROM foreman_tasks_tasks);'
|
97
|
+
end
|
98
|
+
|
99
|
+
feature(:foreman_database).psql("BEGIN; #{sql}; COMMIT;")
|
100
|
+
|
94
101
|
count(state)
|
95
102
|
end
|
96
103
|
|
@@ -6,7 +6,11 @@ module Procedures::Packages
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def run
|
9
|
-
|
9
|
+
installed_fm_packages = []
|
10
|
+
['satellite-maintain', 'rubygem-foreman_maintain'].each do |pkg|
|
11
|
+
installed_fm_packages << find_package(pkg)
|
12
|
+
end
|
13
|
+
package_manager.reinstall(installed_fm_packages, :assumeyes => @assumeyes)
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
@@ -2,7 +2,9 @@ module Procedures::Packages
|
|
2
2
|
class LockVersions < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
4
|
description 'Lock packages'
|
5
|
-
|
5
|
+
confine do
|
6
|
+
package_manager.version_locking_supported?
|
7
|
+
end
|
6
8
|
end
|
7
9
|
|
8
10
|
def run
|
@@ -2,7 +2,9 @@ module Procedures::Packages
|
|
2
2
|
class LockingStatus < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
4
|
description 'Check status of version locking of packages'
|
5
|
-
|
5
|
+
confine do
|
6
|
+
package_manager.version_locking_supported?
|
7
|
+
end
|
6
8
|
end
|
7
9
|
|
8
10
|
def run
|
@@ -2,7 +2,9 @@ module Procedures::Packages
|
|
2
2
|
class UnlockVersions < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
4
|
description 'Unlock packages'
|
5
|
-
|
5
|
+
confine do
|
6
|
+
package_manager.version_locking_supported?
|
7
|
+
end
|
6
8
|
end
|
7
9
|
|
8
10
|
def run
|
@@ -13,15 +13,22 @@ module ForemanMaintain::Scenarios
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def target_version
|
16
|
-
|
16
|
+
current_full_version = feature(:instance).downstream.current_version
|
17
|
+
@target_version ||= current_full_version.bump
|
17
18
|
end
|
18
19
|
|
19
20
|
def current_version
|
20
21
|
feature(:instance).downstream.current_minor_version
|
21
22
|
end
|
22
23
|
|
24
|
+
def maintenance_repo_label
|
25
|
+
@maintenance_repo_label ||= context.get(:maintenance_repo_label)
|
26
|
+
end
|
27
|
+
|
23
28
|
def maintenance_repo_id(version)
|
24
|
-
if
|
29
|
+
if maintenance_repo_label
|
30
|
+
return maintenance_repo_label
|
31
|
+
elsif (repo = ENV['MAINTENANCE_REPO_LABEL'])
|
25
32
|
return repo unless repo.empty?
|
26
33
|
end
|
27
34
|
|
@@ -64,7 +71,9 @@ module ForemanMaintain::Scenarios
|
|
64
71
|
end
|
65
72
|
|
66
73
|
def use_rhsm?
|
67
|
-
|
74
|
+
return false if maintenance_repo_label
|
75
|
+
|
76
|
+
if (repo = ENV['MAINTENANCE_REPO_LABEL'])
|
68
77
|
return false unless repo.empty?
|
69
78
|
end
|
70
79
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Scenarios::
|
1
|
+
module Scenarios::Capsule_6_11
|
2
2
|
class Abstract < ForemanMaintain::Scenario
|
3
3
|
def self.upgrade_metadata(&block)
|
4
4
|
metadata do
|
@@ -6,20 +6,20 @@ module Scenarios::Capsule_7_0
|
|
6
6
|
confine do
|
7
7
|
feature(:capsule) &&
|
8
8
|
(feature(:capsule).current_minor_version == '6.10' || \
|
9
|
-
ForemanMaintain.upgrade_in_progress == '
|
9
|
+
ForemanMaintain.upgrade_in_progress == '6.11')
|
10
10
|
end
|
11
11
|
instance_eval(&block)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def target_version
|
16
|
-
'
|
16
|
+
'6.11'
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
class PreUpgradeCheck < Abstract
|
21
21
|
upgrade_metadata do
|
22
|
-
description 'Checks before upgrading to Capsule
|
22
|
+
description 'Checks before upgrading to Capsule 6.11'
|
23
23
|
tags :pre_upgrade_checks
|
24
24
|
run_strategy :fail_slow
|
25
25
|
end
|
@@ -27,13 +27,13 @@ module Scenarios::Capsule_7_0
|
|
27
27
|
def compose
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Repositories::Validate.new(:version => '
|
30
|
+
add_step(Checks::Repositories::Validate.new(:version => '6.11'))
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
class PreMigrations < Abstract
|
35
35
|
upgrade_metadata do
|
36
|
-
description 'Procedures before migrating to Capsule
|
36
|
+
description 'Procedures before migrating to Capsule 6.11'
|
37
37
|
tags :pre_migrations
|
38
38
|
end
|
39
39
|
|
@@ -46,7 +46,7 @@ module Scenarios::Capsule_7_0
|
|
46
46
|
|
47
47
|
class Migrations < Abstract
|
48
48
|
upgrade_metadata do
|
49
|
-
description 'Migration scripts to Capsule
|
49
|
+
description 'Migration scripts to Capsule 6.11'
|
50
50
|
tags :migrations
|
51
51
|
end
|
52
52
|
|
@@ -55,7 +55,7 @@ module Scenarios::Capsule_7_0
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def compose
|
58
|
-
add_step(Procedures::Repositories::Setup.new(:version => '
|
58
|
+
add_step(Procedures::Repositories::Setup.new(:version => '6.11'))
|
59
59
|
add_step(Procedures::Packages::UnlockVersions.new)
|
60
60
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
61
61
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -64,7 +64,7 @@ module Scenarios::Capsule_7_0
|
|
64
64
|
|
65
65
|
class PostMigrations < Abstract
|
66
66
|
upgrade_metadata do
|
67
|
-
description 'Procedures after migrating to Capsule
|
67
|
+
description 'Procedures after migrating to Capsule 6.11'
|
68
68
|
tags :post_migrations
|
69
69
|
end
|
70
70
|
|
@@ -77,7 +77,7 @@ module Scenarios::Capsule_7_0
|
|
77
77
|
|
78
78
|
class PostUpgradeChecks < Abstract
|
79
79
|
upgrade_metadata do
|
80
|
-
description 'Checks after upgrading to Capsule
|
80
|
+
description 'Checks after upgrading to Capsule 6.11'
|
81
81
|
tags :post_upgrade_checks
|
82
82
|
run_strategy :fail_slow
|
83
83
|
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
module Scenarios::
|
1
|
+
module Scenarios::Capsule_6_11_z
|
2
2
|
class Abstract < ForemanMaintain::Scenario
|
3
3
|
def self.upgrade_metadata(&block)
|
4
4
|
metadata do
|
5
5
|
tags :upgrade_scenario
|
6
6
|
confine do
|
7
7
|
feature(:capsule) &&
|
8
|
-
(feature(:capsule).current_minor_version == '
|
9
|
-
ForemanMaintain.upgrade_in_progress == '
|
8
|
+
(feature(:capsule).current_minor_version == '6.11' || \
|
9
|
+
ForemanMaintain.upgrade_in_progress == '6.11.z')
|
10
10
|
end
|
11
11
|
instance_eval(&block)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def target_version
|
16
|
-
'
|
16
|
+
'6.11.z'
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
class PreUpgradeCheck < Abstract
|
21
21
|
upgrade_metadata do
|
22
|
-
description 'Checks before upgrading to Capsule
|
22
|
+
description 'Checks before upgrading to Capsule 6.11.z'
|
23
23
|
tags :pre_upgrade_checks
|
24
24
|
run_strategy :fail_slow
|
25
25
|
end
|
@@ -27,13 +27,13 @@ module Scenarios::Capsule_7_0_z
|
|
27
27
|
def compose
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Repositories::Validate.new(:version => '
|
30
|
+
add_step(Checks::Repositories::Validate.new(:version => '6.11'))
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
class PreMigrations < Abstract
|
35
35
|
upgrade_metadata do
|
36
|
-
description 'Procedures before migrating to Capsule
|
36
|
+
description 'Procedures before migrating to Capsule 6.11.z'
|
37
37
|
tags :pre_migrations
|
38
38
|
end
|
39
39
|
|
@@ -45,7 +45,7 @@ module Scenarios::Capsule_7_0_z
|
|
45
45
|
|
46
46
|
class Migrations < Abstract
|
47
47
|
upgrade_metadata do
|
48
|
-
description 'Migration scripts to Capsule
|
48
|
+
description 'Migration scripts to Capsule 6.11.z'
|
49
49
|
tags :migrations
|
50
50
|
end
|
51
51
|
|
@@ -54,7 +54,7 @@ module Scenarios::Capsule_7_0_z
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def compose
|
57
|
-
add_step(Procedures::Repositories::Setup.new(:version => '
|
57
|
+
add_step(Procedures::Repositories::Setup.new(:version => '6.11'))
|
58
58
|
add_step(Procedures::Packages::UnlockVersions.new)
|
59
59
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
60
60
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -63,7 +63,7 @@ module Scenarios::Capsule_7_0_z
|
|
63
63
|
|
64
64
|
class PostMigrations < Abstract
|
65
65
|
upgrade_metadata do
|
66
|
-
description 'Procedures after migrating to Capsule
|
66
|
+
description 'Procedures after migrating to Capsule 6.11.z'
|
67
67
|
tags :post_migrations
|
68
68
|
end
|
69
69
|
|
@@ -76,7 +76,7 @@ module Scenarios::Capsule_7_0_z
|
|
76
76
|
|
77
77
|
class PostUpgradeChecks < Abstract
|
78
78
|
upgrade_metadata do
|
79
|
-
description 'Checks after upgrading to Capsule
|
79
|
+
description 'Checks after upgrading to Capsule 6.11.z'
|
80
80
|
tags :post_upgrade_checks
|
81
81
|
run_strategy :fail_slow
|
82
82
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Scenarios::
|
1
|
+
module Scenarios::Satellite_6_11
|
2
2
|
class Abstract < ForemanMaintain::Scenario
|
3
3
|
def self.upgrade_metadata(&block)
|
4
4
|
metadata do
|
@@ -6,20 +6,20 @@ module Scenarios::Satellite_7_0
|
|
6
6
|
confine do
|
7
7
|
feature(:satellite) &&
|
8
8
|
(feature(:satellite).current_minor_version == '6.10' || \
|
9
|
-
ForemanMaintain.upgrade_in_progress == '
|
9
|
+
ForemanMaintain.upgrade_in_progress == '6.11')
|
10
10
|
end
|
11
11
|
instance_eval(&block)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def target_version
|
16
|
-
'
|
16
|
+
'6.11'
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
class PreUpgradeCheck < Abstract
|
21
21
|
upgrade_metadata do
|
22
|
-
description 'Checks before upgrading to Satellite
|
22
|
+
description 'Checks before upgrading to Satellite 6.11'
|
23
23
|
tags :pre_upgrade_checks
|
24
24
|
run_strategy :fail_slow
|
25
25
|
end
|
@@ -29,13 +29,13 @@ module Scenarios::Satellite_7_0
|
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
30
|
|
31
31
|
add_step(Checks::Foreman::CheckpointSegments)
|
32
|
-
add_step(Checks::Repositories::Validate.new(:version => '
|
32
|
+
add_step(Checks::Repositories::Validate.new(:version => '6.11'))
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
class PreMigrations < Abstract
|
37
37
|
upgrade_metadata do
|
38
|
-
description 'Procedures before migrating to Satellite
|
38
|
+
description 'Procedures before migrating to Satellite 6.11'
|
39
39
|
tags :pre_migrations
|
40
40
|
end
|
41
41
|
|
@@ -48,7 +48,7 @@ module Scenarios::Satellite_7_0
|
|
48
48
|
|
49
49
|
class Migrations < Abstract
|
50
50
|
upgrade_metadata do
|
51
|
-
description 'Migration scripts to Satellite
|
51
|
+
description 'Migration scripts to Satellite 6.11'
|
52
52
|
tags :migrations
|
53
53
|
run_strategy :fail_fast
|
54
54
|
end
|
@@ -58,7 +58,7 @@ module Scenarios::Satellite_7_0
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def compose
|
61
|
-
add_step(Procedures::Repositories::Setup.new(:version => '
|
61
|
+
add_step(Procedures::Repositories::Setup.new(:version => '6.11'))
|
62
62
|
add_step(Procedures::Packages::UnlockVersions.new)
|
63
63
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
64
64
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -68,7 +68,7 @@ module Scenarios::Satellite_7_0
|
|
68
68
|
|
69
69
|
class PostMigrations < Abstract
|
70
70
|
upgrade_metadata do
|
71
|
-
description 'Procedures after migrating to Satellite
|
71
|
+
description 'Procedures after migrating to Satellite 6.11'
|
72
72
|
tags :post_migrations
|
73
73
|
end
|
74
74
|
|
@@ -81,7 +81,7 @@ module Scenarios::Satellite_7_0
|
|
81
81
|
|
82
82
|
class PostUpgradeChecks < Abstract
|
83
83
|
upgrade_metadata do
|
84
|
-
description 'Checks after upgrading to Satellite
|
84
|
+
description 'Checks after upgrading to Satellite 6.11'
|
85
85
|
tags :post_upgrade_checks
|
86
86
|
run_strategy :fail_slow
|
87
87
|
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
module Scenarios::
|
1
|
+
module Scenarios::Satellite_6_11_z
|
2
2
|
class Abstract < ForemanMaintain::Scenario
|
3
3
|
def self.upgrade_metadata(&block)
|
4
4
|
metadata do
|
5
5
|
tags :upgrade_scenario
|
6
6
|
confine do
|
7
7
|
feature(:satellite) &&
|
8
|
-
(feature(:satellite).current_minor_version == '
|
9
|
-
ForemanMaintain.upgrade_in_progress == '
|
8
|
+
(feature(:satellite).current_minor_version == '6.11' || \
|
9
|
+
ForemanMaintain.upgrade_in_progress == '6.11.z')
|
10
10
|
end
|
11
11
|
instance_eval(&block)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def target_version
|
16
|
-
'
|
16
|
+
'6.11.z'
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
class PreUpgradeCheck < Abstract
|
21
21
|
upgrade_metadata do
|
22
|
-
description 'Checks before upgrading to Satellite
|
22
|
+
description 'Checks before upgrading to Satellite 6.11.z'
|
23
23
|
tags :pre_upgrade_checks
|
24
24
|
run_strategy :fail_slow
|
25
25
|
end
|
@@ -27,13 +27,13 @@ module Scenarios::Satellite_7_0_z
|
|
27
27
|
def compose
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Repositories::Validate.new(:version => '
|
30
|
+
add_step(Checks::Repositories::Validate.new(:version => '6.11'))
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
class PreMigrations < Abstract
|
35
35
|
upgrade_metadata do
|
36
|
-
description 'Procedures before migrating to Satellite
|
36
|
+
description 'Procedures before migrating to Satellite 6.11.z'
|
37
37
|
tags :pre_migrations
|
38
38
|
end
|
39
39
|
|
@@ -45,7 +45,7 @@ module Scenarios::Satellite_7_0_z
|
|
45
45
|
|
46
46
|
class Migrations < Abstract
|
47
47
|
upgrade_metadata do
|
48
|
-
description 'Migration scripts to Satellite
|
48
|
+
description 'Migration scripts to Satellite 6.11.z'
|
49
49
|
tags :migrations
|
50
50
|
end
|
51
51
|
|
@@ -54,7 +54,7 @@ module Scenarios::Satellite_7_0_z
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def compose
|
57
|
-
add_step(Procedures::Repositories::Setup.new(:version => '
|
57
|
+
add_step(Procedures::Repositories::Setup.new(:version => '6.11'))
|
58
58
|
add_step(Procedures::Packages::UnlockVersions.new)
|
59
59
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
60
60
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -64,7 +64,7 @@ module Scenarios::Satellite_7_0_z
|
|
64
64
|
|
65
65
|
class PostMigrations < Abstract
|
66
66
|
upgrade_metadata do
|
67
|
-
description 'Procedures after migrating to Satellite
|
67
|
+
description 'Procedures after migrating to Satellite 6.11.z'
|
68
68
|
tags :post_migrations
|
69
69
|
end
|
70
70
|
|
@@ -77,7 +77,7 @@ module Scenarios::Satellite_7_0_z
|
|
77
77
|
|
78
78
|
class PostUpgradeChecks < Abstract
|
79
79
|
upgrade_metadata do
|
80
|
-
description 'Checks after upgrading to Satellite
|
80
|
+
description 'Checks after upgrading to Satellite 6.11.z'
|
81
81
|
tags :post_upgrade_checks
|
82
82
|
run_strategy :fail_slow
|
83
83
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import dnf
|
2
|
+
import dnf.exceptions
|
3
|
+
from dnfpluginscore import _, logger
|
4
|
+
|
5
|
+
import configparser
|
6
|
+
|
7
|
+
class ForemanProtector(dnf.Plugin):
|
8
|
+
name = 'foreman-protector'
|
9
|
+
config_name = 'foreman-protector'
|
10
|
+
|
11
|
+
def __init__(self,base,cli):
|
12
|
+
self.base = base
|
13
|
+
self.cli = cli
|
14
|
+
|
15
|
+
def _get_whitelist_file_url(self):
|
16
|
+
try:
|
17
|
+
parser = self.read_config(self.base.conf)
|
18
|
+
except Exception as e:
|
19
|
+
raise dnf.exceptions.Error(_("Parsing file failed: {}").format(str(e)))
|
20
|
+
|
21
|
+
if parser.has_section('main'):
|
22
|
+
fileurl = parser.get('main', 'whitelist')
|
23
|
+
else:
|
24
|
+
raise dnf.exceptions.Error(_('Incorrect plugin configuration!'))
|
25
|
+
return fileurl
|
26
|
+
|
27
|
+
def _load_whitelist(self):
|
28
|
+
fileurl = self._get_whitelist_file_url()
|
29
|
+
package_whitelist = set()
|
30
|
+
try:
|
31
|
+
if fileurl:
|
32
|
+
llfile = open(fileurl, 'r')
|
33
|
+
for line in llfile.readlines():
|
34
|
+
if line.startswith('#') or line.strip() == '':
|
35
|
+
continue
|
36
|
+
|
37
|
+
package_whitelist.add(line.rstrip())
|
38
|
+
llfile.close()
|
39
|
+
except IOError as e:
|
40
|
+
raise dnf.exceptions.Error('Unable to read Foreman protector"s configuration: %s' % e)
|
41
|
+
return package_whitelist
|
42
|
+
|
43
|
+
def _add_obsoletes(self):
|
44
|
+
package_whitelist = self._load_whitelist()
|
45
|
+
final_query = self.base.sack.query()
|
46
|
+
if package_whitelist:
|
47
|
+
# If anything obsoletes something that we have whitelisted ... then
|
48
|
+
# whitelist that too.
|
49
|
+
whitelist_query = self.base.sack.query().filterm(name=package_whitelist)
|
50
|
+
obsoletes_query = self.base.sack.query().filterm(obsoletes=list(whitelist_query))
|
51
|
+
|
52
|
+
final_query = whitelist_query.union(obsoletes_query)
|
53
|
+
return final_query
|
54
|
+
|
55
|
+
def sack(self):
|
56
|
+
whitelist_and_obsoletes = self._add_obsoletes()
|
57
|
+
all_available_packages = self.base.sack.query().available()
|
58
|
+
excluded_pkgs_query = all_available_packages.difference(whitelist_and_obsoletes)
|
59
|
+
total = len(excluded_pkgs_query)
|
60
|
+
logger.info(_('Reading Foreman protector configuration'))
|
61
|
+
self.base.sack.add_excludes(excluded_pkgs_query)
|
62
|
+
|
63
|
+
logger.info(_('*** Excluded total: %s' % total))
|
64
|
+
if total:
|
65
|
+
if total > 1:
|
66
|
+
suffix = 's'
|
67
|
+
else:
|
68
|
+
suffix = ''
|
69
|
+
logger.info(_('\n'
|
70
|
+
'WARNING: Excluding %d package%s due to foreman-protector. \n'
|
71
|
+
'Use foreman-maintain packages install/update <package> \n'
|
72
|
+
'to safely install packages without restrictions.\n'
|
73
|
+
'Use foreman-maintain upgrade run for full upgrade.\n'
|
74
|
+
% (total, suffix)))
|
75
|
+
else:
|
76
|
+
logger.info(_('\n'
|
77
|
+
'Nothing excluded by foreman-protector!\n'))
|
File without changes
|
@@ -1,38 +1,23 @@
|
|
1
1
|
module ForemanMaintain
|
2
2
|
module Cli
|
3
3
|
class SelfUpgradeCommand < Base
|
4
|
-
option ['--
|
5
|
-
'
|
6
|
-
|
4
|
+
option ['--maintenance-repo-label'], 'REPOSITORY_LABEL',\
|
5
|
+
'Repository label from which packages should be updated.'\
|
6
|
+
'This can be used when standard CDN repositories are unavailable.'
|
7
7
|
def execute
|
8
|
-
allow_major_version_upgrade_only
|
9
8
|
run_scenario(upgrade_scenario, upgrade_rescue_scenario)
|
10
9
|
end
|
11
10
|
|
12
11
|
def upgrade_scenario
|
13
|
-
Scenarios::SelfUpgrade.new(
|
12
|
+
Scenarios::SelfUpgrade.new(
|
13
|
+
maintenance_repo_label: maintenance_repo_label
|
14
|
+
)
|
14
15
|
end
|
15
16
|
|
16
17
|
def upgrade_rescue_scenario
|
17
|
-
Scenarios::SelfUpgradeRescue.new(
|
18
|
-
|
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
|
-
"\nand self-upgrade should be used for major version upgrades only!"
|
34
|
-
raise Error::UsageError, message
|
35
|
-
end
|
18
|
+
Scenarios::SelfUpgradeRescue.new(
|
19
|
+
maintenance_repo_label: maintenance_repo_label
|
20
|
+
)
|
36
21
|
end
|
37
22
|
end
|
38
23
|
end
|
@@ -116,7 +116,7 @@ module ForemanMaintain
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def common_repos(full_version)
|
119
|
-
sat_maint_version = if version(full_version) >= version('
|
119
|
+
sat_maint_version = if version(full_version) >= version('6.11') && !use_beta_repos?
|
120
120
|
full_version
|
121
121
|
else
|
122
122
|
full_version[0]
|
@@ -1,13 +1,8 @@
|
|
1
1
|
module ForemanMaintain::PackageManager
|
2
2
|
# rubocop:disable Lint/UnusedMethodArgument
|
3
3
|
class Base
|
4
|
-
#
|
5
|
-
def
|
6
|
-
raise NotImplementedError
|
7
|
-
end
|
8
|
-
|
9
|
-
# make sure the version locking tools are configured
|
10
|
-
def install_version_locking(assumeyes: false)
|
4
|
+
# confirms that Package Manager supports the locking mechanism
|
5
|
+
def version_locking_supported?
|
11
6
|
raise NotImplementedError
|
12
7
|
end
|
13
8
|
|
@@ -2,7 +2,6 @@ module ForemanMaintain::PackageManager
|
|
2
2
|
class Yum < Base
|
3
3
|
PROTECTOR_CONFIG_FILE = '/etc/yum/pluginconf.d/foreman-protector.conf'.freeze
|
4
4
|
PROTECTOR_WHITELIST_FILE = '/etc/yum/pluginconf.d/foreman-protector.whitelist'.freeze
|
5
|
-
PROTECTOR_PLUGIN_FILE = '/usr/lib/yum-plugins/foreman-protector.py'.freeze
|
6
5
|
|
7
6
|
def self.parse_envra(envra)
|
8
7
|
# envra format: 0:foreman-1.20.1.10-1.el7sat.noarch
|
@@ -19,18 +18,17 @@ module ForemanMaintain::PackageManager
|
|
19
18
|
end
|
20
19
|
|
21
20
|
def versions_locked?
|
22
|
-
!!(protector_config =~ /^\s*enabled\s*=\s*1/)
|
21
|
+
!!(protector_config =~ /^\s*enabled\s*=\s*1/) &&
|
22
|
+
protector_whitelist_file_nonzero?
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
File.exist?(
|
27
|
-
File.
|
25
|
+
def protector_whitelist_file_nonzero?
|
26
|
+
File.exist?(PROTECTOR_WHITELIST_FILE) &&
|
27
|
+
!File.zero?(PROTECTOR_WHITELIST_FILE)
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
|
32
|
-
install_extras('foreman_protector/foreman-protector.conf', PROTECTOR_CONFIG_FILE)
|
33
|
-
install_extras('foreman_protector/foreman-protector.whitelist', PROTECTOR_WHITELIST_FILE)
|
30
|
+
def version_locking_supported?
|
31
|
+
true
|
34
32
|
end
|
35
33
|
|
36
34
|
def installed?(packages)
|
@@ -49,6 +47,10 @@ module ForemanMaintain::PackageManager
|
|
49
47
|
yum_action('install', packages, :assumeyes => assumeyes)
|
50
48
|
end
|
51
49
|
|
50
|
+
def reinstall(packages, assumeyes: false)
|
51
|
+
yum_action('reinstall', packages, :assumeyes => assumeyes)
|
52
|
+
end
|
53
|
+
|
52
54
|
def remove(packages, assumeyes: false)
|
53
55
|
yum_action('remove', packages, :assumeyes => assumeyes)
|
54
56
|
end
|
@@ -129,14 +131,5 @@ module ForemanMaintain::PackageManager
|
|
129
131
|
:interactive => !assumeyes, :valid_exit_statuses => valid_exit_statuses)
|
130
132
|
end
|
131
133
|
end
|
132
|
-
|
133
|
-
def install_extras(src, dest, override: false)
|
134
|
-
extras_src = File.expand_path('../../../../extras', __FILE__)
|
135
|
-
if override ||
|
136
|
-
(File.directory?(dest) && !File.exist?(File.join(dest, src))) ||
|
137
|
-
!File.exist?(dest)
|
138
|
-
FileUtils.cp(File.join(extras_src, src), dest)
|
139
|
-
end
|
140
|
-
end
|
141
134
|
end
|
142
135
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -184,7 +184,6 @@ files:
|
|
184
184
|
- definitions/checks/server_ping.rb
|
185
185
|
- definitions/checks/services_up.rb
|
186
186
|
- definitions/checks/system_registration.rb
|
187
|
-
- definitions/checks/version_locking_enabled.rb
|
188
187
|
- definitions/features/apache.rb
|
189
188
|
- definitions/features/candlepin.rb
|
190
189
|
- definitions/features/candlepin_database.rb
|
@@ -334,14 +333,16 @@ files:
|
|
334
333
|
- definitions/scenarios/services.rb
|
335
334
|
- definitions/scenarios/upgrade_to_capsule_6_10.rb
|
336
335
|
- definitions/scenarios/upgrade_to_capsule_6_10_z.rb
|
336
|
+
- definitions/scenarios/upgrade_to_capsule_6_11.rb
|
337
|
+
- definitions/scenarios/upgrade_to_capsule_6_11_z.rb
|
337
338
|
- definitions/scenarios/upgrade_to_capsule_6_8.rb
|
338
339
|
- definitions/scenarios/upgrade_to_capsule_6_8_z.rb
|
339
340
|
- definitions/scenarios/upgrade_to_capsule_6_9.rb
|
340
341
|
- definitions/scenarios/upgrade_to_capsule_6_9_z.rb
|
341
|
-
- definitions/scenarios/upgrade_to_capsule_7_0.rb
|
342
|
-
- definitions/scenarios/upgrade_to_capsule_7_0_z.rb
|
343
342
|
- definitions/scenarios/upgrade_to_satellite_6_10.rb
|
344
343
|
- definitions/scenarios/upgrade_to_satellite_6_10_z.rb
|
344
|
+
- definitions/scenarios/upgrade_to_satellite_6_11.rb
|
345
|
+
- definitions/scenarios/upgrade_to_satellite_6_11_z.rb
|
345
346
|
- definitions/scenarios/upgrade_to_satellite_6_2.rb
|
346
347
|
- definitions/scenarios/upgrade_to_satellite_6_2_z.rb
|
347
348
|
- definitions/scenarios/upgrade_to_satellite_6_3.rb
|
@@ -358,12 +359,11 @@ files:
|
|
358
359
|
- definitions/scenarios/upgrade_to_satellite_6_8_z.rb
|
359
360
|
- definitions/scenarios/upgrade_to_satellite_6_9.rb
|
360
361
|
- definitions/scenarios/upgrade_to_satellite_6_9_z.rb
|
361
|
-
- definitions/scenarios/upgrade_to_satellite_7_0.rb
|
362
|
-
- definitions/scenarios/upgrade_to_satellite_7_0_z.rb
|
363
362
|
- extras/foreman-maintain.sh
|
363
|
+
- extras/foreman_protector/dnf/foreman-protector.py
|
364
364
|
- extras/foreman_protector/foreman-protector.conf
|
365
|
-
- extras/foreman_protector/foreman-protector.py
|
366
365
|
- extras/foreman_protector/foreman-protector.whitelist
|
366
|
+
- extras/foreman_protector/yum/foreman-protector.py
|
367
367
|
- extras/passenger-recycler.cron
|
368
368
|
- lib/foreman_maintain.rb
|
369
369
|
- lib/foreman_maintain/check.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Checks
|
2
|
-
class VersionLockingEnabled < ForemanMaintain::Check
|
3
|
-
metadata do
|
4
|
-
description 'Check if tooling for package locking is installed'
|
5
|
-
end
|
6
|
-
|
7
|
-
def run
|
8
|
-
enabled = package_manager.version_locking_enabled?
|
9
|
-
enable_locking = Procedures::Packages::EnableVersionLocking.new(:assumeyes => assumeyes?)
|
10
|
-
assert(enabled, 'Tools for package version locking are not available on this system',
|
11
|
-
:next_steps => enable_locking)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|