foreman_maintain 1.0.11 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/procedures/installer/run_for_6_11.rb +52 -0
- data/definitions/procedures/packages/update.rb +3 -1
- data/definitions/procedures/pulp/remove.rb +49 -13
- data/definitions/scenarios/puppet.rb +3 -1
- data/definitions/scenarios/self_upgrade.rb +5 -66
- data/definitions/scenarios/upgrade_to_satellite_6_11.rb +1 -1
- 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 +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea2abd618a76da17a92b3427065cae44274abc2b5e1e95c8abdf40c39aa39491
|
4
|
+
data.tar.gz: 6531dae72b1abb17c8a9584f15e5936a821e49c6ad2f25ac12b5d8448bfd42b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4db36662278f2f39bb49d2deb48594d56146d2ed14602b335c4bfb62535923373634ec4b0a126260f6e5b9dcbd7da1a886bf1fd07a4a53da8eaa564b12b1ab2d
|
7
|
+
data.tar.gz: ab5f81e9f64dcc017a4c4e69cc9ba3e627558d21b021af08b58028a06578c337ddef9889fff4fae2b06c5ed16d8892172687e52d5d2ff4ba9985a59e21563292
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Procedures::Installer
|
2
|
+
class RunFor6_11 < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Run installer with Candlepin SSL CA'\
|
5
|
+
' when using external database with SSL'
|
6
|
+
param :assumeyes, 'Do not ask for confirmation'
|
7
|
+
manual_detection
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
if extdb_and_ssl?
|
12
|
+
run_installer_with_extra_option
|
13
|
+
else
|
14
|
+
run_installer
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def ext_db?
|
19
|
+
!feature(:foreman_database).local?
|
20
|
+
end
|
21
|
+
|
22
|
+
def installer_answers
|
23
|
+
@installer_answers ||= feature(:installer).answers
|
24
|
+
end
|
25
|
+
|
26
|
+
def server_db_with_ssl?
|
27
|
+
installer_answers.fetch('katello')['candlepin_db_ssl']
|
28
|
+
end
|
29
|
+
|
30
|
+
def extdb_and_ssl?
|
31
|
+
ext_db? && server_db_with_ssl?
|
32
|
+
end
|
33
|
+
|
34
|
+
def run_installer_with_extra_option
|
35
|
+
ssl_ca_path = installer_answers.fetch('foreman')['db_root_cert']
|
36
|
+
spinner_msg = "Running installer with --katello-candlepin-db-ssl-ca #{ssl_ca_path} argument!"
|
37
|
+
with_spinner(spinner_msg) do
|
38
|
+
installer_args = feature(:installer).installer_arguments
|
39
|
+
new_ssl_arg = " --katello-candlepin-db-ssl-ca #{ssl_ca_path}"
|
40
|
+
installer_args << new_ssl_arg
|
41
|
+
feature(:installer).run(installer_args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def run_installer
|
46
|
+
with_spinner('Executing installer') do
|
47
|
+
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
48
|
+
feature(:installer).upgrade(:interactive => !assumeyes_val)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -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)
|
@@ -24,7 +24,15 @@ module Procedures::Pulp
|
|
24
24
|
'/var/lib/pulp/uploads',
|
25
25
|
'/var/lib/mongodb/',
|
26
26
|
'/var/cache/pulp'
|
27
|
-
]
|
27
|
+
].select { |dir| File.directory?(dir) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def pulp_data_dirs_mountpoints
|
31
|
+
pulp_data_dirs.select { |d| Pathname(d).mountpoint? }
|
32
|
+
end
|
33
|
+
|
34
|
+
def deletable_pulp_dirs
|
35
|
+
@deletable_pulp_dirs ||= pulp_data_dirs - pulp_data_dirs_mountpoints
|
28
36
|
end
|
29
37
|
|
30
38
|
# rubocop:disable Metrics/MethodLength
|
@@ -53,11 +61,12 @@ module Procedures::Pulp
|
|
53
61
|
@installed_pulp_packages
|
54
62
|
end
|
55
63
|
|
56
|
-
def data_dir_removal_cmds
|
57
|
-
|
64
|
+
def data_dir_removal_cmds(pulp_dirs)
|
65
|
+
pulp_dirs.map { |dir| "rm -rf #{dir}" }
|
58
66
|
end
|
59
67
|
|
60
|
-
def ask_to_proceed
|
68
|
+
def ask_to_proceed
|
69
|
+
rm_cmds = data_dir_removal_cmds(pulp_data_dirs)
|
61
70
|
question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
|
62
71
|
question += "\n# rpm -e #{pulp_packages.join(' ')}" if pulp_packages.any?
|
63
72
|
question += "\n# yum remove rh-mongodb34-*"
|
@@ -70,11 +79,9 @@ module Procedures::Pulp
|
|
70
79
|
end
|
71
80
|
|
72
81
|
def run
|
73
|
-
rm_cmds = data_dir_removal_cmds
|
74
|
-
|
75
82
|
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
76
83
|
|
77
|
-
ask_to_proceed
|
84
|
+
ask_to_proceed unless assumeyes_val
|
78
85
|
|
79
86
|
remove_pulp if pulp_packages.any?
|
80
87
|
|
@@ -86,7 +93,7 @@ module Procedures::Pulp
|
|
86
93
|
|
87
94
|
drop_migrations
|
88
95
|
|
89
|
-
delete_pulp_data
|
96
|
+
delete_pulp_data
|
90
97
|
|
91
98
|
restart_pulpcore_services
|
92
99
|
end
|
@@ -163,12 +170,41 @@ module Procedures::Pulp
|
|
163
170
|
end
|
164
171
|
# rubocop:enable Metrics/BlockLength
|
165
172
|
|
166
|
-
def delete_pulp_data
|
167
|
-
|
168
|
-
|
169
|
-
|
173
|
+
def delete_pulp_data
|
174
|
+
non_mountpoints = data_dir_removal_cmds(deletable_pulp_dirs)
|
175
|
+
mountpoints = pulp_data_dirs_mountpoints
|
176
|
+
with_spinner('') do |spinner|
|
177
|
+
if non_mountpoints.any?
|
178
|
+
spinner.update('Deleting pulp2 data directories.')
|
179
|
+
non_mountpoints.each do |cmd|
|
180
|
+
execute!(cmd)
|
181
|
+
end
|
182
|
+
msg_for_del_non_mountpoints(mountpoints, spinner)
|
183
|
+
end
|
184
|
+
if mountpoints.any?
|
185
|
+
msg_for_del_mountpoints(mountpoints, spinner)
|
170
186
|
end
|
171
|
-
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def msg_for_del_non_mountpoints(mountpoints, spinner)
|
191
|
+
if mountpoints.empty?
|
192
|
+
spinner.update('Done deleting all pulp2 data directories.')
|
193
|
+
else
|
194
|
+
spinner.update("Deleted: #{deletable_pulp_dirs.join("\n")}")
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def msg_for_del_mountpoints(mountpoints, spinner)
|
199
|
+
_, cmd_name = ForemanMaintain.pkg_and_cmd_name
|
200
|
+
if mountpoints.count > 1
|
201
|
+
spinner.update("The directories #{mountpoints.join(',')} are individual mountpoints.")
|
202
|
+
puts "\nThe #{cmd_name} won't delete these directories.\n"\
|
203
|
+
'You need to remove content and these directories on your own.'
|
204
|
+
else
|
205
|
+
spinner.update("The directory #{mountpoints.join(',')} is individual mountpoint.")
|
206
|
+
puts "\nThe #{cmd_name} won't delete the directory.\n"\
|
207
|
+
'You need to remove content and the directory on your own.'
|
172
208
|
end
|
173
209
|
end
|
174
210
|
|
@@ -15,7 +15,9 @@ module ForemanMaintain::Scenarios
|
|
15
15
|
add_step(Procedures::Puppet::RemovePuppet)
|
16
16
|
add_step(Procedures::Puppet::RemovePuppetData) if context.get(:remove_data)
|
17
17
|
add_step(Procedures::Service::Restart)
|
18
|
-
|
18
|
+
if server?
|
19
|
+
add_step(Procedures::Foreman::ApipieCache)
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -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
|
@@ -61,7 +61,7 @@ module Scenarios::Satellite_6_11
|
|
61
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
|
-
add_step_with_context(Procedures::Installer::
|
64
|
+
add_step_with_context(Procedures::Installer::RunFor6_11)
|
65
65
|
add_step(Procedures::Installer::UpgradeRakeTask)
|
66
66
|
end
|
67
67
|
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.14
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- definitions/procedures/foreman_tasks/ui_investigate.rb
|
267
267
|
- definitions/procedures/hammer_setup.rb
|
268
268
|
- definitions/procedures/installer/run.rb
|
269
|
+
- definitions/procedures/installer/run_for_6_11.rb
|
269
270
|
- definitions/procedures/installer/upgrade.rb
|
270
271
|
- definitions/procedures/installer/upgrade_rake_task.rb
|
271
272
|
- definitions/procedures/knowledge_base_article.rb
|