foreman_maintain 0.9.1 → 1.0.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/check_for_newer_packages.rb +5 -3
- data/definitions/checks/disk/performance.rb +19 -8
- data/definitions/checks/foreman/check_puppet_capsules.rb +43 -0
- data/definitions/checks/foreman_proxy/check_tftp_storage.rb +3 -1
- data/definitions/checks/pulpcore/group_ownership_check.rb +18 -0
- data/definitions/checks/repositories/check_non_rh_repository.rb +9 -4
- data/definitions/checks/repositories/check_upstream_repository.rb +4 -4
- data/definitions/features/candlepin.rb +1 -2
- data/definitions/features/foreman_tasks.rb +11 -0
- data/definitions/features/pulpcore.rb +2 -1
- data/definitions/features/upstream_repositories.rb +23 -0
- data/definitions/procedures/content/prepare.rb +1 -1
- data/definitions/procedures/installer/upgrade_rake_task.rb +3 -1
- data/definitions/procedures/pulp/remove.rb +12 -0
- 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/disable.rb +1 -1
- data/definitions/procedures/repositories/enable.rb +13 -0
- data/definitions/scenarios/puppet.rb +21 -0
- data/definitions/scenarios/restore.rb +13 -2
- 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 +57 -29
- data/lib/foreman_maintain/concerns/system_helpers.rb +11 -4
- data/lib/foreman_maintain/repository_manager/el.rb +85 -0
- data/lib/foreman_maintain/repository_manager.rb +13 -0
- data/lib/foreman_maintain/utils/backup.rb +1 -1
- data/lib/foreman_maintain/utils/command_runner.rb +2 -1
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +1 -0
- metadata +19 -3
- data/definitions/features/system_repos.rb +0 -50
@@ -0,0 +1,85 @@
|
|
1
|
+
module ForemanMaintain::RepositoryManager
|
2
|
+
class El
|
3
|
+
include ForemanMaintain::Concerns::OsFacts
|
4
|
+
include ForemanMaintain::Concerns::SystemHelpers
|
5
|
+
|
6
|
+
def disable_repos(repo_ids)
|
7
|
+
if el7?
|
8
|
+
execute!("yum-config-manager #{config_manager_options(repo_ids, 'disable')}")
|
9
|
+
else
|
10
|
+
execute!("dnf config-manager #{config_manager_options(repo_ids, 'set-disabled')}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def rhsm_disable_repos(repo_ids)
|
15
|
+
if rhsm_available?
|
16
|
+
execute!(%(subscription-manager repos #{rhsm_options(repo_ids, 'disable')}))
|
17
|
+
else
|
18
|
+
logger.info("subscription-manager is not available.\
|
19
|
+
Using #{pkg_manager} config manager instead.")
|
20
|
+
disable_repos(repo_ids)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def enable_repos(repo_ids)
|
25
|
+
if el7?
|
26
|
+
execute!("yum-config-manager #{config_manager_options(repo_ids, 'enable')}")
|
27
|
+
else
|
28
|
+
execute!("dnf config-manager #{config_manager_options(repo_ids, 'enable')}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def rhsm_enable_repos(repo_ids)
|
33
|
+
if rhsm_available?
|
34
|
+
execute!(%(subscription-manager repos #{rhsm_options(repo_ids, 'enable')}))
|
35
|
+
else
|
36
|
+
logger.info("subscription-manager is not available.\
|
37
|
+
Using #{pkg_manager} config manager instead.")
|
38
|
+
enable_repos(repo_ids)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def rhsm_options(repo_ids, options)
|
43
|
+
repo_ids.map { |r| "--#{options}=#{r}" }.join(' ')
|
44
|
+
end
|
45
|
+
|
46
|
+
def config_manager_options(repo_ids, options)
|
47
|
+
repo_ids_string = if repo_ids.is_a?(Array)
|
48
|
+
repo_ids.join(',')
|
49
|
+
else
|
50
|
+
repo_ids
|
51
|
+
end
|
52
|
+
format_shell_args("--#{options}" => repo_ids_string)
|
53
|
+
end
|
54
|
+
|
55
|
+
def rhsm_available?
|
56
|
+
@rhsm_available ||= find_package('subscription-manager')
|
57
|
+
end
|
58
|
+
|
59
|
+
def rhsm_list_repos(list_option = '--list')
|
60
|
+
repos = execute(%(LANG=en_US.utf-8 subscription-manager repos #{list_option} 2>&1))
|
61
|
+
return {} if repos.empty?
|
62
|
+
|
63
|
+
hash_of_repoids_urls(repos, /Repo ID|Repo URL/)
|
64
|
+
end
|
65
|
+
|
66
|
+
def pkg_manager
|
67
|
+
package_manager.class.name.split('::').last.downcase
|
68
|
+
end
|
69
|
+
|
70
|
+
def enabled_repos
|
71
|
+
cmd = "#{pkg_manager} repolist enabled -d 6 -e 0 2> /dev/null"
|
72
|
+
repos = execute(cmd)
|
73
|
+
return {} if repos.empty?
|
74
|
+
|
75
|
+
hash_of_repoids_urls(repos, /Repo-id|Repo-baseurl/)
|
76
|
+
end
|
77
|
+
|
78
|
+
def hash_of_repoids_urls(repos, regex)
|
79
|
+
Hash[*repos.split("\n").grep(regex).map do |entry|
|
80
|
+
entry.split(':', 2).last.strip
|
81
|
+
end
|
82
|
+
]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'foreman_maintain/repository_manager/el'
|
2
|
+
include ForemanMaintain::Concerns::OsFacts
|
3
|
+
module ForemanMaintain
|
4
|
+
def self.repository_manager
|
5
|
+
@repository_manager ||= if el?
|
6
|
+
ForemanMaintain::RepositoryManager::El.new
|
7
|
+
elsif debian?
|
8
|
+
raise 'Not implemented!'
|
9
|
+
else
|
10
|
+
raise 'No supported repository manager was found'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -291,7 +291,7 @@ module ForemanMaintain
|
|
291
291
|
# I wanted to do `Socket.getifaddrs.map(&:name).uniq`,
|
292
292
|
# but this has to work with Ruby 2.0, and Socket.getifaddrs is 2.1+
|
293
293
|
errors = {}
|
294
|
-
system_interfaces = Dir.
|
294
|
+
system_interfaces = Dir.entries('/sys/class/net') - ['.', '..']
|
295
295
|
|
296
296
|
proxy_config = metadata.fetch('proxy_config', {})
|
297
297
|
|
@@ -66,7 +66,8 @@ module ForemanMaintain
|
|
66
66
|
log_file = Tempfile.open('captured-output')
|
67
67
|
exit_file = Tempfile.open('captured-exit-code')
|
68
68
|
Kernel.system(
|
69
|
-
"bash -c '#{full_command}; echo $? > #{exit_file.path}'
|
69
|
+
"stdbuf -oL -eL bash -c '#{full_command}; echo $? > #{exit_file.path}'"\
|
70
|
+
"| tee -i #{log_file.path}"
|
70
71
|
)
|
71
72
|
File.open(log_file.path) { |f| @output = f.read }
|
72
73
|
File.open(exit_file.path) do |f|
|
data/lib/foreman_maintain.rb
CHANGED
@@ -40,6 +40,7 @@ module ForemanMaintain
|
|
40
40
|
require 'foreman_maintain/upgrade_runner'
|
41
41
|
require 'foreman_maintain/reporter'
|
42
42
|
require 'foreman_maintain/package_manager'
|
43
|
+
require 'foreman_maintain/repository_manager'
|
43
44
|
require 'foreman_maintain/utils'
|
44
45
|
require 'foreman_maintain/error'
|
45
46
|
|
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.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: 2021-
|
11
|
+
date: 2021-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- definitions/checks/foreman/check_duplicate_permission.rb
|
150
150
|
- definitions/checks/foreman/check_duplicate_roles.rb
|
151
151
|
- definitions/checks/foreman/check_https_proxies.rb
|
152
|
+
- definitions/checks/foreman/check_puppet_capsules.rb
|
152
153
|
- definitions/checks/foreman/db_up.rb
|
153
154
|
- definitions/checks/foreman/facts_names.rb
|
154
155
|
- definitions/checks/foreman/puppet_class_duplicates.rb
|
@@ -168,6 +169,7 @@ files:
|
|
168
169
|
- definitions/checks/original_assets.rb
|
169
170
|
- definitions/checks/package_manager/yum/validate_yum_config.rb
|
170
171
|
- definitions/checks/pulpcore/db_up.rb
|
172
|
+
- definitions/checks/pulpcore/group_ownership_check.rb
|
171
173
|
- definitions/checks/puppet/provide_upgrade_guide.rb
|
172
174
|
- definitions/checks/puppet/verify_no_empty_cacert_requests.rb
|
173
175
|
- definitions/checks/puppet/warn_about_puppet_removal.rb
|
@@ -212,9 +214,9 @@ files:
|
|
212
214
|
- definitions/features/satellite.rb
|
213
215
|
- definitions/features/service.rb
|
214
216
|
- definitions/features/sync_plans.rb
|
215
|
-
- definitions/features/system_repos.rb
|
216
217
|
- definitions/features/tar.rb
|
217
218
|
- definitions/features/upstream.rb
|
219
|
+
- definitions/features/upstream_repositories.rb
|
218
220
|
- definitions/procedures/backup/accessibility_confirmation.rb
|
219
221
|
- definitions/procedures/backup/clean.rb
|
220
222
|
- definitions/procedures/backup/compress_data.rb
|
@@ -286,9 +288,13 @@ files:
|
|
286
288
|
- definitions/procedures/pulp/remove.rb
|
287
289
|
- definitions/procedures/pulpcore/migrate.rb
|
288
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
|
289
293
|
- definitions/procedures/refresh_features.rb
|
290
294
|
- definitions/procedures/remote_execution/remove_existing_settingsd.rb
|
295
|
+
- definitions/procedures/repositories/backup_enabled_repos.rb
|
291
296
|
- definitions/procedures/repositories/disable.rb
|
297
|
+
- definitions/procedures/repositories/enable.rb
|
292
298
|
- definitions/procedures/repositories/setup.rb
|
293
299
|
- definitions/procedures/restore/candlepin_dump.rb
|
294
300
|
- definitions/procedures/restore/configs.rb
|
@@ -320,7 +326,9 @@ files:
|
|
320
326
|
- definitions/scenarios/maintenance_mode.rb
|
321
327
|
- definitions/scenarios/packages.rb
|
322
328
|
- definitions/scenarios/prep_6_10_upgrade.rb
|
329
|
+
- definitions/scenarios/puppet.rb
|
323
330
|
- definitions/scenarios/restore.rb
|
331
|
+
- definitions/scenarios/self_upgrade.rb
|
324
332
|
- definitions/scenarios/services.rb
|
325
333
|
- definitions/scenarios/upgrade_to_capsule_6_10.rb
|
326
334
|
- definitions/scenarios/upgrade_to_capsule_6_10_z.rb
|
@@ -328,6 +336,8 @@ files:
|
|
328
336
|
- definitions/scenarios/upgrade_to_capsule_6_8_z.rb
|
329
337
|
- definitions/scenarios/upgrade_to_capsule_6_9.rb
|
330
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
|
331
341
|
- definitions/scenarios/upgrade_to_satellite_6_10.rb
|
332
342
|
- definitions/scenarios/upgrade_to_satellite_6_10_z.rb
|
333
343
|
- definitions/scenarios/upgrade_to_satellite_6_2.rb
|
@@ -346,6 +356,8 @@ files:
|
|
346
356
|
- definitions/scenarios/upgrade_to_satellite_6_8_z.rb
|
347
357
|
- definitions/scenarios/upgrade_to_satellite_6_9.rb
|
348
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
|
349
361
|
- extras/foreman-maintain.sh
|
350
362
|
- extras/foreman_protector/foreman-protector.conf
|
351
363
|
- extras/foreman_protector/foreman-protector.py
|
@@ -367,7 +379,9 @@ files:
|
|
367
379
|
- lib/foreman_maintain/cli/health_command.rb
|
368
380
|
- lib/foreman_maintain/cli/maintenance_mode_command.rb
|
369
381
|
- lib/foreman_maintain/cli/packages_command.rb
|
382
|
+
- lib/foreman_maintain/cli/plugin_command.rb
|
370
383
|
- lib/foreman_maintain/cli/restore_command.rb
|
384
|
+
- lib/foreman_maintain/cli/self_upgrade_command.rb
|
371
385
|
- lib/foreman_maintain/cli/service_command.rb
|
372
386
|
- lib/foreman_maintain/cli/transform_clamp_options.rb
|
373
387
|
- lib/foreman_maintain/cli/upgrade_command.rb
|
@@ -402,6 +416,8 @@ files:
|
|
402
416
|
- lib/foreman_maintain/procedure.rb
|
403
417
|
- lib/foreman_maintain/reporter.rb
|
404
418
|
- lib/foreman_maintain/reporter/cli_reporter.rb
|
419
|
+
- lib/foreman_maintain/repository_manager.rb
|
420
|
+
- lib/foreman_maintain/repository_manager/el.rb
|
405
421
|
- lib/foreman_maintain/runner.rb
|
406
422
|
- lib/foreman_maintain/runner/execution.rb
|
407
423
|
- lib/foreman_maintain/runner/stored_execution.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
class Features::SystemRepos < ForemanMaintain::Feature
|
2
|
-
metadata do
|
3
|
-
label :system_repos
|
4
|
-
description 'Feature for operations on yum repositories of system'
|
5
|
-
end
|
6
|
-
|
7
|
-
def upstream_repos
|
8
|
-
repositories = {}
|
9
|
-
enabled_repos_hash.each do |repo, url|
|
10
|
-
upstream_repo_urls.each do |regex|
|
11
|
-
repositories[repo] = url if url =~ regex
|
12
|
-
end
|
13
|
-
end
|
14
|
-
repositories
|
15
|
-
end
|
16
|
-
|
17
|
-
def enabled_repos_hash
|
18
|
-
repos = execute("yum repolist enabled -d 6 -e 0 2> /dev/null | grep -E 'Repo-id|Repo-baseurl'")
|
19
|
-
return {} if repos.empty?
|
20
|
-
|
21
|
-
Hash[*repos.delete!(' ').split("\n")]
|
22
|
-
end
|
23
|
-
|
24
|
-
def upstream_repos_ids
|
25
|
-
trim_repoids(upstream_repos.keys)
|
26
|
-
end
|
27
|
-
|
28
|
-
def disable_repos(repo_ids)
|
29
|
-
execute!("yum-config-manager --disable #{repo_ids.join(',')}")
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def trim_repoids(repos)
|
35
|
-
repos.map { |r| r.gsub(%r{Repo-id:|\/+\w*}, '') }
|
36
|
-
end
|
37
|
-
|
38
|
-
def upstream_repo_urls
|
39
|
-
repo_urls = { :Foreman => %r{yum.theforeman.org\/},
|
40
|
-
:Katello => %r{fedorapeople.org\/groups\/katello\/releases\/yum\/[\/|\w|.]*} }
|
41
|
-
[/#{repo_urls[:Foreman]}+releases/,
|
42
|
-
/#{repo_urls[:Foreman]}+plugins/,
|
43
|
-
/#{repo_urls[:Katello]}+katello/,
|
44
|
-
/#{repo_urls[:Katello]}+client/,
|
45
|
-
/#{repo_urls[:Katello]}+candlepin/,
|
46
|
-
/#{repo_urls[:Katello]}+pulp/,
|
47
|
-
%r{yum.puppetlabs.com\/el\/[\w|\/|\.]*\/x86_64},
|
48
|
-
%r{repos.fedorapeople.org\/repos\/pulp\/[\/|\w|.]*\/x86_64}]
|
49
|
-
end
|
50
|
-
end
|