foreman_maintain 0.6.0 → 0.6.5
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 +5 -5
- data/README.md +4 -0
- data/definitions/checks/check_hotfix_installed.rb +2 -1
- data/definitions/checks/disk/performance.rb +24 -9
- data/definitions/checks/foreman/check_corrupted_roles.rb +14 -2
- data/definitions/checks/foreman/validate_external_db_version.rb +28 -0
- data/definitions/checks/original_assets.rb +1 -0
- data/definitions/checks/pulpcore/db_up.rb +29 -0
- data/definitions/checks/repositories/check_non_rh_repository.rb +23 -0
- data/definitions/checks/repositories/check_upstream_repository.rb +2 -1
- data/definitions/checks/repositories/validate.rb +2 -1
- data/definitions/features/apache.rb +19 -0
- data/definitions/features/dynflow_sidekiq.rb +1 -1
- data/definitions/features/foreman_database.rb +5 -3
- data/definitions/features/foreman_server.rb +9 -3
- data/definitions/features/foreman_tasks.rb +7 -2
- data/definitions/features/installer.rb +9 -2
- data/definitions/features/instance.rb +5 -2
- data/definitions/features/katello.rb +7 -0
- data/definitions/features/{pulp3.rb → pulpcore.rb} +9 -3
- data/definitions/features/pulpcore_database.rb +39 -0
- data/definitions/features/puppet_server.rb +6 -2
- data/definitions/features/service.rb +10 -3
- data/definitions/features/tar.rb +5 -0
- data/definitions/procedures/backup/config_files.rb +3 -0
- data/definitions/procedures/backup/metadata.rb +2 -0
- data/definitions/procedures/backup/offline/pulpcore_db.rb +57 -0
- data/definitions/procedures/backup/online/pulpcore_db.rb +20 -0
- data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +1 -0
- data/definitions/procedures/backup/snapshot/mount_pulpcore_db.rb +48 -0
- data/definitions/procedures/content/prepare.rb +2 -2
- data/definitions/procedures/content/switchover.rb +22 -0
- data/definitions/procedures/hammer_setup.rb +1 -1
- data/definitions/procedures/installer/run.rb +3 -1
- data/definitions/procedures/installer/upgrade.rb +6 -1
- data/definitions/procedures/packages/installer_confirmation.rb +1 -1
- data/definitions/procedures/packages/update.rb +1 -1
- data/definitions/procedures/packages/update_all_confirmation.rb +24 -0
- data/definitions/procedures/pulpcore/migrate.rb +25 -0
- data/definitions/procedures/restore/configs.rb +6 -0
- data/definitions/procedures/restore/drop_databases.rb +11 -1
- data/definitions/procedures/restore/extract_files.rb +1 -0
- data/definitions/procedures/restore/pulpcore_dump.rb +30 -0
- data/definitions/procedures/restore/regenerate_queues.rb +69 -0
- data/definitions/procedures/service/stop.rb +1 -1
- data/definitions/scenarios/backup.rb +21 -4
- data/definitions/scenarios/content.rb +27 -0
- data/definitions/scenarios/packages.rb +38 -14
- data/definitions/scenarios/restore.rb +10 -2
- data/definitions/scenarios/upgrade_to_capsule_6_7.rb +88 -0
- data/definitions/scenarios/upgrade_to_capsule_6_7_z.rb +88 -0
- data/definitions/scenarios/upgrade_to_capsule_6_8.rb +88 -0
- data/definitions/scenarios/upgrade_to_capsule_6_8_z.rb +88 -0
- data/definitions/scenarios/upgrade_to_satellite_6_2.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_3.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_4.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_4_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_5.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_5_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_6.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_6_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_7.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_7_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_8.rb +88 -0
- data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +88 -0
- data/extras/foreman_protector/foreman-protector.py +1 -1
- data/lib/foreman_maintain.rb +31 -0
- data/lib/foreman_maintain/cli.rb +2 -0
- data/lib/foreman_maintain/cli/content_command.rb +17 -0
- data/lib/foreman_maintain/cli/packages_command.rb +1 -1
- data/lib/foreman_maintain/cli/upgrade_command.rb +10 -0
- data/lib/foreman_maintain/concerns/base_database.rb +16 -1
- data/lib/foreman_maintain/concerns/downstream.rb +14 -10
- data/lib/foreman_maintain/feature.rb +4 -0
- data/lib/foreman_maintain/package_manager/dnf.rb +11 -5
- data/lib/foreman_maintain/package_manager/yum.rb +15 -5
- data/lib/foreman_maintain/reporter/cli_reporter.rb +6 -6
- data/lib/foreman_maintain/upgrade_runner.rb +20 -26
- data/lib/foreman_maintain/utils/backup.rb +62 -62
- data/lib/foreman_maintain/utils/disk/io_device.rb +1 -1
- data/lib/foreman_maintain/utils/facter.rb +1 -1
- data/lib/foreman_maintain/utils/service/abstract.rb +6 -0
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +184 -165
- data/definitions/checks/check_epel_repository.rb +0 -21
@@ -29,7 +29,7 @@ class Features::PuppetServer < ForemanMaintain::Feature
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def puppet_version
|
32
|
-
version(execute!(
|
32
|
+
version(execute!("#{puppet_path} --version"))
|
33
33
|
end
|
34
34
|
|
35
35
|
def find_empty_cacert_request_files
|
@@ -56,6 +56,10 @@ class Features::PuppetServer < ForemanMaintain::Feature
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def puppet_ssldir_path
|
59
|
-
execute!(
|
59
|
+
execute!("#{puppet_path} config print ssldir")
|
60
|
+
end
|
61
|
+
|
62
|
+
def puppet_path
|
63
|
+
'/opt/puppetlabs/bin/puppet'
|
60
64
|
end
|
61
65
|
end
|
@@ -27,7 +27,7 @@ class Features::Service < ForemanMaintain::Feature
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def filtered_services(options)
|
30
|
-
service_list = existing_services
|
30
|
+
service_list = include_unregistered_services(existing_services, options[:include])
|
31
31
|
service_list = filter_services(service_list, options)
|
32
32
|
raise 'No services found matching your parameters' unless service_list.any?
|
33
33
|
|
@@ -99,9 +99,14 @@ class Features::Service < ForemanMaintain::Feature
|
|
99
99
|
%w[start stop restart status enable disable].include?(action)
|
100
100
|
end
|
101
101
|
|
102
|
-
def
|
103
|
-
service_list
|
102
|
+
def extend_service_list_with_sockets(service_list, options)
|
103
|
+
return service_list unless options[:include_sockets]
|
104
|
+
|
105
|
+
socket_list = service_list.map(&:socket).compact.select(&:exist?)
|
106
|
+
service_list + socket_list
|
107
|
+
end
|
104
108
|
|
109
|
+
def filter_services(service_list, options)
|
105
110
|
if options[:only] && options[:only].any?
|
106
111
|
service_list = service_list.select do |service|
|
107
112
|
options[:only].any? { |opt| service.matches?(opt) }
|
@@ -112,6 +117,8 @@ class Features::Service < ForemanMaintain::Feature
|
|
112
117
|
if options[:exclude] && options[:exclude].any?
|
113
118
|
service_list = service_list.reject { |service| options[:exclude].include?(service.name) }
|
114
119
|
end
|
120
|
+
|
121
|
+
service_list = extend_service_list_with_sockets(service_list, options)
|
115
122
|
service_list.sort
|
116
123
|
end
|
117
124
|
|
data/definitions/features/tar.rb
CHANGED
@@ -38,6 +38,7 @@ class Features::Tar < ForemanMaintain::Feature
|
|
38
38
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
39
39
|
def tar_command(options)
|
40
40
|
volume_size = options.fetch(:volume_size, nil)
|
41
|
+
absolute_names = options.fetch(:absolute_names, nil)
|
41
42
|
validate_volume_size(volume_size) unless volume_size.nil?
|
42
43
|
|
43
44
|
tar_command = ['tar']
|
@@ -45,6 +46,10 @@ class Features::Tar < ForemanMaintain::Feature
|
|
45
46
|
tar_command << "--#{options.fetch(:command, 'create')}"
|
46
47
|
tar_command << "--file=#{options.fetch(:archive)}"
|
47
48
|
|
49
|
+
if absolute_names
|
50
|
+
tar_command << '--absolute-names'
|
51
|
+
end
|
52
|
+
|
48
53
|
if volume_size
|
49
54
|
split_tar_script = default_split_tar_script
|
50
55
|
tar_command << "--tape-length=#{volume_size}"
|
@@ -17,6 +17,8 @@ module Procedures::Backup
|
|
17
17
|
:array => true, :default => ['all']
|
18
18
|
param :ignore_changed_files, 'Should packing tar ignore changed files',
|
19
19
|
:flag => true, :default => false
|
20
|
+
param :online_backup, 'The config files are being prepared for an online backup',
|
21
|
+
:flag => true, :default => false
|
20
22
|
end
|
21
23
|
|
22
24
|
# rubocop:disable Metrics/MethodLength
|
@@ -55,6 +57,7 @@ module Procedures::Backup
|
|
55
57
|
|
56
58
|
configs += feature.config_files
|
57
59
|
exclude_configs += feature.config_files_to_exclude
|
60
|
+
exclude_configs += feature.config_files_exclude_for_online if @online_backup
|
58
61
|
end
|
59
62
|
|
60
63
|
if feature(:foreman_proxy)
|
@@ -6,6 +6,7 @@ module Procedures::Backup
|
|
6
6
|
preparation_steps { Checks::Foreman::DBUp.new if feature(:foreman_server) }
|
7
7
|
param :backup_dir, 'Directory where to backup to', :required => true
|
8
8
|
param :incremental_dir, 'Changes since specified backup only'
|
9
|
+
param :online_backup, 'Select for online backup', :flag => true, :default => false
|
9
10
|
end
|
10
11
|
|
11
12
|
def run
|
@@ -16,6 +17,7 @@ module Procedures::Backup
|
|
16
17
|
metadata['proxy_features'] = proxy_feature_list(spinner) || []
|
17
18
|
metadata['rpms'] = rpms(spinner)
|
18
19
|
metadata['incremental'] = @incremental_dir || false
|
20
|
+
metadata['online'] = @online_backup
|
19
21
|
save_metadata(metadata, spinner)
|
20
22
|
end
|
21
23
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Procedures::Backup
|
2
|
+
module Offline
|
3
|
+
class PulpcoreDB < ForemanMaintain::Procedure
|
4
|
+
metadata do
|
5
|
+
description 'Backup Pulpcore DB offline'
|
6
|
+
tags :backup
|
7
|
+
label :backup_offline_pulpcore_db
|
8
|
+
for_feature :pulpcore_database
|
9
|
+
preparation_steps { Checks::Pulpcore::DBUp.new unless feature(:pulpcore_database).local? }
|
10
|
+
param :backup_dir, 'Directory where to backup to', :required => true
|
11
|
+
param :tar_volume_size, 'Size of tar volume (indicates splitting)'
|
12
|
+
param :mount_dir, 'Snapshot mount directory'
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
if feature(:pulpcore_database).local?
|
17
|
+
if File.exist?(pg_backup_file)
|
18
|
+
puts 'Already done'
|
19
|
+
else
|
20
|
+
local_backup
|
21
|
+
end
|
22
|
+
else
|
23
|
+
puts "Backup of #{pg_data_dir} is not supported for remote databases." \
|
24
|
+
' Doing postgres dump instead...'
|
25
|
+
with_spinner('Getting Pulpcore DB dump') do
|
26
|
+
feature(:pulpcore_database).dump_db(File.join(@backup_dir, 'pulpcore.dump'))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def local_backup
|
34
|
+
with_spinner("Collecting data from #{pg_data_dir}") do
|
35
|
+
feature(:pulpcore_database).backup_local(
|
36
|
+
pg_backup_file,
|
37
|
+
:listed_incremental => File.join(@backup_dir, '.postgres.snar'),
|
38
|
+
:volume_size => @tar_volume_size,
|
39
|
+
:data_dir => pg_data_dir
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def pg_backup_file
|
45
|
+
File.join(@backup_dir, 'pgsql_data.tar')
|
46
|
+
end
|
47
|
+
|
48
|
+
def pg_data_dir
|
49
|
+
return feature(:pulpcore_database).data_dir if @mount_dir.nil?
|
50
|
+
mount_point = File.join(@mount_dir, 'pgsql')
|
51
|
+
dir = feature(:pulpcore_database).find_base_directory(mount_point)
|
52
|
+
fail!("Snapshot of Pulpcore DB was not found mounted in #{mount_point}") if dir.nil?
|
53
|
+
dir
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Procedures::Backup
|
2
|
+
module Online
|
3
|
+
class PulpcoreDB < ForemanMaintain::Procedure
|
4
|
+
metadata do
|
5
|
+
description 'Backup Pulpcore database online'
|
6
|
+
tags :backup
|
7
|
+
label :backup_online_pulpcore_db
|
8
|
+
for_feature :pulpcore_database
|
9
|
+
preparation_steps { Checks::Pulpcore::DBUp.new }
|
10
|
+
param :backup_dir, 'Directory where to backup to', :required => true
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
with_spinner('Getting Pulpcore DB dump') do
|
15
|
+
feature(:pulpcore_database).dump_db(File.join(@backup_dir, 'pulpcore.dump'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -16,6 +16,7 @@ module Procedures::Backup
|
|
16
16
|
dbs[:mongo] = 'Mongo' if db_local?(:mongo)
|
17
17
|
dbs[:candlepin_database] = 'Candlepin' if db_local?(:candlepin_database)
|
18
18
|
dbs[:foreman_database] = 'Foreman' if db_local?(:foreman_database)
|
19
|
+
dbs[:pulpcore_database] = 'Pulpcore' if db_local?(:pulpcore_database)
|
19
20
|
|
20
21
|
shared_lv = dbs.inject([]) do |list, (db_label, db_name)|
|
21
22
|
db_lv = get_lv_info(feature(db_label).data_dir)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'procedures/backup/snapshot/mount_base'
|
2
|
+
module Procedures::Backup
|
3
|
+
module Snapshot
|
4
|
+
class MountPulpcoreDB < MountBase
|
5
|
+
metadata do
|
6
|
+
description 'Create and mount snapshot of Pulpcore DB'
|
7
|
+
tags :backup
|
8
|
+
label :backup_snapshot_mount_pulpcore_db
|
9
|
+
for_feature :pulpcore_database
|
10
|
+
preparation_steps { Checks::Pulpcore::DBUp.new unless feature(:pulpcore_database).local? }
|
11
|
+
MountBase.common_params(self)
|
12
|
+
param :backup_dir, 'Directory where to backup to'
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
if feature(:pulpcore_database).local?
|
17
|
+
snapshot
|
18
|
+
else
|
19
|
+
dump_pulpcore
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def dump_pulpcore
|
26
|
+
puts 'LV snapshots are not supported for remote databases. Doing postgres dump instead... '
|
27
|
+
with_spinner('Getting Pulpcore DB dump') do
|
28
|
+
feature(:pulpcore_database).dump_db(File.join(@backup_dir, 'pulpcore.dump'))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def snapshot
|
33
|
+
mount_point = mount_location('pgsql')
|
34
|
+
FileUtils.mkdir_p(mount_point) unless File.directory?(mount_point)
|
35
|
+
if directory_empty?(mount_point)
|
36
|
+
with_spinner('Creating snapshot of Postgres') do |spinner|
|
37
|
+
lv_info = get_lv_info(feature(:pulpcore_database).data_dir)
|
38
|
+
create_lv_snapshot('pgsql-snap', @block_size, lv_info[0])
|
39
|
+
spinner.update("Mounting snapshot of Postgres on #{mount_point}")
|
40
|
+
mount_snapshot('pgsql', lv_info[1])
|
41
|
+
end
|
42
|
+
else
|
43
|
+
puts 'Snapshot of Postgres is already mounted'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -2,11 +2,11 @@ module Procedures::Content
|
|
2
2
|
class Prepare < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
4
|
description 'Prepare content for Pulp 3'
|
5
|
-
for_feature :
|
5
|
+
for_feature :pulpcore
|
6
6
|
end
|
7
7
|
|
8
8
|
def run
|
9
|
-
execute!('foreman-rake katello:pulp3_migration')
|
9
|
+
puts execute!('foreman-rake katello:pulp3_migration')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -0,0 +1,22 @@
|
|
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
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
puts 'Performing final content migration before switching content'
|
10
|
+
puts execute!('foreman-rake katello:pulp3_migration')
|
11
|
+
puts 'Performing a check to verify everything that is needed has been migrated'
|
12
|
+
puts execute!('foreman-rake katello:pulp3_post_migration_check')
|
13
|
+
puts 'Switching specified content over to pulp 3'
|
14
|
+
puts execute!('foreman-rake katello:pulp3_content_switchover')
|
15
|
+
puts 'Re-running the installer to switch specified content over to pulp3'
|
16
|
+
args = ['--foreman-proxy-content-proxy-pulp-isos-to-pulpcore=true',
|
17
|
+
'--katello-use-pulp-2-for-file=false',
|
18
|
+
'--katello-use-pulp-2-for-docker=false']
|
19
|
+
feature(:installer).run(args.join(' '))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -5,7 +5,7 @@ class Procedures::HammerSetup < ForemanMaintain::Procedure
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run
|
8
|
-
if feature(:foreman_server) &&
|
8
|
+
if feature(:foreman_server) && feature(:foreman_server).services_running?
|
9
9
|
puts 'Configuring Hammer CLI...'
|
10
10
|
result = feature(:hammer).setup_admin_access
|
11
11
|
logger.info 'Hammer was configured successfully.' if result
|
@@ -2,10 +2,12 @@ module Procedures::Installer
|
|
2
2
|
class Run < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
4
|
param :arguments, 'Arguments passed to installer'
|
5
|
+
param :assumeyes, 'Do not ask for confirmation'
|
5
6
|
end
|
6
7
|
|
7
8
|
def run
|
8
|
-
|
9
|
+
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
10
|
+
feature(:installer).run(@arguments, :interactive => !assumeyes_val)
|
9
11
|
end
|
10
12
|
|
11
13
|
def description
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Procedures::Installer
|
2
2
|
class Upgrade < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
param :assumeyes, 'Do not ask for confirmation'
|
5
|
+
end
|
6
|
+
|
3
7
|
def run
|
4
|
-
|
8
|
+
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
9
|
+
feature(:installer).run(@arguments, :interactive => !assumeyes_val)
|
5
10
|
end
|
6
11
|
end
|
7
12
|
end
|
@@ -5,7 +5,7 @@ module Procedures::Packages
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run
|
8
|
-
question = "
|
8
|
+
question = "\nWARNING: This script runs #{feature(:installer).installer_command} " \
|
9
9
|
"after the yum execution \n" \
|
10
10
|
"to ensure the #{feature(:instance).product_name} " \
|
11
11
|
"is in a consistent state.\n" \
|
@@ -10,7 +10,7 @@ module Procedures::Packages
|
|
10
10
|
|
11
11
|
def run
|
12
12
|
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
13
|
-
package_manager.clean_cache
|
13
|
+
package_manager.clean_cache(:assumeyes => assumeyes_val)
|
14
14
|
packages_action(:update, @packages, :assumeyes => assumeyes_val)
|
15
15
|
rescue ForemanMaintain::Error::ExecutionError => e
|
16
16
|
if @warn_on_errors
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Procedures::Packages
|
2
|
+
class UpdateAllConfirmation < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
param :packages, 'List of packages to update', :array => true
|
5
|
+
|
6
|
+
description 'Confirm update all is intentional'
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
if @packages.nil? || @packages.empty?
|
11
|
+
question = "\nWARNING: No specific packages to update were provided\n" \
|
12
|
+
"so we are going to update all available packages.\n" \
|
13
|
+
"It is recommended to update everything only as part of upgrade\n" \
|
14
|
+
"of the #{feature(:instance).product_name} to the next version. \n" \
|
15
|
+
"To Upgrade to next version use 'foreman-maintain upgrade'.\n\n" \
|
16
|
+
"NOTE: --assumeyes is not applicable for this check\n\n" \
|
17
|
+
"Do you want to proceed with update of everything regardless\n" \
|
18
|
+
'of the recommendations?'
|
19
|
+
answer = ask_decision(question, 'y(yes), q(quit)', ignore_assumeyes: true)
|
20
|
+
abort! unless answer == :yes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Procedures::Pulpcore
|
2
|
+
class Migrate < ForemanMaintain::Procedure
|
3
|
+
include ForemanMaintain::Concerns::SystemService
|
4
|
+
|
5
|
+
metadata do
|
6
|
+
description 'Migrate pulpcore db'
|
7
|
+
for_feature :pulpcore
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
with_spinner('Migrating pulpcore') do |spinner|
|
12
|
+
necessary_services = feature(:pulpcore_database).services
|
13
|
+
pulp_services = feature(:pulpcore).services
|
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 pulpcore database')
|
19
|
+
execute!('sudo PULP_SETTINGS=/etc/pulp/settings.py '\
|
20
|
+
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings '\
|
21
|
+
'python3-django-admin migrate --noinput')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -19,10 +19,15 @@ module Procedures::Restore
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# rubocop:disable Metrics/MethodLength
|
22
23
|
def restore_configs(backup)
|
23
24
|
exclude = ForemanMaintain.available_features.each_with_object([]) do |feat, cfgs|
|
25
|
+
if backup.online_backup?
|
26
|
+
feat.config_files_exclude_for_online.each { |f| cfgs << f.gsub(%r{^/}, '') }
|
27
|
+
end
|
24
28
|
feat.config_files_to_exclude.each { |f| cfgs << f.gsub(%r{^/}, '') }
|
25
29
|
end
|
30
|
+
|
26
31
|
tar_options = {
|
27
32
|
:overwrite => true,
|
28
33
|
:listed_incremental => '/dev/null',
|
@@ -35,6 +40,7 @@ module Procedures::Restore
|
|
35
40
|
|
36
41
|
feature(:tar).run(tar_options)
|
37
42
|
end
|
43
|
+
# rubocop:enable Metrics/MethodLength
|
38
44
|
|
39
45
|
def reload_configs
|
40
46
|
feature(:mongo).reload_db_config if feature(:mongo)
|
@@ -8,7 +8,7 @@ module Procedures::Restore
|
|
8
8
|
:required => true
|
9
9
|
|
10
10
|
confine do
|
11
|
-
feature(:foreman_database) || feature(:candlepin_database)
|
11
|
+
feature(:foreman_database) || feature(:candlepin_database) || feature(:pulpcore_database)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -19,6 +19,9 @@ module Procedures::Restore
|
|
19
19
|
feature(:service).handle_services(spinner, 'start', :only => ['postgresql'])
|
20
20
|
drop_foreman(backup, spinner)
|
21
21
|
drop_candlepin(backup, spinner)
|
22
|
+
if feature(:pulpcore)
|
23
|
+
drop_pulpcore(backup, spinner)
|
24
|
+
end
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
@@ -35,5 +38,12 @@ module Procedures::Restore
|
|
35
38
|
feature(:candlepin_database).dropdb
|
36
39
|
end
|
37
40
|
end
|
41
|
+
|
42
|
+
def drop_pulpcore(backup, spinner)
|
43
|
+
if backup.file_map[:pulpcore_dump][:present]
|
44
|
+
spinner.update('Dropping pulpcore database')
|
45
|
+
feature(:pulpcore_database).dropdb
|
46
|
+
end
|
47
|
+
end
|
38
48
|
end
|
39
49
|
end
|