foreman_maintain 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/definitions/procedures/packages/update.rb +3 -1
- data/definitions/scenarios/self_upgrade.rb +5 -66
- data/lib/foreman_maintain/cli/self_upgrade_command.rb +1 -7
- data/lib/foreman_maintain/concerns/system_helpers.rb +3 -2
- data/lib/foreman_maintain/package_manager/yum.rb +8 -4
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6b379bdb79107fc7f416af7bf700834ec7ae0591b734926398a09311d86879e
|
4
|
+
data.tar.gz: bf901e325a757e8e5c31787019dd9ba662bedef4a5692f20d78f4204f45bbcc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49831252dbbb12f0dc9f6e591d24aa9cb112e9dacfe50470c5ef9cb1a5c6a4f5e7070b95a0929f970dfcb7430ffad4cffce74f6cbd1c8f28231e26411cc42886
|
7
|
+
data.tar.gz: e0173b351c72f65b1d17cca48c31a7b3896781c8a2af6d07a23c25593318ed1f548f73a54e8ece99b8ced0ff6fb0828f6d850bde95a9de07950c03a433861987
|
@@ -6,12 +6,14 @@ module Procedures::Packages
|
|
6
6
|
param :force, 'Do not skip if package is installed', :flag => true, :default => false
|
7
7
|
param :warn_on_errors, 'Do not interrupt scenario on failure',
|
8
8
|
:flag => true, :default => false
|
9
|
+
param :yum_options, 'Extra yum options if any', :array => true, :default => []
|
9
10
|
end
|
10
11
|
|
11
12
|
def run
|
12
13
|
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
13
14
|
package_manager.clean_cache(:assumeyes => assumeyes_val)
|
14
|
-
|
15
|
+
opts = { :assumeyes => assumeyes_val, :yum_options => @yum_options }
|
16
|
+
packages_action(:update, @packages, opts)
|
15
17
|
rescue ForemanMaintain::Error::ExecutionError => e
|
16
18
|
if @warn_on_errors
|
17
19
|
set_status(:warning, e.message)
|
@@ -1,18 +1,6 @@
|
|
1
1
|
module ForemanMaintain::Scenarios
|
2
2
|
class SelfUpgradeBase < ForemanMaintain::Scenario
|
3
3
|
include ForemanMaintain::Concerns::Downstream
|
4
|
-
def enabled_system_repos_id
|
5
|
-
repository_manager.enabled_repos.keys
|
6
|
-
end
|
7
|
-
|
8
|
-
def enable_repos(repo_ids = stored_enabled_repos_ids)
|
9
|
-
add_step(Procedures::Repositories::Enable.new(repos: repo_ids))
|
10
|
-
end
|
11
|
-
|
12
|
-
def disable_repos(repo_ids = stored_enabled_repos_ids)
|
13
|
-
add_step(Procedures::Repositories::Disable.new(repos: repo_ids))
|
14
|
-
end
|
15
|
-
|
16
4
|
def target_version
|
17
5
|
current_full_version = feature(:instance).downstream.current_version
|
18
6
|
@target_version ||= current_full_version.bump
|
@@ -44,36 +32,6 @@ module ForemanMaintain::Scenarios
|
|
44
32
|
end
|
45
33
|
end
|
46
34
|
|
47
|
-
def maintenance_repo_version
|
48
|
-
return '6' if current_version == '6.10'
|
49
|
-
|
50
|
-
current_version
|
51
|
-
end
|
52
|
-
|
53
|
-
def stored_enabled_repos_ids
|
54
|
-
@stored_enabled_repos_ids ||= begin
|
55
|
-
path = File.expand_path('enabled_repos.yml', ForemanMaintain.config.backup_dir)
|
56
|
-
@stored_enabled_repos_ids = File.file?(path) ? YAML.load(File.read(path)) : []
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def all_maintenance_repos
|
61
|
-
repo_regex = if el7?
|
62
|
-
/rhel-\d-server-satellite-maintenance-\d.\d-rpms/
|
63
|
-
else
|
64
|
-
/satellite-maintenance-\d.\d-for-rhel-\d-x86_64-rpms/
|
65
|
-
end
|
66
|
-
stored_enabled_repos_ids.select { |id| !id.match(repo_regex).nil? }
|
67
|
-
end
|
68
|
-
|
69
|
-
def repos_ids_to_reenable
|
70
|
-
repos_ids_to_reenable = stored_enabled_repos_ids - all_maintenance_repos
|
71
|
-
if use_rhsm?
|
72
|
-
repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
|
73
|
-
end
|
74
|
-
repos_ids_to_reenable
|
75
|
-
end
|
76
|
-
|
77
35
|
def use_rhsm?
|
78
36
|
return false if maintenance_repo_label
|
79
37
|
|
@@ -100,30 +58,11 @@ module ForemanMaintain::Scenarios
|
|
100
58
|
def compose
|
101
59
|
if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
|
102
60
|
pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
disable_repos('*')
|
109
|
-
enable_repos(repos_ids_to_reenable)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
class SelfUpgradeRescue < SelfUpgradeBase
|
115
|
-
metadata do
|
116
|
-
label :rescue_self_upgrade
|
117
|
-
description 'Disables all version specific maintenance repositories and,'\
|
118
|
-
"\nenables the repositories which were configured prior to self upgrade"
|
119
|
-
manual_detection
|
120
|
-
run_strategy :fail_slow
|
121
|
-
end
|
122
|
-
|
123
|
-
def compose
|
124
|
-
if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
|
125
|
-
disable_repos('*')
|
126
|
-
enable_repos(repos_ids_to_reenable)
|
61
|
+
yum_options = req_repos_to_update_pkgs.map do |id|
|
62
|
+
"--enablerepo=#{id}"
|
63
|
+
end
|
64
|
+
add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
|
65
|
+
yum_options: yum_options))
|
127
66
|
end
|
128
67
|
end
|
129
68
|
end
|
@@ -5,7 +5,7 @@ module ForemanMaintain
|
|
5
5
|
'Repository label from which packages should be updated.'\
|
6
6
|
'This can be used when standard CDN repositories are unavailable.'
|
7
7
|
def execute
|
8
|
-
run_scenario(upgrade_scenario
|
8
|
+
run_scenario(upgrade_scenario)
|
9
9
|
end
|
10
10
|
|
11
11
|
def upgrade_scenario
|
@@ -13,12 +13,6 @@ module ForemanMaintain
|
|
13
13
|
maintenance_repo_label: maintenance_repo_label
|
14
14
|
)
|
15
15
|
end
|
16
|
-
|
17
|
-
def upgrade_rescue_scenario
|
18
|
-
Scenarios::SelfUpgradeRescue.new(
|
19
|
-
maintenance_repo_label: maintenance_repo_label
|
20
|
-
)
|
21
|
-
end
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
@@ -100,12 +100,13 @@ module ForemanMaintain
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def packages_action(action, packages, options = {})
|
103
|
-
options.validate_options!(:assumeyes)
|
103
|
+
options.validate_options!(:assumeyes, :yum_options)
|
104
104
|
case action
|
105
105
|
when :install
|
106
106
|
package_manager.install(packages, :assumeyes => options[:assumeyes])
|
107
107
|
when :update
|
108
|
-
package_manager.update(packages, :assumeyes => options[:assumeyes]
|
108
|
+
package_manager.update(packages, :assumeyes => options[:assumeyes],
|
109
|
+
:yum_options => options[:yum_options])
|
109
110
|
when :remove
|
110
111
|
package_manager.remove(packages, :assumeyes => options[:assumeyes])
|
111
112
|
else
|
@@ -55,8 +55,8 @@ module ForemanMaintain::PackageManager
|
|
55
55
|
yum_action('remove', packages, :assumeyes => assumeyes)
|
56
56
|
end
|
57
57
|
|
58
|
-
def update(packages = [], assumeyes: false)
|
59
|
-
yum_action('update', packages, :assumeyes => assumeyes)
|
58
|
+
def update(packages = [], assumeyes: false, yum_options: [])
|
59
|
+
yum_action('update', packages, :assumeyes => assumeyes, :yum_options => yum_options)
|
60
60
|
end
|
61
61
|
|
62
62
|
def clean_cache(assumeyes: false)
|
@@ -116,8 +116,12 @@ module ForemanMaintain::PackageManager
|
|
116
116
|
File.open(protector_config_file, 'w') { |file| file.puts config }
|
117
117
|
end
|
118
118
|
|
119
|
-
|
120
|
-
|
119
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
120
|
+
def yum_action(action, packages, options)
|
121
|
+
with_status = options.fetch(:with_status, false)
|
122
|
+
assumeyes = options.fetch(:assumeyes, false)
|
123
|
+
valid_exit_statuses = options.fetch(:valid_exit_statuses, [0])
|
124
|
+
yum_options = options.fetch(:yum_options, [])
|
121
125
|
packages = [packages].flatten(1)
|
122
126
|
yum_options << '-y' if assumeyes
|
123
127
|
yum_options << '--disableplugin=foreman-protector'
|
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.13
|
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-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|