foreman_maintain 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -4
- data/bin/foreman-maintain +1 -1
- data/bin/foreman-maintain-complete +5 -5
- data/definitions/checks/candlepin/db_up.rb +1 -1
- data/definitions/checks/candlepin/validate_db.rb +2 -9
- data/definitions/checks/check_for_newer_packages.rb +5 -5
- data/definitions/checks/check_hotfix_installed.rb +3 -7
- data/definitions/checks/disk/available_space_postgresql12.rb +3 -2
- data/definitions/checks/disk/performance.rb +3 -3
- data/definitions/checks/foreman/check_corrupted_roles.rb +2 -4
- data/definitions/checks/foreman/check_duplicate_permission.rb +1 -1
- data/definitions/checks/foreman/check_duplicate_roles.rb +1 -1
- data/definitions/checks/foreman/check_tuning_requirements.rb +1 -1
- data/definitions/checks/foreman/db_up.rb +1 -1
- data/definitions/checks/foreman/facts_names.rb +4 -4
- data/definitions/checks/foreman_openscap/invalid_report_associations.rb +4 -4
- data/definitions/checks/foreman_proxy/check_tftp_storage.rb +4 -4
- data/definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb +1 -2
- data/definitions/checks/foreman_tasks/invalid/check_old.rb +2 -2
- data/definitions/checks/foreman_tasks/invalid/check_pending_state.rb +2 -2
- data/definitions/checks/foreman_tasks/invalid/check_planning_state.rb +2 -2
- data/definitions/checks/foreman_tasks/not_paused.rb +2 -2
- data/definitions/checks/foreman_tasks/not_running.rb +6 -6
- data/definitions/checks/original_assets.rb +3 -3
- data/definitions/checks/package_manager/yum/validate_yum_config.rb +1 -1
- data/definitions/checks/pulpcore/db_up.rb +1 -1
- data/definitions/checks/repositories/check_upstream_repository.rb +2 -2
- data/definitions/checks/repositories/validate.rb +2 -2
- data/definitions/checks/restore/validate_backup.rb +2 -2
- data/definitions/checks/restore/validate_hostname.rb +2 -2
- data/definitions/checks/restore/validate_interfaces.rb +2 -2
- data/definitions/checks/restore/validate_postgresql_dump_permissions.rb +31 -0
- data/definitions/checks/services_up.rb +2 -2
- data/definitions/features/apache.rb +1 -1
- data/definitions/features/candlepin.rb +1 -1
- data/definitions/features/candlepin_database.rb +2 -4
- data/definitions/features/cron.rb +3 -5
- data/definitions/features/dynflow_sidekiq.rb +2 -2
- data/definitions/features/foreman_cockpit.rb +1 -1
- data/definitions/features/foreman_database.rb +1 -1
- data/definitions/features/foreman_proxy.rb +1 -1
- data/definitions/features/foreman_server.rb +2 -2
- data/definitions/features/foreman_tasks.rb +9 -12
- data/definitions/features/gofer.rb +1 -1
- data/definitions/features/hammer.rb +4 -4
- data/definitions/features/installer.rb +4 -5
- data/definitions/features/instance.rb +12 -14
- data/definitions/features/katello.rb +8 -12
- data/definitions/features/pulpcore.rb +5 -3
- data/definitions/features/pulpcore_database.rb +3 -1
- data/definitions/features/puppet_server.rb +1 -1
- data/definitions/features/redis.rb +2 -18
- data/definitions/features/salt_server.rb +1 -1
- data/definitions/features/service.rb +4 -48
- data/definitions/features/sync_plans.rb +2 -2
- data/definitions/features/tar.rb +4 -3
- data/definitions/procedures/backup/compress_data.rb +0 -1
- data/definitions/procedures/backup/config_files.rb +6 -5
- data/definitions/procedures/backup/prepare_directory.rb +0 -2
- data/definitions/procedures/backup/pulp.rb +3 -3
- data/definitions/procedures/backup/snapshot/clean_mount.rb +1 -1
- data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +1 -2
- data/definitions/procedures/backup/snapshot/mount_pulp.rb +2 -2
- data/definitions/procedures/foreman/fix_corrupted_roles.rb +3 -3
- data/definitions/procedures/foreman_tasks/delete.rb +3 -3
- data/definitions/procedures/hammer_setup.rb +1 -1
- data/definitions/procedures/knowledge_base_article.rb +3 -4
- data/definitions/procedures/packages/enable_modules.rb +1 -1
- data/definitions/procedures/packages/install.rb +1 -1
- data/definitions/procedures/packages/uninstall.rb +1 -1
- data/definitions/procedures/packages/update.rb +1 -1
- data/definitions/procedures/remote_execution/remove_existing_settingsd.rb +2 -2
- data/definitions/procedures/repositories/enable.rb +1 -1
- data/definitions/procedures/repositories/setup.rb +2 -2
- data/definitions/procedures/restore/candlepin_dump.rb +2 -2
- data/definitions/procedures/restore/configs.rb +3 -10
- data/definitions/procedures/restore/drop_databases.rb +2 -2
- data/definitions/procedures/restore/extract_files.rb +4 -17
- data/definitions/procedures/restore/foreman_dump.rb +2 -2
- data/definitions/procedures/restore/installer_reset.rb +1 -2
- data/definitions/procedures/restore/postgres_owner.rb +2 -2
- data/definitions/procedures/restore/pulpcore_dump.rb +2 -2
- data/definitions/procedures/selinux/set_file_security.rb +2 -2
- data/definitions/procedures/service/restart.rb +1 -1
- data/definitions/scenarios/backup.rb +44 -61
- data/definitions/scenarios/packages.rb +9 -9
- data/definitions/scenarios/restore.rb +24 -40
- data/definitions/scenarios/self_upgrade.rb +7 -11
- data/definitions/scenarios/services.rb +17 -17
- data/extras/foreman_protector/foreman-protector.whitelist +0 -6
- data/lib/foreman_maintain/cli/advanced/prebuild_bash_completion.rb +1 -1
- data/lib/foreman_maintain/cli/advanced_command.rb +2 -2
- data/lib/foreman_maintain/cli/backup_command.rb +17 -17
- data/lib/foreman_maintain/cli/base.rb +13 -13
- data/lib/foreman_maintain/cli/maintenance_mode_command.rb +1 -1
- data/lib/foreman_maintain/cli/plugin_command.rb +1 -1
- data/lib/foreman_maintain/cli/restore_command.rb +4 -4
- data/lib/foreman_maintain/cli/self_upgrade_command.rb +2 -2
- data/lib/foreman_maintain/cli/service_command.rb +2 -2
- data/lib/foreman_maintain/cli/transform_clamp_options.rb +1 -1
- data/lib/foreman_maintain/cli/upgrade_command.rb +7 -7
- data/lib/foreman_maintain/cli.rb +1 -11
- data/lib/foreman_maintain/concerns/base_database.rb +8 -17
- data/lib/foreman_maintain/concerns/downstream.rb +6 -64
- data/lib/foreman_maintain/concerns/firewall/iptables_maintenance_mode.rb +1 -1
- data/lib/foreman_maintain/concerns/foreman_and_katello_version_map.rb +1 -1
- data/lib/foreman_maintain/concerns/os_facts.rb +0 -8
- data/lib/foreman_maintain/concerns/primary_checks.rb +6 -5
- data/lib/foreman_maintain/concerns/pulp_common.rb +1 -8
- data/lib/foreman_maintain/concerns/system_helpers.rb +3 -6
- data/lib/foreman_maintain/concerns/upstream.rb +3 -3
- data/lib/foreman_maintain/config.rb +6 -6
- data/lib/foreman_maintain/core_ext.rb +2 -2
- data/lib/foreman_maintain/executable.rb +7 -9
- data/lib/foreman_maintain/package_manager/apt.rb +2 -2
- data/lib/foreman_maintain/package_manager/base.rb +0 -2
- data/lib/foreman_maintain/package_manager/dnf.rb +2 -2
- data/lib/foreman_maintain/package_manager/yum.rb +2 -3
- data/lib/foreman_maintain/package_manager.rb +1 -3
- data/lib/foreman_maintain/param.rb +2 -2
- data/lib/foreman_maintain/reporter/cli_reporter.rb +6 -7
- data/lib/foreman_maintain/reporter.rb +15 -10
- data/lib/foreman_maintain/repository_manager/el.rb +2 -10
- data/lib/foreman_maintain/repository_manager.rb +2 -1
- data/lib/foreman_maintain/runner.rb +5 -5
- data/lib/foreman_maintain/scenario.rb +4 -2
- data/lib/foreman_maintain/upgrade_runner.rb +0 -2
- data/lib/foreman_maintain/utils/backup.rb +27 -111
- data/lib/foreman_maintain/utils/bash.rb +18 -19
- data/lib/foreman_maintain/utils/command_runner.rb +5 -9
- data/lib/foreman_maintain/utils/hash_tools.rb +5 -5
- data/lib/foreman_maintain/utils/response.rb +1 -0
- data/lib/foreman_maintain/utils/service/remote_db.rb +1 -0
- data/lib/foreman_maintain/utils/service/systemd.rb +3 -5
- data/lib/foreman_maintain/utils/service.rb +1 -1
- data/lib/foreman_maintain/utils.rb +0 -1
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain/yaml_storage.rb +1 -0
- data/lib/foreman_maintain.rb +3 -3
- metadata +29 -78
- data/definitions/checks/foreman/check_https_proxies.rb +0 -34
- data/definitions/checks/mongo/db_up.rb +0 -33
- data/definitions/checks/mongo/tools_installed.rb +0 -31
- data/definitions/checks/pulpcore/group_ownership_check.rb +0 -18
- data/definitions/checks/puppet/provide_upgrade_guide.rb +0 -35
- data/definitions/checks/puppet/warn_about_puppet_removal.rb +0 -35
- data/definitions/checks/remote_execution/verify_settings_file_already_exists.rb +0 -42
- data/definitions/features/mongo.rb +0 -217
- data/definitions/features/pulp2.rb +0 -35
- data/definitions/procedures/backup/offline/mongo.rb +0 -56
- data/definitions/procedures/backup/online/mongo.rb +0 -21
- data/definitions/procedures/backup/snapshot/mount_mongo.rb +0 -43
- data/definitions/procedures/candlepin/delete_orphaned_records_from_env_content.rb +0 -40
- data/definitions/procedures/content/fix_pulpcore_artifact_permissions.rb +0 -31
- data/definitions/procedures/content/migration_reset.rb +0 -12
- data/definitions/procedures/content/migration_stats.rb +0 -12
- data/definitions/procedures/content/prepare.rb +0 -17
- data/definitions/procedures/content/prepare_abort.rb +0 -12
- data/definitions/procedures/content/switchover.rb +0 -41
- data/definitions/procedures/prep_6_10_upgrade.rb +0 -29
- data/definitions/procedures/pulp/cleanup_old_metadata_files.rb +0 -75
- data/definitions/procedures/pulp/migrate.rb +0 -23
- data/definitions/procedures/pulp/print_remove_instructions.rb +0 -16
- data/definitions/procedures/pulp/remove.rb +0 -222
- data/definitions/procedures/restore/ensure_mongo_engine_matches.rb +0 -35
- data/definitions/procedures/restore/mongo_dump.rb +0 -41
- data/definitions/procedures/restore/regenerate_queues.rb +0 -69
- data/definitions/scenarios/content.rb +0 -158
- data/definitions/scenarios/prep_6_10_upgrade.rb +0 -13
- data/definitions/scenarios/upgrade_to_capsule_6_10.rb +0 -89
- data/definitions/scenarios/upgrade_to_capsule_6_10_z.rb +0 -88
- data/definitions/scenarios/upgrade_to_capsule_6_11.rb +0 -91
- data/definitions/scenarios/upgrade_to_capsule_6_11_z.rb +0 -90
- data/definitions/scenarios/upgrade_to_capsule_6_12.rb +0 -92
- data/definitions/scenarios/upgrade_to_capsule_6_12_z.rb +0 -92
- data/definitions/scenarios/upgrade_to_capsule_6_13.rb +0 -92
- data/definitions/scenarios/upgrade_to_capsule_6_13_z.rb +0 -92
- data/definitions/scenarios/upgrade_to_capsule_6_8.rb +0 -88
- data/definitions/scenarios/upgrade_to_capsule_6_8_z.rb +0 -88
- data/definitions/scenarios/upgrade_to_capsule_6_9.rb +0 -88
- data/definitions/scenarios/upgrade_to_capsule_6_9_z.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_10.rb +0 -113
- data/definitions/scenarios/upgrade_to_satellite_6_10_z.rb +0 -89
- data/definitions/scenarios/upgrade_to_satellite_6_11.rb +0 -96
- data/definitions/scenarios/upgrade_to_satellite_6_11_z.rb +0 -91
- data/definitions/scenarios/upgrade_to_satellite_6_12.rb +0 -95
- data/definitions/scenarios/upgrade_to_satellite_6_12_z.rb +0 -94
- data/definitions/scenarios/upgrade_to_satellite_6_13.rb +0 -95
- data/definitions/scenarios/upgrade_to_satellite_6_13_z.rb +0 -94
- data/definitions/scenarios/upgrade_to_satellite_6_2.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_3.rb +0 -89
- data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_4.rb +0 -89
- data/definitions/scenarios/upgrade_to_satellite_6_4_z.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_5.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_5_z.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_6.rb +0 -90
- data/definitions/scenarios/upgrade_to_satellite_6_6_z.rb +0 -90
- data/definitions/scenarios/upgrade_to_satellite_6_7.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_7_z.rb +0 -88
- data/definitions/scenarios/upgrade_to_satellite_6_8.rb +0 -91
- data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +0 -89
- data/definitions/scenarios/upgrade_to_satellite_6_9.rb +0 -91
- data/definitions/scenarios/upgrade_to_satellite_6_9_z.rb +0 -89
- data/lib/foreman_maintain/cli/content_command.rb +0 -69
- data/lib/foreman_maintain/utils/mongo_core.rb +0 -86
@@ -1,217 +0,0 @@
|
|
1
|
-
class Features::Mongo < ForemanMaintain::Feature
|
2
|
-
include ForemanMaintain::Concerns::DirectoryMarker
|
3
|
-
|
4
|
-
# assume mongo is installed when there is Pulp
|
5
|
-
PULP_DB_CONFIG = '/etc/pulp/server.conf'.freeze
|
6
|
-
|
7
|
-
attr_reader :configuration
|
8
|
-
metadata do
|
9
|
-
label :mongo
|
10
|
-
|
11
|
-
confine do
|
12
|
-
feature(:pulp2)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def services
|
17
|
-
core.services.map do |service, priority|
|
18
|
-
system_service(service, priority, :db_feature => self)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def data_dir
|
23
|
-
'/var/lib/mongodb'
|
24
|
-
end
|
25
|
-
|
26
|
-
def config_files
|
27
|
-
[config_file] + (local? ? core.server_config_files : [])
|
28
|
-
end
|
29
|
-
|
30
|
-
def config_file
|
31
|
-
PULP_DB_CONFIG
|
32
|
-
end
|
33
|
-
|
34
|
-
def initialize
|
35
|
-
reload_db_config
|
36
|
-
end
|
37
|
-
|
38
|
-
def reload_db_config
|
39
|
-
@configuration = load_db_config(config_file)
|
40
|
-
end
|
41
|
-
|
42
|
-
# guess mongo version from installed packages
|
43
|
-
# safe method to run mongo commands prior we know
|
44
|
-
# what version uses the target DB
|
45
|
-
def available_core
|
46
|
-
return @core unless @core.nil? # return correct mongo ver if known
|
47
|
-
if @available_core.nil?
|
48
|
-
@available_core = ForemanMaintain::Utils::MongoCoreInstalled.new
|
49
|
-
end
|
50
|
-
@available_core
|
51
|
-
end
|
52
|
-
|
53
|
-
def core
|
54
|
-
if @core.nil?
|
55
|
-
begin
|
56
|
-
version = server_version
|
57
|
-
@core = if version =~ /^3\.4/
|
58
|
-
load_mongo_core_34(version)
|
59
|
-
else
|
60
|
-
load_mongo_core_default(version)
|
61
|
-
end
|
62
|
-
rescue ForemanMaintain::Error::ExecutionError
|
63
|
-
# server version detection failed
|
64
|
-
logger.debug('Mongo version detection failed, choosing from installed versions')
|
65
|
-
@core = @available_core
|
66
|
-
end
|
67
|
-
end
|
68
|
-
@core
|
69
|
-
end
|
70
|
-
|
71
|
-
def local?
|
72
|
-
['localhost', '127.0.0.1', hostname].include?(configuration['host'])
|
73
|
-
end
|
74
|
-
|
75
|
-
# rubocop:disable Metrics/AbcSize
|
76
|
-
def base_command(command, config = configuration, args = '')
|
77
|
-
if config['ssl']
|
78
|
-
ssl = ' --ssl'
|
79
|
-
if config['ca_path'] && !config['ca_path'].empty?
|
80
|
-
ca_cert = " --sslCAFile #{config['ca_path']}"
|
81
|
-
end
|
82
|
-
if config['ssl_certfile'] && !config['ssl_certfile'].empty?
|
83
|
-
client_cert = " --sslPEMKeyFile #{config['ssl_certfile']}"
|
84
|
-
end
|
85
|
-
verify_ssl = ' --sslAllowInvalidCertificates' if config['verify_ssl'] == false
|
86
|
-
end
|
87
|
-
username = " -u #{config['username']}" if config['username']
|
88
|
-
password = " -p #{config['password']}" if config['password']
|
89
|
-
host = "--host #{config['host']} --port #{config['port']}"
|
90
|
-
"#{command}#{username}#{password} #{host}#{ssl}#{verify_ssl}#{ca_cert}#{client_cert} #{args}"
|
91
|
-
end
|
92
|
-
# rubocop:enable Metrics/AbcSize
|
93
|
-
|
94
|
-
def mongo_command(args, config = configuration)
|
95
|
-
base_command(core.client_command, config, "#{args} #{config['name']}")
|
96
|
-
end
|
97
|
-
|
98
|
-
def dump(target, config = configuration)
|
99
|
-
execute!(base_command(core.dump_command, config, "-d #{config['name']} --out #{target}"),
|
100
|
-
:hidden_patterns => [config['password']])
|
101
|
-
end
|
102
|
-
|
103
|
-
def restore(dir, config = configuration)
|
104
|
-
cmd = base_command(core.restore_command, config,
|
105
|
-
"-d #{config['name']} #{File.join(dir, config['name'])}")
|
106
|
-
execute!(cmd, :hidden_patterns => [config['password']])
|
107
|
-
end
|
108
|
-
|
109
|
-
def dropdb(config = configuration)
|
110
|
-
execute!(mongo_command("--eval 'db.dropDatabase()'", config),
|
111
|
-
:hidden_patterns => [config['password']])
|
112
|
-
end
|
113
|
-
|
114
|
-
def ping(config = configuration)
|
115
|
-
execute?(mongo_command("--eval 'ping:1'", config),
|
116
|
-
:hidden_patterns => [config['password']])
|
117
|
-
end
|
118
|
-
|
119
|
-
def server_version(config = configuration)
|
120
|
-
# do not use any core methods as we need this prior the core is created
|
121
|
-
mongo_cmd = base_command(available_core.client_command, config,
|
122
|
-
"--eval 'db.version()' #{config['name']}")
|
123
|
-
version = execute!(mongo_cmd, :hidden_patterns => [config['password']])
|
124
|
-
version.split("\n").last
|
125
|
-
end
|
126
|
-
|
127
|
-
def backup_local(backup_file, extra_tar_options = {})
|
128
|
-
dir = extra_tar_options.fetch(:data_dir, nil) || data_dir
|
129
|
-
logger.info("Backup of Mongo DB at #{dir} into #{backup_file}")
|
130
|
-
logger.debug(extra_tar_options.inspect)
|
131
|
-
FileUtils.cd(dir) do
|
132
|
-
tar_options = {
|
133
|
-
:archive => backup_file,
|
134
|
-
:command => 'create',
|
135
|
-
:exclude => ['mongod.lock'],
|
136
|
-
:transform => 's,^,var/lib/mongodb/,S',
|
137
|
-
:files => '*'
|
138
|
-
}.merge(extra_tar_options)
|
139
|
-
feature(:tar).run(tar_options)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def mongo_cmd_available?
|
144
|
-
exit_status, _output = execute_with_status('which mongo')
|
145
|
-
exit_status == 0
|
146
|
-
end
|
147
|
-
|
148
|
-
def raise_mongo_client_missing_error
|
149
|
-
raise ForemanMaintain::Error::Fail, 'The mongo command not found.'\
|
150
|
-
' Make sure system has mongo utility installed.'
|
151
|
-
end
|
152
|
-
|
153
|
-
private
|
154
|
-
|
155
|
-
def load_mongo_core_default(version)
|
156
|
-
unless find_package('mongodb')
|
157
|
-
raise ForemanMaintain::Error::Fail, 'Mongo client was not found'
|
158
|
-
end
|
159
|
-
logger.debug("Mongo #{version} detected, using default commands")
|
160
|
-
ForemanMaintain::Utils::MongoCore.new
|
161
|
-
end
|
162
|
-
|
163
|
-
def load_mongo_core_34(version)
|
164
|
-
unless find_package('rh-mongodb34-mongodb')
|
165
|
-
raise ForemanMaintain::Error::Fail, 'Mongo client ver. 3.4 was not found'
|
166
|
-
end
|
167
|
-
logger.debug("Mongo #{version} detected, using commands from rh-mongodb34 SCL")
|
168
|
-
ForemanMaintain::Utils::MongoCore34.new
|
169
|
-
end
|
170
|
-
|
171
|
-
def norm_value(value)
|
172
|
-
value = value.strip
|
173
|
-
case value
|
174
|
-
when 'true'
|
175
|
-
true
|
176
|
-
when 'false'
|
177
|
-
false
|
178
|
-
else
|
179
|
-
value
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def load_db_config(config)
|
184
|
-
cfg = read_db_section(config)
|
185
|
-
if cfg['seeds']
|
186
|
-
seed = cfg['seeds'].split(',').first
|
187
|
-
host, port = seed.split(':')
|
188
|
-
end
|
189
|
-
cfg['host'] = host || 'localhost'
|
190
|
-
cfg['port'] = port || '27017'
|
191
|
-
cfg
|
192
|
-
end
|
193
|
-
|
194
|
-
# rubocop:disable Metrics/MethodLength
|
195
|
-
def read_db_section(config)
|
196
|
-
cfg = {}
|
197
|
-
section = nil
|
198
|
-
File.readlines(config).each do |line|
|
199
|
-
case line
|
200
|
-
when /^\s*#/
|
201
|
-
next # skip comments
|
202
|
-
when /^\s*$/
|
203
|
-
next # skip empty lines
|
204
|
-
when /\[([^\]]+)\]/
|
205
|
-
section = Regexp.last_match(1)
|
206
|
-
next
|
207
|
-
else
|
208
|
-
if section == 'database'
|
209
|
-
key, value = line.split(':', 2)
|
210
|
-
cfg[key.strip] = norm_value(value)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
cfg
|
215
|
-
end
|
216
|
-
# rubocop:enable Metrics/MethodLength
|
217
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
class Features::Pulp < ForemanMaintain::Feature
|
2
|
-
include ForemanMaintain::Concerns::DirectoryMarker
|
3
|
-
include ForemanMaintain::Concerns::PulpCommon
|
4
|
-
|
5
|
-
metadata do
|
6
|
-
label :pulp2
|
7
|
-
|
8
|
-
confine do
|
9
|
-
!check_min_version('katello-common', '4.0') &&
|
10
|
-
ForemanMaintain::Utils::Service::Systemd.new('pulp_resource_manager', 0).enabled?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def services
|
15
|
-
[
|
16
|
-
system_service('squid', 10),
|
17
|
-
system_service('qpidd', 10),
|
18
|
-
system_service('qdrouterd', 10),
|
19
|
-
system_service('pulp_workers', 20),
|
20
|
-
system_service('pulp_celerybeat', 20),
|
21
|
-
system_service('pulp_resource_manager', 20),
|
22
|
-
system_service('pulp_streamer', 20),
|
23
|
-
system_service('httpd', 30)
|
24
|
-
]
|
25
|
-
end
|
26
|
-
|
27
|
-
def config_files
|
28
|
-
[
|
29
|
-
'/etc/pki/pulp',
|
30
|
-
'/etc/pulp',
|
31
|
-
'/etc/crane.conf',
|
32
|
-
'/etc/default/pulp_workers'
|
33
|
-
]
|
34
|
-
end
|
35
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Offline
|
3
|
-
class Mongo < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
description 'Backup mongo offline'
|
6
|
-
tags :backup
|
7
|
-
for_feature :mongo
|
8
|
-
preparation_steps do
|
9
|
-
unless feature(:mongo).local?
|
10
|
-
[Checks::Mongo::DBUp.new, Checks::Mongo::ToolsInstalled.new]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
param :backup_dir, 'Directory where to backup to', :required => true
|
14
|
-
param :tar_volume_size, 'Size of tar volume (indicates splitting)'
|
15
|
-
param :mount_dir, 'Snapshot mount directory'
|
16
|
-
end
|
17
|
-
|
18
|
-
def run
|
19
|
-
if feature(:mongo).local?
|
20
|
-
local_backup
|
21
|
-
else
|
22
|
-
dump_mongo
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def data_dir
|
27
|
-
return nil if @mount_dir.nil?
|
28
|
-
mount_point = File.join(@mount_dir, 'mongodb')
|
29
|
-
dir = feature(:mongo).find_marked_directory(mount_point)
|
30
|
-
fail!("Snapshot of Mongo DB was not found mounted in #{mount_point}") if dir.nil?
|
31
|
-
dir
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def dump_mongo
|
37
|
-
puts "Backup of #{feature(:mongo).data_dir} is not supported for remote databases." \
|
38
|
-
' Doing dump instead... '
|
39
|
-
with_spinner('Getting dump of Mongo DB') do
|
40
|
-
feature(:mongo).dump(File.join(@backup_dir, 'mongo_dump'))
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def local_backup
|
45
|
-
with_spinner('Collecting Mongo data') do
|
46
|
-
feature(:mongo).backup_local(
|
47
|
-
File.join(@backup_dir, 'mongo_data.tar'),
|
48
|
-
:listed_incremental => File.join(@backup_dir, '.mongo.snar'),
|
49
|
-
:volume_size => @tar_volume_size,
|
50
|
-
:data_dir => data_dir
|
51
|
-
)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Online
|
3
|
-
class Mongo < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
description 'Backup Mongo online'
|
6
|
-
tags :backup
|
7
|
-
for_feature :mongo
|
8
|
-
preparation_steps do
|
9
|
-
[Checks::Mongo::DBUp.new, Checks::Mongo::ToolsInstalled.new]
|
10
|
-
end
|
11
|
-
param :backup_dir, 'Directory where to backup to', :required => true
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
with_spinner('Getting dump of Mongo DB') do
|
16
|
-
feature(:mongo).dump(File.join(@backup_dir, 'mongo_dump'))
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'procedures/backup/snapshot/mount_base'
|
2
|
-
module Procedures::Backup
|
3
|
-
module Snapshot
|
4
|
-
class MountMongo < MountBase
|
5
|
-
metadata do
|
6
|
-
description 'Create and mount snapshot of Mongo DB'
|
7
|
-
tags :backup
|
8
|
-
for_feature :mongo
|
9
|
-
preparation_steps do
|
10
|
-
unless feature(:mongo).local?
|
11
|
-
[Checks::Mongo::DBUp.new, Checks::Mongo::ToolsInstalled.new]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
MountBase.common_params(self)
|
15
|
-
param :backup_dir, 'Directory where to backup to'
|
16
|
-
end
|
17
|
-
|
18
|
-
def run
|
19
|
-
if feature(:mongo).local?
|
20
|
-
mount_local
|
21
|
-
else
|
22
|
-
puts 'LV snapshots are not supported for remote databases. Doing dump instead...'
|
23
|
-
with_spinner('Getting dump of Mongo DB') do
|
24
|
-
feature(:mongo).dump(File.join(@backup_dir, 'mongo_dump'))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def mount_local
|
32
|
-
with_spinner('Creating snapshot of Mongo DB') do |spinner|
|
33
|
-
feature(:mongo).with_marked_directory(feature(:mongo).data_dir) do
|
34
|
-
lv_info = get_lv_info(feature(:mongo).data_dir)
|
35
|
-
create_lv_snapshot('mongodb-snap', @block_size, lv_info[0])
|
36
|
-
spinner.update("Mounting snapshot of Mongo DB on #{mount_location('mongodb')}")
|
37
|
-
mount_snapshot('mongodb', lv_info[1])
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Procedures::Candlepin
|
2
|
-
class DeleteOrphanedRecordsFromEnvContent < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Delete orphaned record(s) from cp_env_content with unresolvable content'
|
5
|
-
label :candlepin_delete_orphaned_records_from_env_content
|
6
|
-
|
7
|
-
confine do
|
8
|
-
feature(:candlepin_database) &&
|
9
|
-
feature(:satellite) && feature(:satellite).current_minor_version == '6.2'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def run
|
14
|
-
if feature(:candlepin_database).table_exist?('cp_env_content')
|
15
|
-
with_spinner('Deleting cp_env_content record(s) with unresolvable content') do |spinner|
|
16
|
-
spinner.update 'Finding cp_env_content records with unresolvable content'
|
17
|
-
env_content_ids = feature(:candlepin_database).env_content_ids_with_null_content
|
18
|
-
if env_content_ids.empty?
|
19
|
-
spinner.update 'No orphaned records found'
|
20
|
-
else
|
21
|
-
backup_and_delete_records(spinner, env_content_ids)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def backup_and_delete_records(spinner, env_content_ids)
|
30
|
-
spinner.update 'Taking a backup of the candlepin database'
|
31
|
-
feature(:candlepin_database).perform_backup
|
32
|
-
|
33
|
-
puts "Total #{env_content_ids.length} records with unresolvable content"
|
34
|
-
spinner.update 'Deleting record(s) from cp_env_content table'
|
35
|
-
feature(:candlepin_database).delete_records_by_ids(
|
36
|
-
'cp_env_content', env_content_ids
|
37
|
-
)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Procedures::Content
|
2
|
-
class FixPulpcoreArtifactOwnership < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Fix Pulpcore artifact ownership to be pulp:pulp'
|
5
|
-
param :assumeyes, 'Do not ask for confirmation', :default => false
|
6
|
-
|
7
|
-
confine do
|
8
|
-
check_min_version(foreman_plugin_name('katello'), '4.0') &&
|
9
|
-
Dir.exist?('/var/lib/pulp/media/artifact')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def ask_to_proceed
|
14
|
-
question = "\nWARNING: Only proceed if your system is fully switched to Pulp 3.\n"
|
15
|
-
question += "\n\nDo you want to proceed?"
|
16
|
-
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
|
17
|
-
abort! if answer != :yes
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
22
|
-
|
23
|
-
ask_to_proceed unless assumeyes_val
|
24
|
-
|
25
|
-
with_spinner('Updating artifact ownership for Pulp 3') do |spinner|
|
26
|
-
spinner.update('# chown -hR pulp.pulp /var/lib/pulp/media/artifact')
|
27
|
-
FileUtils.chown_R 'pulp', 'pulp', '/var/lib/pulp/media/artifact'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Procedures::Content
|
2
|
-
class MigrationReset < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Reset the Pulp 2 to Pulp 3 migration data (pre-switchover)'
|
5
|
-
for_feature :pulpcore
|
6
|
-
end
|
7
|
-
|
8
|
-
def run
|
9
|
-
puts execute!('foreman-rake katello:pulp3_migration_reset')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Procedures::Content
|
2
|
-
class MigrationStats < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Retrieve Pulp 2 to Pulp 3 migration statistics'
|
5
|
-
for_feature :pulpcore
|
6
|
-
end
|
7
|
-
|
8
|
-
def run
|
9
|
-
puts execute!('foreman-rake katello:pulp3_migration_stats')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Procedures::Content
|
2
|
-
class Prepare < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Prepare content for Pulp 3'
|
5
|
-
for_feature :pulpcore
|
6
|
-
param :quiet, 'Keep the output on a single line', :flag => true, :default => false
|
7
|
-
do_not_whitelist
|
8
|
-
end
|
9
|
-
|
10
|
-
def run
|
11
|
-
sleep(20) # in satellite 6.9 the services are still coming up
|
12
|
-
# use interactive to get realtime output
|
13
|
-
env_vars = @quiet ? '' : 'preserve_output=true '
|
14
|
-
execute!("#{env_vars}foreman-rake katello:pulp3_migration", :interactive => true)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Procedures::Content
|
2
|
-
class PrepareAbort < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Abort all running Pulp 2 to Pulp 3 migration tasks'
|
5
|
-
for_feature :pulpcore
|
6
|
-
end
|
7
|
-
|
8
|
-
def run
|
9
|
-
puts execute!('foreman-rake katello:pulp3_migration_abort')
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Procedures::Content
|
2
|
-
class Switchover < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Switch support for certain content from Pulp 2 to Pulp 3'
|
5
|
-
for_feature :pulpcore
|
6
|
-
|
7
|
-
confine do
|
8
|
-
!check_min_version(foreman_plugin_name('katello'), '4.0')
|
9
|
-
end
|
10
|
-
|
11
|
-
param :skip_deb, 'Do not run debian options in installer.'
|
12
|
-
do_not_whitelist
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
puts 'Performing final content migration before switching content'
|
17
|
-
puts execute!('foreman-rake katello:pulp3_migration')
|
18
|
-
puts 'Performing a check to verify everything that is needed has been migrated'
|
19
|
-
puts execute!('foreman-rake katello:pulp3_post_migration_check')
|
20
|
-
puts 'Switching specified content over to pulp 3'
|
21
|
-
puts execute!('foreman-rake katello:pulp3_content_switchover')
|
22
|
-
run_installer if feature(:katello_install)
|
23
|
-
end
|
24
|
-
|
25
|
-
def run_installer
|
26
|
-
puts 'Re-running the installer to switch specified content over to pulp3'
|
27
|
-
args = ['--foreman-proxy-content-proxy-pulp-isos-to-pulpcore=true',
|
28
|
-
'--foreman-proxy-content-proxy-pulp-yum-to-pulpcore=true',
|
29
|
-
'--katello-use-pulp-2-for-file=false',
|
30
|
-
'--katello-use-pulp-2-for-docker=false',
|
31
|
-
'--katello-use-pulp-2-for-yum=false']
|
32
|
-
|
33
|
-
unless @skip_deb
|
34
|
-
args += ['--katello-use-pulp-2-for-deb=false',
|
35
|
-
'--foreman-proxy-content-proxy-pulp-deb-to-pulpcore=true']
|
36
|
-
end
|
37
|
-
|
38
|
-
feature(:installer).run(args.join(' '))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class Procedures::Prep610Upgrade < ForemanMaintain::Procedure
|
2
|
-
metadata do
|
3
|
-
description 'Preparations for the Satellite 6.10 upgrade'
|
4
|
-
|
5
|
-
confine do
|
6
|
-
feature(:satellite) &&
|
7
|
-
feature(:satellite).current_minor_version == '6.9'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
puts time_warning
|
13
|
-
with_spinner('Updating filesystem permissions for Pulp 3') do |spinner|
|
14
|
-
spinner.update('# chmod -R g=rwX /var/lib/pulp/content')
|
15
|
-
FileUtils.chmod_R 'g=rwX', '/var/lib/pulp/content'
|
16
|
-
spinner.update("# find /var/lib/pulp/content -type d \! -perm -g+s -exec chmod g+s {} +")
|
17
|
-
execute!('find /var/lib/pulp/content -type d \! -perm -g+s -exec chmod g+s {} +')
|
18
|
-
spinner.update('# chgrp -R pulp /var/lib/pulp/content')
|
19
|
-
FileUtils.chown_R nil, 'pulp', '/var/lib/pulp/content'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def time_warning
|
26
|
-
"\e[33mprep-6.10-upgrade may take a while depending on the "\
|
27
|
-
"size of /var/lib/pulp/content\e[0m"
|
28
|
-
end
|
29
|
-
end
|
@@ -1,75 +0,0 @@
|
|
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
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Procedures::Pulp
|
2
|
-
class Migrate < ForemanMaintain::Procedure
|
3
|
-
include ForemanMaintain::Concerns::SystemService
|
4
|
-
|
5
|
-
metadata do
|
6
|
-
description 'Migrate pulp db'
|
7
|
-
for_feature :pulp2
|
8
|
-
end
|
9
|
-
|
10
|
-
def run
|
11
|
-
with_spinner('Migrating pulp') do |spinner|
|
12
|
-
necessary_services = feature(:mongo).services + [system_service('qpidd', 10)]
|
13
|
-
pulp_services = %w[pulp_celerybeat pulp_workers pulp_resource_manager]
|
14
|
-
|
15
|
-
feature(:service).handle_services(spinner, 'start', :only => necessary_services)
|
16
|
-
feature(:service).handle_services(spinner, 'stop', :only => pulp_services)
|
17
|
-
|
18
|
-
spinner.update('Migrating pulp database')
|
19
|
-
execute!('su - apache -s /bin/bash -c pulp-manage-db')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|