foreman_maintain 0.8.9 → 0.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/definitions/checks/puppet/warn_about_puppet_removal.rb +35 -0
- data/definitions/procedures/pulp/cleanup_old_metadata_files.rb +75 -0
- data/definitions/procedures/pulp/remove.rb +10 -1
- data/definitions/scenarios/content.rb +18 -0
- data/definitions/scenarios/upgrade_to_satellite_6_10.rb +1 -0
- data/lib/foreman_maintain/cli/content_command.rb +11 -0
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89971a91002aac54e075713715691d77d7b715b58533f51e3289694cda83aa20
|
4
|
+
data.tar.gz: 2f0a7a2df838bf960b3ab131600d5845eec38151ef63c0bf3e510da4d207d971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5234f5d84ff2de5c3857493ab3c52a2f3c7bc03b96f68ba1122d1531ce086937072b7b4d20251ce7716dc81638d64bb95e74331031718c6899b247c3fc7ea561
|
7
|
+
data.tar.gz: 8ff4f8dfc0e233ef91639e6fbd02d7e74bda85dee490a1e1b7a47aa68d2eade50e5e4f581ca851f6f148b25344959650c78dd2103e1d32be044ba7c170ce4ff5
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Checks::Puppet
|
2
|
+
class WarnAboutPuppetRemoval < ForemanMaintain::Check
|
3
|
+
metadata do
|
4
|
+
description 'Warn about Puppet content removal prior to 6.10 upgrade'
|
5
|
+
label :warn_before_puppet_removal
|
6
|
+
confine do
|
7
|
+
feature(:instance).downstream &&
|
8
|
+
feature(:instance).downstream.current_minor_version == '6.9'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
message = "Puppet repositories found!\n"\
|
14
|
+
"Upgrading to 6.10 will delete the Puppet repositories\n"\
|
15
|
+
"if any of the following conditions are met,\n"\
|
16
|
+
"1. Any Puppet repositories in Library lifecycle environment.\n"\
|
17
|
+
"2. Unpublished content view's Puppet repositories.\n\n"\
|
18
|
+
"Note: Any Puppet content that is in use by hosts will not be deleted.\n"\
|
19
|
+
"After the upgrade, hosts will continue to use the Puppet modules,\n"\
|
20
|
+
'but future Puppet content management '\
|
21
|
+
"must be handled outside of the Satellite!\n\n"\
|
22
|
+
'Do you want to proceed?'
|
23
|
+
if puppet_repos_available?
|
24
|
+
answer = ask_decision(message, actions_msg: 'y(yes), n(no)')
|
25
|
+
exit 0 unless answer == :yes
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def puppet_repos_available?
|
30
|
+
hammer_cmd = '--output json repository list --fields name --content-type puppet'
|
31
|
+
puppet_repos = feature(:hammer).run(hammer_cmd)
|
32
|
+
!JSON.parse(puppet_repos).empty?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'find'
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
module Procedures::Pulp
|
5
|
+
class CleanupOldMetadataFiles < ForemanMaintain::Procedure
|
6
|
+
metadata do
|
7
|
+
description 'Cleanup old and unneeded yum metadata files from /var/lib/pulp/'
|
8
|
+
confine do
|
9
|
+
check_max_version('katello-common', '4.0')
|
10
|
+
end
|
11
|
+
param :remove_files, 'If true, will actually delete files, otherwise will print them out.'
|
12
|
+
end
|
13
|
+
|
14
|
+
PULP_METADATA_DIR = '/var/lib/pulp/published/yum/master/yum_distributor/'.freeze
|
15
|
+
REPOMD_FILE = 'repomd.xml'.freeze
|
16
|
+
|
17
|
+
def run
|
18
|
+
return unless File.directory?(PULP_METADATA_DIR)
|
19
|
+
found = []
|
20
|
+
|
21
|
+
puts 'Warning: This command may cause reduced performance related to content operations.'
|
22
|
+
message = 'Locating repository metadata (this may take a while)'
|
23
|
+
with_spinner(message) do |spinner|
|
24
|
+
Find.find(PULP_METADATA_DIR) do |path|
|
25
|
+
next if File.basename(path) != REPOMD_FILE
|
26
|
+
found << path
|
27
|
+
spinner.update("#{message}: Found #{found.count} repos.")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
found.each do |repo_md_path|
|
32
|
+
handle(repo_md_path, @remove_files)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def handle(repo_md_path, remove_files)
|
37
|
+
base_path = File.dirname(repo_md_path)
|
38
|
+
to_remove = list_existing_files(repo_md_path) - list_repomd_files(repo_md_path)
|
39
|
+
|
40
|
+
if to_remove.empty?
|
41
|
+
"Skipping #{base_path}, no files to remove."
|
42
|
+
elsif remove_files
|
43
|
+
puts '================================================================================'
|
44
|
+
puts "Removing #{to_remove.count} files from #{base_path}"
|
45
|
+
to_remove.each { |file| File.delete(File.join(base_path, file)) }
|
46
|
+
else
|
47
|
+
puts '================================================================================'
|
48
|
+
puts "For #{base_path} would remove, but --remove-files was not specified:"
|
49
|
+
to_remove.each { |file| puts " #{file}" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def list_repomd_files(repo_md_path)
|
54
|
+
doc = REXML::Document.new(File.new(repo_md_path))
|
55
|
+
filenames = []
|
56
|
+
doc.root.elements.each do |data|
|
57
|
+
locations = data.elements['location']
|
58
|
+
next unless locations
|
59
|
+
|
60
|
+
if locations.attributes
|
61
|
+
filenames << locations.attributes['href']
|
62
|
+
end
|
63
|
+
end
|
64
|
+
base_names(filenames.flatten)
|
65
|
+
end
|
66
|
+
|
67
|
+
def list_existing_files(repo_md_path)
|
68
|
+
base_names(Dir[File.dirname(repo_md_path) + '/*']) - [REPOMD_FILE]
|
69
|
+
end
|
70
|
+
|
71
|
+
def base_names(file_list)
|
72
|
+
file_list.map { |file| File.basename(file) }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -58,7 +58,8 @@ module Procedures::Pulp
|
|
58
58
|
def ask_to_proceed(rm_cmds)
|
59
59
|
question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
|
60
60
|
question += "\n# rpm -e #{pulp_packages.join(' ')}" if pulp_packages.any?
|
61
|
-
question += "\n# yum remove rh-mongodb34-*"
|
61
|
+
question += "\n# yum remove rh-mongodb34-*"
|
62
|
+
question += "\n# yum remove squid mod_wsgi" \
|
62
63
|
"\n\nAll pulp2 data will be removed.\n"
|
63
64
|
question += rm_cmds.collect { |cmd| "\n# #{cmd}" }.join
|
64
65
|
question += "\n\nDo you want to proceed?"
|
@@ -77,6 +78,8 @@ module Procedures::Pulp
|
|
77
78
|
|
78
79
|
remove_mongo
|
79
80
|
|
81
|
+
remove_other_packages
|
82
|
+
|
80
83
|
drop_migration_tables
|
81
84
|
|
82
85
|
drop_migrations
|
@@ -96,6 +99,12 @@ module Procedures::Pulp
|
|
96
99
|
end
|
97
100
|
end
|
98
101
|
|
102
|
+
def remove_other_packages
|
103
|
+
with_spinner('Removing additional packages') do
|
104
|
+
packages_action(:remove, %w[squid mod_wsgi], :assumeyes => true)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
99
108
|
def drop_migration_tables
|
100
109
|
with_spinner('Dropping migration tables') do
|
101
110
|
feature(:pulpcore_database).psql(<<-SQL)
|
@@ -98,6 +98,24 @@ module ForemanMaintain::Scenarios
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
+
class CleanupRepositoryMetadata < ContentBase
|
102
|
+
metadata do
|
103
|
+
label :cleanup_repository_metadata
|
104
|
+
description 'Remove old leftover repository metadata'
|
105
|
+
param :remove_files, 'Actually remove the files? Otherwise a dryrun is performed.'
|
106
|
+
|
107
|
+
manual_detection
|
108
|
+
end
|
109
|
+
|
110
|
+
def compose
|
111
|
+
add_step_with_context(Procedures::Pulp::CleanupOldMetadataFiles)
|
112
|
+
end
|
113
|
+
|
114
|
+
def set_context_mapping
|
115
|
+
context.map(:remove_files, Procedures::Pulp::CleanupOldMetadataFiles => :remove_files)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
101
119
|
class RemovePulp2 < ContentBase
|
102
120
|
metadata do
|
103
121
|
label :content_remove_pulp2
|
@@ -34,6 +34,17 @@ module ForemanMaintain
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
subcommand 'cleanup-repository-metadata', 'Cleanup old repository metadata under Pulp 2' do
|
38
|
+
option ['-r', '--remove-files'], :flag, 'Remove the files instead of just listing them.',
|
39
|
+
:attribute_name => :remove_files
|
40
|
+
|
41
|
+
def execute
|
42
|
+
run_scenarios_and_exit(
|
43
|
+
Scenarios::Content::CleanupRepositoryMetadata.new(:remove_files => @remove_files)
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
37
48
|
subcommand 'remove-pulp2', 'Remove pulp2 and mongodb packages and data' do
|
38
49
|
interactive_option(%w[assumeyes plaintext])
|
39
50
|
def execute
|
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.8.
|
4
|
+
version: 0.8.10
|
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-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- definitions/checks/pulpcore/db_up.rb
|
155
155
|
- definitions/checks/puppet/provide_upgrade_guide.rb
|
156
156
|
- definitions/checks/puppet/verify_no_empty_cacert_requests.rb
|
157
|
+
- definitions/checks/puppet/warn_about_puppet_removal.rb
|
157
158
|
- definitions/checks/remote_execution/verify_settings_file_already_exists.rb
|
158
159
|
- definitions/checks/repositories/check_non_rh_repository.rb
|
159
160
|
- definitions/checks/repositories/check_upstream_repository.rb
|
@@ -262,6 +263,7 @@ files:
|
|
262
263
|
- definitions/procedures/packages/update_all_confirmation.rb
|
263
264
|
- definitions/procedures/passenger_recycler.rb
|
264
265
|
- definitions/procedures/prep_6_10_upgrade.rb
|
266
|
+
- definitions/procedures/pulp/cleanup_old_metadata_files.rb
|
265
267
|
- definitions/procedures/pulp/migrate.rb
|
266
268
|
- definitions/procedures/pulp/print_remove_instructions.rb
|
267
269
|
- definitions/procedures/pulp/remove.rb
|