foreman_maintain 1.0.8 → 1.1.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/package_manager/yum/validate_yum_config.rb +1 -3
- data/definitions/features/capsule.rb +1 -1
- data/definitions/features/installer.rb +7 -1
- data/definitions/features/katello.rb +1 -1
- data/definitions/features/satellite.rb +1 -1
- data/definitions/procedures/pulp/remove.rb +49 -13
- data/definitions/procedures/restore/candlepin_reset_migrations.rb +14 -0
- data/definitions/scenarios/restore.rb +2 -1
- data/lib/foreman_maintain/concerns/system_helpers.rb +2 -8
- data/lib/foreman_maintain/package_manager/yum.rb +11 -7
- data/lib/foreman_maintain/utils/service/systemd.rb +8 -13
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +3 -3
- data/definitions/procedures/packages/enable_version_locking.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38a7ae9f24c88731e052acb62c13b25d29074a07ad852daa258bed6322c1d22d
|
4
|
+
data.tar.gz: e0420aa7dc1935c61ef479aed3a43069281797ca41f131048902c727676c6634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0b38e2d2819e152a508874b060b22f161aa4b56523d9b6869b714f9186920fa7d61fd10b09840158c94e4b55a7c18a718307e9a02f4320426f54baa9bdfdd9f
|
7
|
+
data.tar.gz: d53fb1934cdc2cbbc2cad92e43a4132ff0f8ea8eec1435bd930be575d3e2284a48278809b7576bdf24b8d7df36ac39fe2dcb223813dc9f8c3b57632e08e030e5
|
@@ -41,9 +41,7 @@ module Checks::PackageManager
|
|
41
41
|
|
42
42
|
def yum_config_options
|
43
43
|
@yum_config_options ||= {
|
44
|
-
'exclude' => '^exclude\s*=\s*\S+.*$'
|
45
|
-
'clean_requirements_on_remove' =>
|
46
|
-
'^clean_requirements_on_remove\s*=\S*(1|yes|true)$'
|
44
|
+
'exclude' => '^exclude\s*=\s*\S+.*$'
|
47
45
|
}
|
48
46
|
end
|
49
47
|
end
|
@@ -100,7 +100,13 @@ class Features::Installer < ForemanMaintain::Feature
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def installer_arguments
|
103
|
-
installer_args = '
|
103
|
+
installer_args = ''
|
104
|
+
|
105
|
+
if feature(:foreman_proxy) &&
|
106
|
+
feature(:foreman_proxy).with_content?
|
107
|
+
installer_args += ' --disable-system-checks'
|
108
|
+
end
|
109
|
+
|
104
110
|
unless check_min_version('foreman', '2.1') || check_min_version('foreman-proxy', '2.1')
|
105
111
|
installer_args += ' --upgrade' if can_upgrade?
|
106
112
|
end
|
@@ -10,7 +10,7 @@ class Features::Satellite < ForemanMaintain::Feature
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def current_version
|
13
|
-
@current_version ||=
|
13
|
+
@current_version ||= package_version(package_name) || version_from_source
|
14
14
|
end
|
15
15
|
|
16
16
|
def package_name
|
@@ -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
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Procedures::Restore
|
2
|
+
class CandlepinResetMigrations < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Ensure Candlepin runs all migrations after restoring the database'
|
5
|
+
confine do
|
6
|
+
feature(:candlepin_database)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
FileUtils.rm_f('/var/lib/candlepin/.puppet-candlepin-rpm-version')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -46,7 +46,8 @@ module ForemanMaintain::Scenarios
|
|
46
46
|
end
|
47
47
|
restore_mongo_dump(backup)
|
48
48
|
add_steps_with_context(Procedures::Pulp::Migrate,
|
49
|
-
Procedures::Pulpcore::Migrate
|
49
|
+
Procedures::Pulpcore::Migrate,
|
50
|
+
Procedures::Restore::CandlepinResetMigrations)
|
50
51
|
|
51
52
|
add_steps_with_context(Procedures::Restore::RegenerateQueues) if backup.online_backup?
|
52
53
|
add_steps_with_context(Procedures::Service::Start,
|
@@ -115,7 +115,8 @@ module ForemanMaintain
|
|
115
115
|
|
116
116
|
def package_version(name)
|
117
117
|
# space for extension to support non-rpm distributions
|
118
|
-
|
118
|
+
pkg = package_manager.find_installed_package(name, '%{VERSION}')
|
119
|
+
version(pkg) unless pkg.nil?
|
119
120
|
end
|
120
121
|
|
121
122
|
def parse_csv(data)
|
@@ -132,13 +133,6 @@ module ForemanMaintain
|
|
132
133
|
nil
|
133
134
|
end
|
134
135
|
|
135
|
-
def rpm_version(name)
|
136
|
-
rpm_version = execute(%(rpm -q '#{name}' --queryformat="%{VERSION}"))
|
137
|
-
if $CHILD_STATUS.success?
|
138
|
-
version(rpm_version)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
136
|
def shellescape(string)
|
143
137
|
Shellwords.escape(string)
|
144
138
|
end
|
@@ -36,8 +36,12 @@ module ForemanMaintain::PackageManager
|
|
36
36
|
sys.execute?(%(rpm -q #{packages_list}))
|
37
37
|
end
|
38
38
|
|
39
|
-
def find_installed_package(name)
|
40
|
-
|
39
|
+
def find_installed_package(name, queryformat = '')
|
40
|
+
rpm_cmd = "rpm -q '#{name}'"
|
41
|
+
unless queryformat.empty?
|
42
|
+
rpm_cmd += " --qf '#{queryformat}'"
|
43
|
+
end
|
44
|
+
status, result = sys.execute_with_status(rpm_cmd)
|
41
45
|
if status == 0
|
42
46
|
result
|
43
47
|
end
|
@@ -78,12 +82,12 @@ module ForemanMaintain::PackageManager
|
|
78
82
|
sys.execute(find_cmd).split("\n")
|
79
83
|
end
|
80
84
|
|
81
|
-
def list_installed_packages(
|
82
|
-
# The
|
85
|
+
def list_installed_packages(queryformat = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
|
86
|
+
# The queryformat should only include valid tag(s) as per `rpm --querytags` list.
|
83
87
|
# If any special formatting is required with querytag then it should be provided with tag i.e,
|
84
|
-
#
|
85
|
-
# The
|
86
|
-
sys.execute!("rpm -qa --qf '#{
|
88
|
+
# "--%{VENDOR}"
|
89
|
+
# The queryformat string must end with '\n'
|
90
|
+
sys.execute!("rpm -qa --qf '#{queryformat}'").split("\n")
|
87
91
|
end
|
88
92
|
|
89
93
|
private
|
@@ -8,21 +8,16 @@ module ForemanMaintain::Utils
|
|
8
8
|
@instance_parent_unit = options.fetch(:instance_parent_unit, nil)
|
9
9
|
end
|
10
10
|
|
11
|
-
def command(action
|
12
|
-
do_wait = options.fetch(:wait, true) # wait for service to start
|
11
|
+
def command(action)
|
13
12
|
all = @options.fetch(:all, false)
|
14
13
|
skip_enablement = @options.fetch(:skip_enablement, false)
|
15
14
|
if skip_enablement && %w[enable disable].include?(action)
|
16
15
|
return skip_enablement_message(action, @name)
|
17
16
|
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
cmd = "systemctl #{action} #{@name}"
|
23
|
-
cmd += ' --all' if all
|
24
|
-
cmd
|
25
|
-
end
|
18
|
+
cmd = "systemctl #{action} #{@name}"
|
19
|
+
cmd += ' --all' if all
|
20
|
+
cmd
|
26
21
|
end
|
27
22
|
|
28
23
|
def status
|
@@ -38,11 +33,11 @@ module ForemanMaintain::Utils
|
|
38
33
|
end
|
39
34
|
|
40
35
|
def enable
|
41
|
-
execute('enable'
|
36
|
+
execute('enable')
|
42
37
|
end
|
43
38
|
|
44
39
|
def disable
|
45
|
-
execute('disable'
|
40
|
+
execute('disable')
|
46
41
|
end
|
47
42
|
|
48
43
|
def running?
|
@@ -66,8 +61,8 @@ module ForemanMaintain::Utils
|
|
66
61
|
|
67
62
|
private
|
68
63
|
|
69
|
-
def execute(action
|
70
|
-
@sys.execute_with_status(command(action
|
64
|
+
def execute(action)
|
65
|
+
@sys.execute_with_status(command(action))
|
71
66
|
end
|
72
67
|
|
73
68
|
def service_enabled_status
|
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.
|
4
|
+
version: 1.1.1
|
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-04-
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -273,7 +273,6 @@ files:
|
|
273
273
|
- definitions/procedures/maintenance_mode/enable_maintenance_mode.rb
|
274
274
|
- definitions/procedures/maintenance_mode/is_enabled.rb
|
275
275
|
- definitions/procedures/packages/check_update.rb
|
276
|
-
- definitions/procedures/packages/enable_version_locking.rb
|
277
276
|
- definitions/procedures/packages/install.rb
|
278
277
|
- definitions/procedures/packages/installer_confirmation.rb
|
279
278
|
- definitions/procedures/packages/lock_versions.rb
|
@@ -298,6 +297,7 @@ files:
|
|
298
297
|
- definitions/procedures/repositories/enable.rb
|
299
298
|
- definitions/procedures/repositories/setup.rb
|
300
299
|
- definitions/procedures/restore/candlepin_dump.rb
|
300
|
+
- definitions/procedures/restore/candlepin_reset_migrations.rb
|
301
301
|
- definitions/procedures/restore/configs.rb
|
302
302
|
- definitions/procedures/restore/confirmation.rb
|
303
303
|
- definitions/procedures/restore/drop_databases.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Procedures::Packages
|
2
|
-
class EnableVersionLocking < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Install and configure tools for version locking'
|
5
|
-
param :assumeyes, 'Do not ask for confirmation'
|
6
|
-
end
|
7
|
-
|
8
|
-
def run
|
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)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|