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
@@ -11,15 +11,15 @@ module ForemanMaintain::Scenarios
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
14
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
14
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
15
15
|
def compose
|
16
16
|
backup = ForemanMaintain::Utils::Backup.new(context.get(:backup_dir))
|
17
17
|
|
18
18
|
add_steps(find_checks(:root_user))
|
19
|
-
supported_version_check
|
20
19
|
add_steps_with_context(Checks::Restore::ValidateBackup,
|
21
|
-
|
22
|
-
|
20
|
+
Checks::Restore::ValidateHostname,
|
21
|
+
Checks::Restore::ValidateInterfaces,
|
22
|
+
Checks::Restore::ValidatePostgresqlDumpPermissions)
|
23
23
|
|
24
24
|
if context.get(:dry_run)
|
25
25
|
self.class.metadata[:run_strategy] = :fail_slow
|
@@ -27,12 +27,11 @@ module ForemanMaintain::Scenarios
|
|
27
27
|
end
|
28
28
|
|
29
29
|
add_steps_with_context(Procedures::Restore::Confirmation,
|
30
|
-
|
31
|
-
|
30
|
+
Procedures::Selinux::SetFileSecurity,
|
31
|
+
Procedures::Restore::Configs)
|
32
32
|
add_step_with_context(Procedures::Crond::Stop) if feature(:cron)
|
33
33
|
unless backup.incremental?
|
34
|
-
add_steps_with_context(Procedures::Restore::
|
35
|
-
Procedures::Restore::InstallerReset)
|
34
|
+
add_steps_with_context(Procedures::Restore::InstallerReset)
|
36
35
|
end
|
37
36
|
add_step_with_context(Procedures::Service::Stop)
|
38
37
|
add_steps_with_context(Procedures::Restore::ExtractFiles) if backup.tar_backups_exist?
|
@@ -44,25 +43,24 @@ module ForemanMaintain::Scenarios
|
|
44
43
|
if backup.sql_dump_files_exist? && feature(:instance).postgresql_local?
|
45
44
|
add_step(Procedures::Service::Stop.new(:only => ['postgresql']))
|
46
45
|
end
|
47
|
-
restore_mongo_dump(backup)
|
48
46
|
|
49
47
|
if feature(:instance).postgresql_local? && !backup.online_backup?
|
50
48
|
add_step_with_context(Procedures::Restore::ReindexDatabases)
|
51
49
|
end
|
52
50
|
|
53
|
-
add_steps_with_context(
|
54
|
-
|
55
|
-
|
51
|
+
add_steps_with_context(
|
52
|
+
Procedures::Pulpcore::Migrate,
|
53
|
+
Procedures::Restore::CandlepinResetMigrations
|
54
|
+
)
|
56
55
|
|
57
|
-
add_steps_with_context(Procedures::Restore::RegenerateQueues) if backup.online_backup?
|
58
56
|
add_steps_with_context(Procedures::Service::Start,
|
59
|
-
|
57
|
+
Procedures::Service::DaemonReload)
|
60
58
|
add_step(Procedures::Installer::Upgrade.new(:assumeyes => true))
|
61
59
|
add_step_with_context(Procedures::Installer::UpgradeRakeTask)
|
62
60
|
add_step_with_context(Procedures::Crond::Start) if feature(:cron)
|
63
61
|
end
|
64
62
|
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize
|
65
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
63
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
66
64
|
|
67
65
|
def drop_dbs(backup)
|
68
66
|
if backup.file_map[:candlepin_dump][:present] ||
|
@@ -84,35 +82,21 @@ module ForemanMaintain::Scenarios
|
|
84
82
|
end
|
85
83
|
end
|
86
84
|
|
87
|
-
def restore_mongo_dump(backup)
|
88
|
-
if backup.file_map[:mongo_dump][:present]
|
89
|
-
add_steps_with_context(Procedures::Restore::MongoDump)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def supported_version_check
|
94
|
-
if feature(:instance).downstream && feature(:instance).downstream.less_than_version?('6.3')
|
95
|
-
msg = 'ERROR: Restore subcommand is supported by Satellite 6.3+. ' \
|
96
|
-
'Please use katello-restore instead.'
|
97
|
-
abort(msg)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
85
|
def set_context_mapping
|
102
86
|
context.map(:backup_dir,
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
87
|
+
Checks::Restore::ValidateBackup => :backup_dir,
|
88
|
+
Checks::Restore::ValidateHostname => :backup_dir,
|
89
|
+
Checks::Restore::ValidateInterfaces => :backup_dir,
|
90
|
+
Checks::Restore::ValidatePostgresqlDumpPermissions => :backup_dir,
|
91
|
+
Procedures::Restore::Configs => :backup_dir,
|
92
|
+
Procedures::Restore::DropDatabases => :backup_dir,
|
93
|
+
Procedures::Restore::CandlepinDump => :backup_dir,
|
94
|
+
Procedures::Restore::ForemanDump => :backup_dir,
|
95
|
+
Procedures::Restore::PulpcoreDump => :backup_dir,
|
96
|
+
Procedures::Restore::ExtractFiles => :backup_dir)
|
113
97
|
|
114
98
|
context.map(:incremental_backup,
|
115
|
-
|
99
|
+
Procedures::Selinux::SetFileSecurity => :incremental_backup)
|
116
100
|
end
|
117
101
|
end
|
118
102
|
|
@@ -26,18 +26,14 @@ module ForemanMaintain::Scenarios
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def maintenance_repo(version)
|
29
|
-
|
30
|
-
"rhel-#{el_major_version}-server-satellite-maintenance-#{version}-rpms"
|
31
|
-
else
|
32
|
-
"satellite-maintenance-#{version}-for-rhel-#{el_major_version}-x86_64-rpms"
|
33
|
-
end
|
29
|
+
"satellite-maintenance-#{version}-for-rhel-#{el_major_version}-x86_64-rpms"
|
34
30
|
end
|
35
31
|
|
36
32
|
def use_rhsm?
|
37
33
|
return false if maintenance_repo_label
|
38
34
|
|
39
|
-
if (repo = ENV['MAINTENANCE_REPO_LABEL'])
|
40
|
-
return false
|
35
|
+
if (repo = ENV['MAINTENANCE_REPO_LABEL']) && !repo.empty?
|
36
|
+
return false
|
41
37
|
end
|
42
38
|
|
43
39
|
true
|
@@ -64,7 +60,7 @@ module ForemanMaintain::Scenarios
|
|
64
60
|
metadata do
|
65
61
|
label :self_upgrade_foreman_maintain
|
66
62
|
description "Enables the specified version's maintenance repository and,"\
|
67
|
-
|
63
|
+
"\nupdates the satellite-maintain packages"
|
68
64
|
manual_detection
|
69
65
|
end
|
70
66
|
|
@@ -76,7 +72,7 @@ module ForemanMaintain::Scenarios
|
|
76
72
|
"--enablerepo=#{id}"
|
77
73
|
end
|
78
74
|
add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
|
79
|
-
|
75
|
+
yum_options: yum_options))
|
80
76
|
end
|
81
77
|
end
|
82
78
|
|
@@ -94,14 +90,14 @@ module ForemanMaintain::Scenarios
|
|
94
90
|
|
95
91
|
def rollback_repositories
|
96
92
|
installed_release_pkg = package_manager.find_installed_package('foreman-release',
|
97
|
-
|
93
|
+
'%{VERSION}')
|
98
94
|
|
99
95
|
unless current_version.nil? && installed_release_pkg.nil?
|
100
96
|
current_major_version = current_version[0..2]
|
101
97
|
installed_foreman_release_major_version = installed_release_pkg[0..2]
|
102
98
|
if installed_foreman_release_major_version != current_major_version
|
103
99
|
add_step(Procedures::Packages::Uninstall.new(packages: %w[foreman-release katello-repos],
|
104
|
-
|
100
|
+
assumeyes: true))
|
105
101
|
add_step(Procedures::Repositories::Setup.new(:version => current_major_version))
|
106
102
|
end
|
107
103
|
end
|
@@ -14,13 +14,13 @@ module ForemanMaintain::Scenarios
|
|
14
14
|
|
15
15
|
def set_context_mapping
|
16
16
|
context.map(:only,
|
17
|
-
|
17
|
+
Procedures::Service::Restart => :only)
|
18
18
|
|
19
19
|
context.map(:exclude,
|
20
|
-
|
20
|
+
Procedures::Service::Restart => :exclude)
|
21
21
|
|
22
22
|
context.map(:wait_for_server_response,
|
23
|
-
|
23
|
+
Procedures::Service::Restart => :wait_for_server_response)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -39,10 +39,10 @@ module ForemanMaintain::Scenarios
|
|
39
39
|
|
40
40
|
def set_context_mapping
|
41
41
|
context.map(:only,
|
42
|
-
|
42
|
+
Procedures::Service::Stop => :only)
|
43
43
|
|
44
44
|
context.map(:exclude,
|
45
|
-
|
45
|
+
Procedures::Service::Stop => :exclude)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -61,10 +61,10 @@ module ForemanMaintain::Scenarios
|
|
61
61
|
|
62
62
|
def set_context_mapping
|
63
63
|
context.map(:only,
|
64
|
-
|
64
|
+
Procedures::Service::Start => :only)
|
65
65
|
|
66
66
|
context.map(:exclude,
|
67
|
-
|
67
|
+
Procedures::Service::Start => :exclude)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -82,10 +82,10 @@ module ForemanMaintain::Scenarios
|
|
82
82
|
|
83
83
|
def set_context_mapping
|
84
84
|
context.map(:only,
|
85
|
-
|
85
|
+
Procedures::Service::List => :only)
|
86
86
|
|
87
87
|
context.map(:exclude,
|
88
|
-
|
88
|
+
Procedures::Service::List => :exclude)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -104,10 +104,10 @@ module ForemanMaintain::Scenarios
|
|
104
104
|
|
105
105
|
def set_context_mapping
|
106
106
|
context.map(:only,
|
107
|
-
|
107
|
+
Procedures::Service::Enable => :only)
|
108
108
|
|
109
109
|
context.map(:exclude,
|
110
|
-
|
110
|
+
Procedures::Service::Enable => :exclude)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -126,10 +126,10 @@ module ForemanMaintain::Scenarios
|
|
126
126
|
|
127
127
|
def set_context_mapping
|
128
128
|
context.map(:only,
|
129
|
-
|
129
|
+
Procedures::Service::Disable => :only)
|
130
130
|
|
131
131
|
context.map(:exclude,
|
132
|
-
|
132
|
+
Procedures::Service::Disable => :exclude)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
@@ -147,16 +147,16 @@ module ForemanMaintain::Scenarios
|
|
147
147
|
|
148
148
|
def set_context_mapping
|
149
149
|
context.map(:only,
|
150
|
-
|
150
|
+
Procedures::Service::Status => :only)
|
151
151
|
|
152
152
|
context.map(:exclude,
|
153
|
-
|
153
|
+
Procedures::Service::Status => :exclude)
|
154
154
|
|
155
155
|
context.map(:brief,
|
156
|
-
|
156
|
+
Procedures::Service::Status => :brief)
|
157
157
|
|
158
158
|
context.map(:failing,
|
159
|
-
|
159
|
+
Procedures::Service::Status => :failing)
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
@@ -17,12 +17,6 @@ boost-random
|
|
17
17
|
boost-iostreams
|
18
18
|
boost-thread
|
19
19
|
yum-utils
|
20
|
-
# el7 psql client dependencies
|
21
|
-
rh-postgresql12-postgresql
|
22
|
-
rh-postgresql12-postgresql-libs
|
23
|
-
rh-postgresql12-postgresql-syspaths
|
24
|
-
rh-postgresql12-runtime
|
25
|
-
scl-utils
|
26
20
|
# el8 psql client dependencies
|
27
21
|
postgresql
|
28
22
|
libpq
|
@@ -9,7 +9,7 @@ module ForemanMaintain
|
|
9
9
|
answers = feature(:installer).configuration[:answer_file]
|
10
10
|
comp_map[:expire] = {
|
11
11
|
:file => answers,
|
12
|
-
:sha1sum => execute!("sha1sum #{answers}")
|
12
|
+
:sha1sum => execute!("sha1sum #{answers}"),
|
13
13
|
}
|
14
14
|
cache_dir = File.dirname(ForemanMaintain.config.completion_cache_file)
|
15
15
|
FileUtils.mkdir_p(cache_dir) unless File.directory?(cache_dir)
|
@@ -6,8 +6,8 @@ module ForemanMaintain
|
|
6
6
|
class AdvancedCommand < Base
|
7
7
|
subcommand 'procedure', 'Run maintain procedures manually', ProcedureCommand
|
8
8
|
subcommand 'prebuild-bash-completion',
|
9
|
-
|
10
|
-
|
9
|
+
'Prepare map of options and subcommands for Bash completion',
|
10
|
+
PrebuildBashCompletionCommand
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -33,20 +33,20 @@ module ForemanMaintain
|
|
33
33
|
def common_backup_options
|
34
34
|
# TODO: BACKUP_DIR in f-m config - should be default?
|
35
35
|
parameter 'BACKUP_DIR', 'Path to backup dir',
|
36
|
-
|
37
|
-
|
36
|
+
:completion => { :type => :directory },
|
37
|
+
:attribute_name => :backup_root_dir do |dir|
|
38
38
|
File.expand_path(dir)
|
39
39
|
end
|
40
40
|
option ['-s', '--skip-pulp-content'], :flag, 'Do not backup Pulp content'
|
41
41
|
option ['-p', '--preserve-directory'], :flag, 'Do not create a time-stamped subdirectory'
|
42
42
|
option ['-t', '--split-pulp-tar'], 'SPLIT_SIZE',
|
43
|
-
|
44
|
-
|
43
|
+
'Split pulp data into files of a specified size, i.e. (100M, 50G). ' \
|
44
|
+
"See '--tape-length' in 'info tar' for all sizes" do |size|
|
45
45
|
self.class.valid_tape_size(size)
|
46
46
|
end
|
47
47
|
option ['-i', '--incremental'], 'PREVIOUS_BACKUP_DIR',
|
48
|
-
|
49
|
-
|
48
|
+
'Backup changes since previous backup',
|
49
|
+
:completion => { :type => :directory } do |dir|
|
50
50
|
unless File.directory?(dir)
|
51
51
|
raise ArgumentError, "Previous backup directory does not exist: #{dir}"
|
52
52
|
end
|
@@ -55,8 +55,8 @@ module ForemanMaintain
|
|
55
55
|
end
|
56
56
|
proxy_name = ForemanMaintain.detector.feature(:capsule) ? 'Capsule' : 'Foreman Proxy'
|
57
57
|
option '--features', 'FEATURES',
|
58
|
-
|
59
|
-
|
58
|
+
"#{proxy_name} features to include in the backup. " \
|
59
|
+
'Valid features are tftp, dns, dhcp, openscap, and all.', :multivalued => true
|
60
60
|
end
|
61
61
|
# rubocop:enable Metrics/MethodLength
|
62
62
|
|
@@ -76,7 +76,7 @@ module ForemanMaintain
|
|
76
76
|
Scenarios::BackupRescueCleanup.new({
|
77
77
|
:backup_dir => backup_dir,
|
78
78
|
:strategy => strategy,
|
79
|
-
:preserve_dir => preserve_directory
|
79
|
+
:preserve_dir => preserve_directory?,
|
80
80
|
}.merge(options))
|
81
81
|
end
|
82
82
|
|
@@ -88,7 +88,7 @@ module ForemanMaintain
|
|
88
88
|
:proxy_features => features,
|
89
89
|
:tar_volume_size => split_pulp_tar,
|
90
90
|
:skip_pulp_content => skip_pulp_content?,
|
91
|
-
:incremental_dir => incremental
|
91
|
+
:incremental_dir => incremental,
|
92
92
|
}.merge(options))
|
93
93
|
end
|
94
94
|
|
@@ -123,7 +123,7 @@ module ForemanMaintain
|
|
123
123
|
|
124
124
|
def execute
|
125
125
|
perform_backup(:offline,
|
126
|
-
|
126
|
+
:include_db_dumps => include_db_dumps?)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -133,21 +133,21 @@ module ForemanMaintain
|
|
133
133
|
common_backup_options
|
134
134
|
option '--include-db-dumps', :flag, 'Also dump full database schema before snapshot backup'
|
135
135
|
option ['-d', '--snapshot-mount-dir'], 'SNAPSHOT_MOUNT_DIR',
|
136
|
-
|
137
|
-
|
136
|
+
"Override default directory ('/var/snap/') where the snapshots will be mounted",
|
137
|
+
:default => '/var/snap/' do |dir|
|
138
138
|
unless File.directory?(dir)
|
139
139
|
raise ArgumentError, "Snapshot mount directory does not exist: #{dir}"
|
140
140
|
end
|
141
141
|
dir
|
142
142
|
end
|
143
143
|
option ['-b', '--snapshot-block-size'], 'SNAPSHOT_BLOCK_SIZE',
|
144
|
-
|
144
|
+
'Override default block size (2G)', :default => '2G'
|
145
145
|
|
146
146
|
def execute
|
147
147
|
perform_backup(:snapshot,
|
148
|
-
|
149
|
-
|
150
|
-
|
148
|
+
:snapshot_mount_dir => snapshot_mount_dir,
|
149
|
+
:snapshot_block_size => snapshot_block_size,
|
150
|
+
:include_db_dumps => include_db_dumps?)
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -57,10 +57,10 @@ module ForemanMaintain
|
|
57
57
|
def run_scenario(scenarios, rescue_scenario = nil)
|
58
58
|
@runner ||=
|
59
59
|
ForemanMaintain::Runner.new(reporter, scenarios,
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
:assumeyes => option_wrapper('assumeyes?'),
|
61
|
+
:whitelist => option_wrapper('whitelist') || [],
|
62
|
+
:force => option_wrapper('force?'),
|
63
|
+
:rescue_scenario => rescue_scenario)
|
64
64
|
runner.run
|
65
65
|
end
|
66
66
|
|
@@ -135,8 +135,8 @@ module ForemanMaintain
|
|
135
135
|
|
136
136
|
def self.label_option
|
137
137
|
option '--label', 'label',
|
138
|
-
|
139
|
-
|
138
|
+
'Run only a specific check with a label. ' \
|
139
|
+
'(Use "list" command to see available labels)' do |label|
|
140
140
|
raise ArgumentError, 'value not specified' if label.nil? || label.empty?
|
141
141
|
underscorize(label).to_sym
|
142
142
|
end
|
@@ -144,9 +144,9 @@ module ForemanMaintain
|
|
144
144
|
|
145
145
|
def self.tags_option
|
146
146
|
option('--tags', 'tags',
|
147
|
-
|
148
|
-
|
149
|
-
|
147
|
+
'Run only those with all specific set of tags. ' \
|
148
|
+
'(Use list-tags command to see available tags)',
|
149
|
+
:multivalued => true) do |tags|
|
150
150
|
raise ArgumentError, 'value not specified' if tags.nil? || tags.empty?
|
151
151
|
tags.map { |tag| underscorize(tag).to_sym }
|
152
152
|
end
|
@@ -158,14 +158,14 @@ module ForemanMaintain
|
|
158
158
|
|
159
159
|
if opts.include?('assumeyes')
|
160
160
|
option ['-y', '--assumeyes'], :flag,
|
161
|
-
|
161
|
+
'Automatically answer yes for all questions' do |assume|
|
162
162
|
ForemanMaintain.reporter.assumeyes = assume
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
166
|
if opts.include?('whitelist')
|
167
167
|
option(['-w', '--whitelist'], 'whitelist',
|
168
|
-
|
168
|
+
'Comma-separated list of labels of steps to be skipped') do |whitelist|
|
169
169
|
raise ArgumentError, 'value not specified' if whitelist.nil? || whitelist.empty?
|
170
170
|
whitelist.split(',').map(&:strip)
|
171
171
|
end
|
@@ -173,12 +173,12 @@ module ForemanMaintain
|
|
173
173
|
|
174
174
|
if opts.include?('force')
|
175
175
|
option ['-f', '--force'], :flag,
|
176
|
-
|
176
|
+
'Force steps that would be skipped as they were already run'
|
177
177
|
end
|
178
178
|
|
179
179
|
if opts.include?('plaintext')
|
180
180
|
option(['--plaintext'], :flag,
|
181
|
-
|
181
|
+
'Print the output in plaintext and disable the spinner') do |plaintext|
|
182
182
|
ForemanMaintain.reporter.plaintext = plaintext
|
183
183
|
end
|
184
184
|
end
|
@@ -42,7 +42,7 @@ module ForemanMaintain
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def fetch_procedure(scenario, procedure_class_name)
|
45
|
-
scenario.steps.find { |procedure| procedure.
|
45
|
+
scenario.steps.find { |procedure| procedure.instance_of?(procedure_class_name) }
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -3,7 +3,7 @@ module ForemanMaintain
|
|
3
3
|
class PluginCommand < Base
|
4
4
|
subcommand 'purge-puppet', 'Remove the Puppet feature' do
|
5
5
|
option ['-f', '--remove-all-data'], :flag, 'Purge all the Puppet data',
|
6
|
-
|
6
|
+
:attribute_name => :remove_data
|
7
7
|
|
8
8
|
def execute
|
9
9
|
run_scenarios_and_exit(Scenarios::Puppet::RemovePuppet.new(:remove_data => remove_data?))
|
@@ -3,13 +3,13 @@ module ForemanMaintain
|
|
3
3
|
class RestoreCommand < Base
|
4
4
|
interactive_option
|
5
5
|
parameter 'BACKUP_DIR', 'Path to backup directory to restore',
|
6
|
-
|
6
|
+
:attribute_name => :backup_dir, :completion => { :type => :directory }
|
7
7
|
|
8
8
|
option ['-i', '--incremental'], :flag, 'Restore an incremental backup',
|
9
|
-
|
9
|
+
:attribute_name => :incremental, :completion => { :type => :directory }
|
10
10
|
option ['-n', '--dry-run'], :flag,
|
11
|
-
|
12
|
-
|
11
|
+
'Check if backup could be restored, without performing the restore',
|
12
|
+
:attribute_name => :dry_run
|
13
13
|
|
14
14
|
def execute
|
15
15
|
scenario = Scenarios::Restore.new(
|
@@ -2,8 +2,8 @@ module ForemanMaintain
|
|
2
2
|
module Cli
|
3
3
|
class SelfUpgradeCommand < Base
|
4
4
|
option ['--maintenance-repo-label'], 'REPOSITORY_LABEL',\
|
5
|
-
|
6
|
-
|
5
|
+
'Repository label from which packages should be updated.'\
|
6
|
+
'This can be used when standard CDN repositories are unavailable.'
|
7
7
|
def execute
|
8
8
|
run_scenario(upgrade_scenario)
|
9
9
|
end
|
@@ -35,8 +35,8 @@ module ForemanMaintain
|
|
35
35
|
service_options
|
36
36
|
if feature(:katello)
|
37
37
|
option ['-p', '--wait-for-server-response', '--wait-for-hammer-ping'], :flag,
|
38
|
-
|
39
|
-
|
38
|
+
'Wait for hammer ping to return successfully before terminating',
|
39
|
+
:attribute_name => :wait_for_server_response
|
40
40
|
end
|
41
41
|
|
42
42
|
def execute
|
@@ -3,20 +3,20 @@ module ForemanMaintain
|
|
3
3
|
class UpgradeCommand < Base
|
4
4
|
def self.target_version_option
|
5
5
|
option '--target-version', 'TARGET_VERSION', 'Target version of the upgrade',
|
6
|
-
|
6
|
+
:required => false
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.disable_self_upgrade_option
|
10
10
|
option '--disable-self-upgrade', :flag, 'Disable automatic self upgrade',
|
11
|
-
|
11
|
+
:default => false
|
12
12
|
end
|
13
13
|
|
14
14
|
def current_target_version
|
15
15
|
current_target_version = ForemanMaintain::UpgradeRunner.current_target_version
|
16
16
|
if current_target_version && target_version && target_version != current_target_version
|
17
17
|
raise Error::UsageError,
|
18
|
-
|
19
|
-
|
18
|
+
"Can't set target version #{target_version}, "\
|
19
|
+
"#{current_target_version} already in progress"
|
20
20
|
end
|
21
21
|
@target_version = current_target_version if current_target_version
|
22
22
|
return true if current_target_version
|
@@ -43,9 +43,9 @@ module ForemanMaintain
|
|
43
43
|
return @upgrade_runner if defined? @upgrade_runner
|
44
44
|
validate_target_version!
|
45
45
|
@upgrade_runner = ForemanMaintain::UpgradeRunner.new(target_version, reporter,
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
:assumeyes => assumeyes?,
|
47
|
+
:whitelist => whitelist || [],
|
48
|
+
:force => force?).tap(&:load)
|
49
49
|
end
|
50
50
|
|
51
51
|
def print_versions(target_versions)
|
data/lib/foreman_maintain/cli.rb
CHANGED
@@ -10,7 +10,6 @@ require 'foreman_maintain/cli/service_command'
|
|
10
10
|
require 'foreman_maintain/cli/restore_command'
|
11
11
|
require 'foreman_maintain/cli/maintenance_mode_command'
|
12
12
|
require 'foreman_maintain/cli/packages_command'
|
13
|
-
require 'foreman_maintain/cli/content_command'
|
14
13
|
require 'foreman_maintain/cli/plugin_command'
|
15
14
|
require 'foreman_maintain/cli/self_upgrade_command'
|
16
15
|
|
@@ -26,19 +25,10 @@ module ForemanMaintain
|
|
26
25
|
subcommand 'restore', 'Restore a backup', RestoreCommand
|
27
26
|
subcommand 'packages', 'Lock/Unlock package protection, install, update', PackagesCommand
|
28
27
|
subcommand 'advanced', 'Advanced tools for server maintenance', AdvancedCommand
|
29
|
-
subcommand 'content', 'Content related commands', ContentCommand
|
30
28
|
subcommand 'plugin', 'Manage optional plugins on your server', PluginCommand
|
31
29
|
subcommand 'self-upgrade', 'Perform major version self upgrade', SelfUpgradeCommand
|
32
30
|
subcommand 'maintenance-mode', 'Control maintenance-mode for application',
|
33
|
-
|
34
|
-
if ForemanMaintain.detector.feature(:satellite) &&
|
35
|
-
ForemanMaintain.detector.feature(:satellite).current_minor_version == '6.9'
|
36
|
-
subcommand 'prep-6.10-upgrade', 'Preparations for the Satellite 6.10 upgrade' do
|
37
|
-
def execute
|
38
|
-
run_scenarios_and_exit(Scenarios::Prep610Upgrade.new)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
31
|
+
MaintenanceModeCommand
|
42
32
|
|
43
33
|
def run(*arguments)
|
44
34
|
logger.info("Running foreman-maintain command with arguments #{arguments.inspect}")
|