foreman_maintain 1.5.0 → 1.6.0
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/README.md +0 -20
- data/definitions/checks/disk/available_space_candlepin.rb +1 -1
- data/definitions/checks/disk/available_space_postgresql13.rb +42 -0
- data/definitions/checks/foreman/check_corrupted_roles.rb +0 -3
- data/definitions/checks/foreman/validate_external_db_version.rb +1 -2
- data/definitions/features/foreman_proxy.rb +2 -10
- data/definitions/features/foreman_tasks.rb +2 -6
- data/definitions/features/installer.rb +0 -4
- data/definitions/features/pulpcore_database.rb +1 -1
- data/definitions/procedures/backup/offline/candlepin_db.rb +1 -6
- data/definitions/procedures/backup/offline/foreman_db.rb +1 -8
- data/definitions/procedures/backup/offline/pulpcore_db.rb +1 -6
- data/definitions/procedures/backup/pulp.rb +1 -10
- data/definitions/procedures/foreman/fix_corrupted_roles.rb +0 -3
- data/definitions/procedures/packages/update.rb +7 -2
- data/definitions/procedures/puppet/remove_puppet.rb +1 -2
- data/definitions/procedures/restore/installer_reset.rb +1 -17
- data/definitions/scenarios/backup.rb +5 -88
- data/definitions/scenarios/packages.rb +2 -2
- data/definitions/scenarios/puppet.rb +4 -6
- data/definitions/scenarios/restore.rb +1 -1
- data/definitions/scenarios/upgrade_to_capsule_6_16.rb +14 -8
- data/definitions/scenarios/upgrade_to_capsule_6_16_z.rb +12 -8
- data/definitions/scenarios/upgrade_to_foreman_nightly.rb +3 -3
- data/definitions/scenarios/upgrade_to_katello_nightly.rb +11 -7
- data/definitions/scenarios/upgrade_to_satellite_6_16.rb +13 -8
- data/definitions/scenarios/upgrade_to_satellite_6_16_z.rb +12 -8
- data/lib/foreman_maintain/cli/backup_command.rb +0 -27
- data/lib/foreman_maintain/cli.rb +2 -0
- data/lib/foreman_maintain/concerns/base_database.rb +0 -4
- data/lib/foreman_maintain/concerns/downstream.rb +0 -4
- data/lib/foreman_maintain/concerns/os_facts.rb +4 -0
- data/lib/foreman_maintain/concerns/system_helpers.rb +0 -12
- data/lib/foreman_maintain/package_manager/dnf.rb +1 -1
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +1 -1
- metadata +3 -15
- data/definitions/checks/disk/available_space_postgresql12.rb +0 -46
- data/definitions/procedures/backup/snapshot/clean_mount.rb +0 -24
- data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +0 -56
- data/definitions/procedures/backup/snapshot/mount_base.rb +0 -27
- data/definitions/procedures/backup/snapshot/mount_candlepin_db.rb +0 -48
- data/definitions/procedures/backup/snapshot/mount_foreman_db.rb +0 -48
- data/definitions/procedures/backup/snapshot/mount_pulp.rb +0 -32
- data/definitions/procedures/backup/snapshot/mount_pulpcore_db.rb +0 -48
- data/definitions/procedures/backup/snapshot/prepare_mount.rb +0 -16
- data/definitions/procedures/backup/snapshot/snapshot_deprecation_message.rb +0 -14
- data/definitions/procedures/foreman/remove_duplicate_obsolete_roles.rb +0 -64
- data/definitions/procedures/installer/run_for_6_11.rb +0 -52
- data/definitions/procedures/installer/upgrade.rb +0 -12
@@ -1,48 +0,0 @@
|
|
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
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Snapshot
|
3
|
-
class PrepareMount < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
description 'Prepare mount point for the snapshot'
|
6
|
-
tags :backup
|
7
|
-
param :mount_dir, 'Snapshot mount directory', :required => true
|
8
|
-
end
|
9
|
-
|
10
|
-
def run
|
11
|
-
logger.debug("Creating snap dir: #{@mount_dir}")
|
12
|
-
FileUtils.mkdir_p @mount_dir
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Procedures::Backup
|
2
|
-
module Snapshot
|
3
|
-
class SnapshotDeprecationMessage < ForemanMaintain::Procedure
|
4
|
-
metadata do
|
5
|
-
description 'Snapshot backups are deprecated'
|
6
|
-
tags :backup
|
7
|
-
end
|
8
|
-
|
9
|
-
def run
|
10
|
-
set_warn('Snapshot backups are deprecated and will be removed in a future version.')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Procedures::Foreman
|
2
|
-
class RemoveDuplicateObsoleteRoles < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
for_feature :foreman_database
|
5
|
-
description 'Remove duplicate obsolete roles from DB'
|
6
|
-
confine do
|
7
|
-
check_max_version('foreman', '1.20')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
duplicate_roles = feature(:foreman_database).query(
|
13
|
-
Checks::Foreman::CheckDuplicateRoles.query_to_get_duplicate_roles
|
14
|
-
)
|
15
|
-
roles_hash = duplicate_roles.each_with_object({}) do |role_rec, new_obj|
|
16
|
-
r_name = role_rec['name']
|
17
|
-
new_obj[r_name] = [] unless new_obj.key?(r_name)
|
18
|
-
new_obj[r_name] << role_rec['id'].to_i
|
19
|
-
end
|
20
|
-
duplicate_role_ids = filter_consumed_roles(roles_hash)
|
21
|
-
remove_obsolete_role_records(duplicate_role_ids) unless duplicate_role_ids.empty?
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def filter_consumed_roles(roles_hash)
|
27
|
-
consumed_role_ids = find_consumed_role_ids
|
28
|
-
roles_hash.values.map do |ids|
|
29
|
-
consumed_ids = ids & consumed_role_ids
|
30
|
-
if consumed_ids.count == 1
|
31
|
-
ids -= consumed_ids
|
32
|
-
elsif consumed_ids.count > 1
|
33
|
-
ids -= consumed_ids
|
34
|
-
update_duplicate_consumed_roles(consumed_ids)
|
35
|
-
elsif ids.length > 1
|
36
|
-
ids.delete(ids.min)
|
37
|
-
end
|
38
|
-
ids
|
39
|
-
end.flatten
|
40
|
-
end
|
41
|
-
|
42
|
-
def find_consumed_role_ids
|
43
|
-
feature(:foreman_database).query(<<-SQL).map { |r| r['role_id'].to_i }
|
44
|
-
select DISTINCT(role_id) role_id from user_roles
|
45
|
-
SQL
|
46
|
-
end
|
47
|
-
|
48
|
-
def update_duplicate_consumed_roles(role_ids)
|
49
|
-
logger.info("Updating name of duplicate consumed roles using id(s): #{role_ids.join(', ')}")
|
50
|
-
|
51
|
-
feature(:foreman_database).psql(<<-SQL)
|
52
|
-
UPDATE roles set name = concat(name, ' - ', id) where id in (#{role_ids.join(', ')})
|
53
|
-
SQL
|
54
|
-
end
|
55
|
-
|
56
|
-
def remove_obsolete_role_records(role_ids)
|
57
|
-
feature(:foreman_database).psql(<<-SQL)
|
58
|
-
BEGIN;
|
59
|
-
DELETE from roles r where r.id IN (#{role_ids.join(', ')});
|
60
|
-
COMMIT;
|
61
|
-
SQL
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module Procedures::Installer
|
2
|
-
class RunFor6_11 < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'Run installer with Candlepin SSL CA'\
|
5
|
-
' when using external database with SSL'
|
6
|
-
param :assumeyes, 'Do not ask for confirmation'
|
7
|
-
manual_detection
|
8
|
-
end
|
9
|
-
|
10
|
-
def run
|
11
|
-
if extdb_and_ssl?
|
12
|
-
run_installer_with_extra_option
|
13
|
-
else
|
14
|
-
run_installer
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def ext_db?
|
19
|
-
!feature(:foreman_database).local?
|
20
|
-
end
|
21
|
-
|
22
|
-
def installer_answers
|
23
|
-
@installer_answers ||= feature(:installer).answers
|
24
|
-
end
|
25
|
-
|
26
|
-
def server_db_with_ssl?
|
27
|
-
installer_answers.fetch('katello')['candlepin_db_ssl']
|
28
|
-
end
|
29
|
-
|
30
|
-
def extdb_and_ssl?
|
31
|
-
ext_db? && server_db_with_ssl?
|
32
|
-
end
|
33
|
-
|
34
|
-
def run_installer_with_extra_option
|
35
|
-
ssl_ca_path = installer_answers.fetch('foreman')['db_root_cert']
|
36
|
-
spinner_msg = "Running installer with --katello-candlepin-db-ssl-ca #{ssl_ca_path} argument!"
|
37
|
-
with_spinner(spinner_msg) do
|
38
|
-
installer_args = feature(:installer).installer_arguments
|
39
|
-
new_ssl_arg = " --katello-candlepin-db-ssl-ca #{ssl_ca_path}"
|
40
|
-
installer_args << new_ssl_arg
|
41
|
-
feature(:installer).run(installer_args)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def run_installer
|
46
|
-
with_spinner('Executing installer') do
|
47
|
-
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
48
|
-
feature(:installer).upgrade(:interactive => !assumeyes_val)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Procedures::Installer
|
2
|
-
class Upgrade < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
param :assumeyes, 'Do not ask for confirmation'
|
5
|
-
end
|
6
|
-
|
7
|
-
def run
|
8
|
-
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
9
|
-
feature(:installer).upgrade(:interactive => !assumeyes_val)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|