foreman_maintain 1.0.6 → 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/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/procedures/pulp/remove.rb +49 -13
- data/definitions/procedures/restore/candlepin_reset_migrations.rb +14 -0
- data/definitions/scenarios/restore.rb +2 -1
- data/definitions/scenarios/self_upgrade.rb +12 -3
- 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/system_helpers.rb +2 -8
- 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 +22 -25
- data/lib/foreman_maintain/utils/service/systemd.rb +8 -13
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +5 -5
- data/definitions/checks/version_locking_enabled.rb +0 -14
- data/definitions/procedures/packages/enable_version_locking.rb +0 -12
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
|
@@ -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
|
@@ -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,
|
@@ -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
|
|
@@ -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
|
@@ -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
|
@@ -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)
|
@@ -38,8 +36,12 @@ module ForemanMaintain::PackageManager
|
|
38
36
|
sys.execute?(%(rpm -q #{packages_list}))
|
39
37
|
end
|
40
38
|
|
41
|
-
def find_installed_package(name)
|
42
|
-
|
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)
|
43
45
|
if status == 0
|
44
46
|
result
|
45
47
|
end
|
@@ -49,6 +51,10 @@ module ForemanMaintain::PackageManager
|
|
49
51
|
yum_action('install', packages, :assumeyes => assumeyes)
|
50
52
|
end
|
51
53
|
|
54
|
+
def reinstall(packages, assumeyes: false)
|
55
|
+
yum_action('reinstall', packages, :assumeyes => assumeyes)
|
56
|
+
end
|
57
|
+
|
52
58
|
def remove(packages, assumeyes: false)
|
53
59
|
yum_action('remove', packages, :assumeyes => assumeyes)
|
54
60
|
end
|
@@ -76,12 +82,12 @@ module ForemanMaintain::PackageManager
|
|
76
82
|
sys.execute(find_cmd).split("\n")
|
77
83
|
end
|
78
84
|
|
79
|
-
def list_installed_packages(
|
80
|
-
# 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.
|
81
87
|
# If any special formatting is required with querytag then it should be provided with tag i.e,
|
82
|
-
#
|
83
|
-
# The
|
84
|
-
sys.execute!("rpm -qa --qf '#{
|
88
|
+
# "--%{VENDOR}"
|
89
|
+
# The queryformat string must end with '\n'
|
90
|
+
sys.execute!("rpm -qa --qf '#{queryformat}'").split("\n")
|
85
91
|
end
|
86
92
|
|
87
93
|
private
|
@@ -129,14 +135,5 @@ module ForemanMaintain::PackageManager
|
|
129
135
|
:interactive => !assumeyes, :valid_exit_statuses => valid_exit_statuses)
|
130
136
|
end
|
131
137
|
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
138
|
end
|
142
139
|
end
|
@@ -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-
|
11
|
+
date: 2022-04-26 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
|
@@ -274,7 +273,6 @@ files:
|
|
274
273
|
- definitions/procedures/maintenance_mode/enable_maintenance_mode.rb
|
275
274
|
- definitions/procedures/maintenance_mode/is_enabled.rb
|
276
275
|
- definitions/procedures/packages/check_update.rb
|
277
|
-
- definitions/procedures/packages/enable_version_locking.rb
|
278
276
|
- definitions/procedures/packages/install.rb
|
279
277
|
- definitions/procedures/packages/installer_confirmation.rb
|
280
278
|
- definitions/procedures/packages/lock_versions.rb
|
@@ -299,6 +297,7 @@ files:
|
|
299
297
|
- definitions/procedures/repositories/enable.rb
|
300
298
|
- definitions/procedures/repositories/setup.rb
|
301
299
|
- definitions/procedures/restore/candlepin_dump.rb
|
300
|
+
- definitions/procedures/restore/candlepin_reset_migrations.rb
|
302
301
|
- definitions/procedures/restore/configs.rb
|
303
302
|
- definitions/procedures/restore/confirmation.rb
|
304
303
|
- definitions/procedures/restore/drop_databases.rb
|
@@ -361,9 +360,10 @@ files:
|
|
361
360
|
- definitions/scenarios/upgrade_to_satellite_6_9.rb
|
362
361
|
- definitions/scenarios/upgrade_to_satellite_6_9_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
|
@@ -1,12 +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
|
-
package_manager.install_version_locking(:assumeyes => @assumeyes)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|