foreman_maintain 0.8.21 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/checks/foreman/check_puppet_capsules.rb +43 -0
- data/definitions/checks/pulpcore/group_ownership_check.rb +18 -0
- data/definitions/checks/repositories/validate.rb +1 -2
- data/definitions/checks/restore/validate_interfaces.rb +24 -0
- data/definitions/features/candlepin.rb +1 -2
- data/definitions/features/pulpcore.rb +2 -1
- data/definitions/features/system_repos.rb +8 -0
- data/definitions/procedures/backup/metadata.rb +11 -0
- data/definitions/procedures/installer/upgrade_rake_task.rb +3 -1
- data/definitions/procedures/pulpcore/migrate.rb +1 -1
- data/definitions/procedures/puppet/remove_puppet.rb +50 -0
- data/definitions/procedures/puppet/remove_puppet_data.rb +21 -0
- data/definitions/procedures/repositories/backup_enabled_repos.rb +16 -0
- data/definitions/procedures/repositories/enable.rb +13 -0
- data/definitions/procedures/repositories/setup.rb +0 -4
- data/definitions/procedures/restore/configs.rb +5 -1
- data/definitions/scenarios/puppet.rb +21 -0
- data/definitions/scenarios/restore.rb +14 -1
- data/definitions/scenarios/self_upgrade.rb +102 -0
- data/definitions/scenarios/upgrade_to_capsule_7_0.rb +89 -0
- data/definitions/scenarios/upgrade_to_capsule_7_0_z.rb +89 -0
- data/definitions/scenarios/upgrade_to_satellite_6_10.rb +1 -8
- data/definitions/scenarios/upgrade_to_satellite_7_0.rb +93 -0
- data/definitions/scenarios/upgrade_to_satellite_7_0_z.rb +90 -0
- data/lib/foreman_maintain/cli/plugin_command.rb +14 -0
- data/lib/foreman_maintain/cli/restore_command.rb +5 -1
- data/lib/foreman_maintain/cli/self_upgrade_command.rb +38 -0
- data/lib/foreman_maintain/cli.rb +4 -0
- data/lib/foreman_maintain/concerns/downstream.rb +50 -22
- data/lib/foreman_maintain/concerns/os_facts.rb +70 -0
- data/lib/foreman_maintain/concerns/system_helpers.rb +12 -33
- data/lib/foreman_maintain/utils/backup.rb +36 -11
- data/lib/foreman_maintain/utils.rb +0 -1
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +1 -0
- metadata +36 -11
- data/lib/foreman_maintain/concerns/el_repos_manager_common.rb +0 -20
- data/lib/foreman_maintain/repos_manager/dnf_config_manager.rb +0 -13
- data/lib/foreman_maintain/repos_manager/el_common.rb +0 -0
- data/lib/foreman_maintain/repos_manager/yum_config_manager.rb +0 -20
- data/lib/foreman_maintain/utils/facter.rb +0 -17
@@ -267,21 +267,46 @@ module ForemanMaintain
|
|
267
267
|
|
268
268
|
def validate_hostname?
|
269
269
|
# make sure that the system hostname is the same as the backup
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
# Incremental backups sometimes don't include httpd.conf. Since a "base" backup
|
275
|
-
# is restored before an incremental, we can assume that the hostname is checked
|
276
|
-
# during the base backup restore
|
277
|
-
if status == 0
|
278
|
-
match = httpd_config.match(/\s*ServerName\s+"*([^ "]+)"*\s*$/)
|
279
|
-
match ? match[1] == hostname : false
|
270
|
+
hostname_from_metadata = metadata.fetch('hostname', nil)
|
271
|
+
if hostname_from_metadata
|
272
|
+
hostname_from_metadata == hostname
|
280
273
|
else
|
281
|
-
|
274
|
+
config_tarball = file_map[:config_files][:path]
|
275
|
+
tar_cmd = "tar zxf #{config_tarball} etc/httpd/conf/httpd.conf --to-stdout --occurrence=1"
|
276
|
+
status, httpd_config = execute_with_status(tar_cmd)
|
277
|
+
|
278
|
+
# Incremental backups sometimes don't include httpd.conf. Since a "base" backup
|
279
|
+
# is restored before an incremental, we can assume that the hostname is checked
|
280
|
+
# during the base backup restore
|
281
|
+
if status == 0
|
282
|
+
match = httpd_config.match(/\s*ServerName\s+"*([^ "]+)"*\s*$/)
|
283
|
+
match ? match[1] == hostname : false
|
284
|
+
else
|
285
|
+
true
|
286
|
+
end
|
282
287
|
end
|
283
288
|
end
|
284
289
|
|
290
|
+
def validate_interfaces
|
291
|
+
# I wanted to do `Socket.getifaddrs.map(&:name).uniq`,
|
292
|
+
# but this has to work with Ruby 2.0, and Socket.getifaddrs is 2.1+
|
293
|
+
errors = {}
|
294
|
+
system_interfaces = Dir.entries('/sys/class/net') - ['.', '..']
|
295
|
+
|
296
|
+
proxy_config = metadata.fetch('proxy_config', {})
|
297
|
+
|
298
|
+
%w[dns dhcp].each do |feature|
|
299
|
+
next unless proxy_config.fetch(feature, false)
|
300
|
+
|
301
|
+
wanted_interface = proxy_config.fetch("#{feature}_interface", 'lo')
|
302
|
+
unless system_interfaces.include?(wanted_interface)
|
303
|
+
errors[feature] = { 'configured' => wanted_interface, 'available' => system_interfaces }
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
return errors
|
308
|
+
end
|
309
|
+
|
285
310
|
def metadata
|
286
311
|
if file_map[:metadata][:present]
|
287
312
|
YAML.load_file(file_map[:metadata][:path])
|
data/lib/foreman_maintain.rb
CHANGED
@@ -15,6 +15,7 @@ module ForemanMaintain
|
|
15
15
|
require 'foreman_maintain/concerns/finders'
|
16
16
|
require 'foreman_maintain/concerns/metadata'
|
17
17
|
require 'foreman_maintain/concerns/scenario_metadata'
|
18
|
+
require 'foreman_maintain/concerns/os_facts'
|
18
19
|
require 'foreman_maintain/concerns/system_helpers'
|
19
20
|
require 'foreman_maintain/concerns/system_service'
|
20
21
|
require 'foreman_maintain/concerns/hammer'
|
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: 0.
|
4
|
+
version: 1.0.0
|
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: 2021-
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -84,16 +84,30 @@ dependencies:
|
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 0.50.0
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - '='
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 0.50.0
|
97
111
|
description: Provides various features that helps keeping the Foreman/Satellite up
|
98
112
|
and running.
|
99
113
|
email: inecas@redhat.com
|
@@ -135,6 +149,7 @@ files:
|
|
135
149
|
- definitions/checks/foreman/check_duplicate_permission.rb
|
136
150
|
- definitions/checks/foreman/check_duplicate_roles.rb
|
137
151
|
- definitions/checks/foreman/check_https_proxies.rb
|
152
|
+
- definitions/checks/foreman/check_puppet_capsules.rb
|
138
153
|
- definitions/checks/foreman/db_up.rb
|
139
154
|
- definitions/checks/foreman/facts_names.rb
|
140
155
|
- definitions/checks/foreman/puppet_class_duplicates.rb
|
@@ -154,6 +169,7 @@ files:
|
|
154
169
|
- definitions/checks/original_assets.rb
|
155
170
|
- definitions/checks/package_manager/yum/validate_yum_config.rb
|
156
171
|
- definitions/checks/pulpcore/db_up.rb
|
172
|
+
- definitions/checks/pulpcore/group_ownership_check.rb
|
157
173
|
- definitions/checks/puppet/provide_upgrade_guide.rb
|
158
174
|
- definitions/checks/puppet/verify_no_empty_cacert_requests.rb
|
159
175
|
- definitions/checks/puppet/warn_about_puppet_removal.rb
|
@@ -163,6 +179,7 @@ files:
|
|
163
179
|
- definitions/checks/repositories/validate.rb
|
164
180
|
- definitions/checks/restore/validate_backup.rb
|
165
181
|
- definitions/checks/restore/validate_hostname.rb
|
182
|
+
- definitions/checks/restore/validate_interfaces.rb
|
166
183
|
- definitions/checks/root_user.rb
|
167
184
|
- definitions/checks/server_ping.rb
|
168
185
|
- definitions/checks/services_up.rb
|
@@ -271,9 +288,13 @@ files:
|
|
271
288
|
- definitions/procedures/pulp/remove.rb
|
272
289
|
- definitions/procedures/pulpcore/migrate.rb
|
273
290
|
- definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb
|
291
|
+
- definitions/procedures/puppet/remove_puppet.rb
|
292
|
+
- definitions/procedures/puppet/remove_puppet_data.rb
|
274
293
|
- definitions/procedures/refresh_features.rb
|
275
294
|
- definitions/procedures/remote_execution/remove_existing_settingsd.rb
|
295
|
+
- definitions/procedures/repositories/backup_enabled_repos.rb
|
276
296
|
- definitions/procedures/repositories/disable.rb
|
297
|
+
- definitions/procedures/repositories/enable.rb
|
277
298
|
- definitions/procedures/repositories/setup.rb
|
278
299
|
- definitions/procedures/restore/candlepin_dump.rb
|
279
300
|
- definitions/procedures/restore/configs.rb
|
@@ -305,7 +326,9 @@ files:
|
|
305
326
|
- definitions/scenarios/maintenance_mode.rb
|
306
327
|
- definitions/scenarios/packages.rb
|
307
328
|
- definitions/scenarios/prep_6_10_upgrade.rb
|
329
|
+
- definitions/scenarios/puppet.rb
|
308
330
|
- definitions/scenarios/restore.rb
|
331
|
+
- definitions/scenarios/self_upgrade.rb
|
309
332
|
- definitions/scenarios/services.rb
|
310
333
|
- definitions/scenarios/upgrade_to_capsule_6_10.rb
|
311
334
|
- definitions/scenarios/upgrade_to_capsule_6_10_z.rb
|
@@ -313,6 +336,8 @@ files:
|
|
313
336
|
- definitions/scenarios/upgrade_to_capsule_6_8_z.rb
|
314
337
|
- definitions/scenarios/upgrade_to_capsule_6_9.rb
|
315
338
|
- definitions/scenarios/upgrade_to_capsule_6_9_z.rb
|
339
|
+
- definitions/scenarios/upgrade_to_capsule_7_0.rb
|
340
|
+
- definitions/scenarios/upgrade_to_capsule_7_0_z.rb
|
316
341
|
- definitions/scenarios/upgrade_to_satellite_6_10.rb
|
317
342
|
- definitions/scenarios/upgrade_to_satellite_6_10_z.rb
|
318
343
|
- definitions/scenarios/upgrade_to_satellite_6_2.rb
|
@@ -331,6 +356,8 @@ files:
|
|
331
356
|
- definitions/scenarios/upgrade_to_satellite_6_8_z.rb
|
332
357
|
- definitions/scenarios/upgrade_to_satellite_6_9.rb
|
333
358
|
- definitions/scenarios/upgrade_to_satellite_6_9_z.rb
|
359
|
+
- definitions/scenarios/upgrade_to_satellite_7_0.rb
|
360
|
+
- definitions/scenarios/upgrade_to_satellite_7_0_z.rb
|
334
361
|
- extras/foreman-maintain.sh
|
335
362
|
- extras/foreman_protector/foreman-protector.conf
|
336
363
|
- extras/foreman_protector/foreman-protector.py
|
@@ -352,18 +379,20 @@ files:
|
|
352
379
|
- lib/foreman_maintain/cli/health_command.rb
|
353
380
|
- lib/foreman_maintain/cli/maintenance_mode_command.rb
|
354
381
|
- lib/foreman_maintain/cli/packages_command.rb
|
382
|
+
- lib/foreman_maintain/cli/plugin_command.rb
|
355
383
|
- lib/foreman_maintain/cli/restore_command.rb
|
384
|
+
- lib/foreman_maintain/cli/self_upgrade_command.rb
|
356
385
|
- lib/foreman_maintain/cli/service_command.rb
|
357
386
|
- lib/foreman_maintain/cli/transform_clamp_options.rb
|
358
387
|
- lib/foreman_maintain/cli/upgrade_command.rb
|
359
388
|
- lib/foreman_maintain/concerns/base_database.rb
|
360
389
|
- lib/foreman_maintain/concerns/directory_marker.rb
|
361
390
|
- lib/foreman_maintain/concerns/downstream.rb
|
362
|
-
- lib/foreman_maintain/concerns/el_repos_manager_common.rb
|
363
391
|
- lib/foreman_maintain/concerns/finders.rb
|
364
392
|
- lib/foreman_maintain/concerns/hammer.rb
|
365
393
|
- lib/foreman_maintain/concerns/logger.rb
|
366
394
|
- lib/foreman_maintain/concerns/metadata.rb
|
395
|
+
- lib/foreman_maintain/concerns/os_facts.rb
|
367
396
|
- lib/foreman_maintain/concerns/primary_checks.rb
|
368
397
|
- lib/foreman_maintain/concerns/pulp_common.rb
|
369
398
|
- lib/foreman_maintain/concerns/reporter.rb
|
@@ -387,9 +416,6 @@ files:
|
|
387
416
|
- lib/foreman_maintain/procedure.rb
|
388
417
|
- lib/foreman_maintain/reporter.rb
|
389
418
|
- lib/foreman_maintain/reporter/cli_reporter.rb
|
390
|
-
- lib/foreman_maintain/repos_manager/dnf_config_manager.rb
|
391
|
-
- lib/foreman_maintain/repos_manager/el_common.rb
|
392
|
-
- lib/foreman_maintain/repos_manager/yum_config_manager.rb
|
393
419
|
- lib/foreman_maintain/runner.rb
|
394
420
|
- lib/foreman_maintain/runner/execution.rb
|
395
421
|
- lib/foreman_maintain/runner/stored_execution.rb
|
@@ -406,7 +432,6 @@ files:
|
|
406
432
|
- lib/foreman_maintain/utils/disk/io_device.rb
|
407
433
|
- lib/foreman_maintain/utils/disk/nil_device.rb
|
408
434
|
- lib/foreman_maintain/utils/disk/stats.rb
|
409
|
-
- lib/foreman_maintain/utils/facter.rb
|
410
435
|
- lib/foreman_maintain/utils/hash_tools.rb
|
411
436
|
- lib/foreman_maintain/utils/mongo_core.rb
|
412
437
|
- lib/foreman_maintain/utils/response.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module ForemanMaintain
|
2
|
-
module Concerns
|
3
|
-
module ElReposManagerCommon
|
4
|
-
include ForemanMaintain::Concerns::OsFacts
|
5
|
-
|
6
|
-
def package_manager
|
7
|
-
return 'dnf' if el8?
|
8
|
-
|
9
|
-
'yum'
|
10
|
-
end
|
11
|
-
|
12
|
-
def enabled_repos_hash
|
13
|
-
repos = execute("#{package_manager} repolist enabled -d 6 -e 0 2> /dev/null | grep -E 'Repo-id|Repo-baseurl'")
|
14
|
-
return {} if repos.empty?
|
15
|
-
|
16
|
-
Hash[*repos.delete!(' ').split("\n")]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ForemanMaintain::ReposManager
|
2
|
-
class DnfConfigManager
|
3
|
-
include ForemanMaintain::Concerns::ElReposManagerCommon
|
4
|
-
|
5
|
-
def disable_repos(repo_ids)
|
6
|
-
execute!("dnf config-manager --set-disabled #{repo_ids.join(',')}")
|
7
|
-
end
|
8
|
-
|
9
|
-
def enable_repos(repo_ids)
|
10
|
-
execute!("dnf config-manager --set-enabled #{repo_ids.join(',')}")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
File without changes
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module ForemanMaintain::ReposManager
|
2
|
-
class YumConfigManager
|
3
|
-
include ForemanMaintain::Concerns::ElReposManagerCommon
|
4
|
-
|
5
|
-
def disable_repos(repo_ids)
|
6
|
-
execute!("yum-config-manager --disable #{repo_ids.join(',')}")
|
7
|
-
end
|
8
|
-
|
9
|
-
def enable_repos(repo_ids)
|
10
|
-
execute!("yum-config-manager --enable #{repo_ids.join(',')}")
|
11
|
-
end
|
12
|
-
|
13
|
-
def enabled_repos_hash
|
14
|
-
repos = execute("yum repolist enabled -d 6 -e 0 2> /dev/null | grep -E 'Repo-id|Repo-baseurl'")
|
15
|
-
return {} if repos.empty?
|
16
|
-
|
17
|
-
Hash[*repos.delete!(' ').split("\n")]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module ForemanMaintain::Utils
|
2
|
-
module Facter
|
3
|
-
include ForemanMaintain::Concerns::SystemHelpers
|
4
|
-
|
5
|
-
FACTER_FILES = %w[/usr/bin/facter /opt/puppetlabs/bin/facter].freeze
|
6
|
-
|
7
|
-
def self.package
|
8
|
-
puppet_version = version(execute!('/opt/puppetlabs/bin/puppet --version'))
|
9
|
-
|
10
|
-
puppet_version.major >= 4 ? 'puppet-agent' : 'facter'
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.path
|
14
|
-
FACTER_FILES.find { |path| File.exist?(path) }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|