foreman_maintain 1.3.0 → 1.3.2
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/backup/directory_ready.rb +3 -1
- 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 +3 -7
- 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 +6 -30
- 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 +6 -2
- data/definitions/procedures/pulpcore/migrate.rb +2 -3
- data/definitions/procedures/pulpcore/trim_rpm_changelogs.rb +2 -3
- 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 +2 -3
- data/definitions/scenarios/backup.rb +47 -65
- 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/definitions/scenarios/upgrade_to_capsule_6_14.rb +3 -2
- data/definitions/scenarios/upgrade_to_capsule_6_14_z.rb +3 -2
- data/definitions/scenarios/upgrade_to_katello_nightly.rb +3 -0
- data/definitions/scenarios/upgrade_to_satellite_6_14.rb +3 -2
- data/definitions/scenarios/upgrade_to_satellite_6_14_z.rb +3 -2
- data/extras/foreman_protector/dnf/foreman-protector.py +4 -4
- 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 +5 -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 +7 -7
- 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 +3 -4
- data/lib/foreman_maintain/package_manager.rb +7 -9
- 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 +7 -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 +7 -6
- 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
@@ -2,17 +2,17 @@ require 'fileutils'
|
|
2
2
|
module ForemanMaintain
|
3
3
|
class Config
|
4
4
|
attr_accessor :pre_setup_log_messages,
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
:config_file, :definitions_dirs, :log_level, :log_dir, :log_file_size,
|
6
|
+
:log_filename, :storage_file, :backup_dir, :foreman_proxy_cert_path,
|
7
|
+
:db_backup_dir, :completion_cache_file, :disable_commands, :manage_crond,
|
8
|
+
:foreman_url, :foreman_port
|
9
9
|
|
10
10
|
def initialize(options)
|
11
11
|
@pre_setup_log_messages = []
|
12
12
|
@config_file = options.fetch(:config_file, config_file_path)
|
13
13
|
@options = load_config
|
14
14
|
@definitions_dirs = @options.fetch(:definitions_dirs,
|
15
|
-
|
15
|
+
[File.join(source_path, 'definitions')])
|
16
16
|
load_log_configs
|
17
17
|
load_backup_dir_paths
|
18
18
|
load_cron_option
|
@@ -28,7 +28,7 @@ module ForemanMaintain
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def load_log_configs
|
31
|
-
@log_level = @options.fetch(:log_level, ::Logger::
|
31
|
+
@log_level = @options.fetch(:log_level, ::Logger::INFO)
|
32
32
|
@log_dir = find_dir_path(@options.fetch(:log_dir, 'log'))
|
33
33
|
@log_file_size = @options.fetch(:log_file_size, 10_000)
|
34
34
|
# Note - If timestamp added to filename then number of log files i.e second
|
@@ -68,7 +68,7 @@ module ForemanMaintain
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def source_path
|
71
|
-
File.expand_path('
|
71
|
+
File.expand_path('../..', __dir__)
|
72
72
|
end
|
73
73
|
|
74
74
|
def find_dir_path(dir_path_str)
|
@@ -10,7 +10,7 @@ module ForemanMaintain
|
|
10
10
|
gsub(/^[ \t]{#{indent}}/, '')
|
11
11
|
end
|
12
12
|
end
|
13
|
-
String.
|
13
|
+
String.include StripHeredoc
|
14
14
|
|
15
15
|
module ValidateOptions
|
16
16
|
def validate_options!(*valid_keys)
|
@@ -23,6 +23,6 @@ module ForemanMaintain
|
|
23
23
|
self
|
24
24
|
end
|
25
25
|
end
|
26
|
-
Hash.
|
26
|
+
Hash.include ValidateOptions
|
27
27
|
end
|
28
28
|
end
|
@@ -3,10 +3,11 @@ module ForemanMaintain
|
|
3
3
|
extend Forwardable
|
4
4
|
extend Concerns::Finders
|
5
5
|
attr_reader :options
|
6
|
+
|
6
7
|
def_delegators :execution,
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
:success?, :skipped?, :fail?, :aborted?, :warning?, :output,
|
9
|
+
:assumeyes?, :whitelisted?, :ask_decision,
|
10
|
+
:execution, :puts, :print, :with_spinner, :ask, :storage
|
10
11
|
|
11
12
|
def initialize(options = {})
|
12
13
|
@options = options.inject({}) { |h, (k, v)| h.update(k.to_s => v) }
|
@@ -26,7 +27,8 @@ module ForemanMaintain
|
|
26
27
|
end
|
27
28
|
|
28
29
|
# public method to be overriden to perform after-initialization steps
|
29
|
-
def after_initialize
|
30
|
+
def after_initialize
|
31
|
+
end
|
30
32
|
|
31
33
|
# processes the params from provided options
|
32
34
|
def setup_params
|
@@ -113,11 +115,7 @@ module ForemanMaintain
|
|
113
115
|
end
|
114
116
|
|
115
117
|
def execution
|
116
|
-
|
117
|
-
@_execution
|
118
|
-
else
|
119
|
-
raise 'Trying to get execution information before the run started happened'
|
120
|
-
end
|
118
|
+
@_execution || raise('Trying to get execution information before the run started happened')
|
121
119
|
end
|
122
120
|
|
123
121
|
# public method to be overriden: it can perform additional checks
|
@@ -68,10 +68,10 @@ module ForemanMaintain::PackageManager
|
|
68
68
|
packages_s = packages.empty? ? '' : ' ' + packages.join(' ')
|
69
69
|
if with_status
|
70
70
|
sys.execute_with_status("apt-get#{apt_options_s} #{action}#{packages_s}",
|
71
|
-
|
71
|
+
:interactive => !assumeyes)
|
72
72
|
else
|
73
73
|
sys.execute!("apt-get#{apt_options_s} #{action}#{packages_s}",
|
74
|
-
|
74
|
+
:interactive => !assumeyes, :valid_exit_statuses => valid_exit_statuses)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module ForemanMaintain::PackageManager
|
2
|
-
# rubocop:disable Lint/UnusedMethodArgument
|
3
2
|
class Base
|
4
3
|
# confirms that Package Manager supports the locking mechanism
|
5
4
|
def version_locking_supported?
|
@@ -62,5 +61,4 @@ module ForemanMaintain::PackageManager
|
|
62
61
|
ForemanMaintain::Utils::SystemHelpers
|
63
62
|
end
|
64
63
|
end
|
65
|
-
# rubocop:enable Lint/UnusedMethodArgument
|
66
64
|
end
|
@@ -35,10 +35,10 @@ module ForemanMaintain::PackageManager
|
|
35
35
|
yum_options << '-y' if assumeyes
|
36
36
|
if with_status
|
37
37
|
sys.execute_with_status("dnf #{yum_options.join(' ')} #{action} #{packages.join(' ')}",
|
38
|
-
|
38
|
+
:interactive => !assumeyes)
|
39
39
|
else
|
40
40
|
sys.execute!("dnf #{yum_options.join(' ')} #{action} #{packages.join(' ')}",
|
41
|
-
|
41
|
+
:interactive => !assumeyes)
|
42
42
|
|
43
43
|
end
|
44
44
|
end
|
@@ -68,7 +68,7 @@ module ForemanMaintain::PackageManager
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def check_update(packages: nil, with_status: false)
|
71
|
-
yum_action('check-update', packages, :assumeyes => true, :valid_exit_statuses => [100],
|
71
|
+
yum_action('check-update', packages, :assumeyes => true, :valid_exit_statuses => [0, 100],
|
72
72
|
:with_status => with_status)
|
73
73
|
end
|
74
74
|
|
@@ -120,7 +120,6 @@ module ForemanMaintain::PackageManager
|
|
120
120
|
File.open(protector_config_file, 'w') { |file| file.puts config }
|
121
121
|
end
|
122
122
|
|
123
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
124
123
|
def yum_action(action, packages, options)
|
125
124
|
with_status = options.fetch(:with_status, false)
|
126
125
|
assumeyes = options.fetch(:assumeyes, false)
|
@@ -133,10 +132,10 @@ module ForemanMaintain::PackageManager
|
|
133
132
|
packages_s = packages.empty? ? '' : ' ' + packages.join(' ')
|
134
133
|
if with_status
|
135
134
|
sys.execute_with_status("yum#{yum_options_s} #{action}#{packages_s}",
|
136
|
-
|
135
|
+
:interactive => !assumeyes)
|
137
136
|
else
|
138
137
|
sys.execute!("yum#{yum_options_s} #{action}#{packages_s}",
|
139
|
-
|
138
|
+
:interactive => !assumeyes, :valid_exit_statuses => valid_exit_statuses)
|
140
139
|
end
|
141
140
|
end
|
142
141
|
end
|
@@ -5,14 +5,12 @@ require 'foreman_maintain/package_manager/apt'
|
|
5
5
|
|
6
6
|
module ForemanMaintain
|
7
7
|
def self.package_manager
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
raise 'No supported package manager was found'
|
16
|
-
end
|
8
|
+
if el?
|
9
|
+
ForemanMaintain::PackageManager::Dnf.new
|
10
|
+
elsif debian_or_ubuntu?
|
11
|
+
ForemanMaintain::PackageManager::Apt.new
|
12
|
+
else
|
13
|
+
raise 'No supported package manager was found'
|
14
|
+
end
|
17
15
|
end
|
18
16
|
end
|
@@ -4,7 +4,7 @@ module ForemanMaintain
|
|
4
4
|
|
5
5
|
def initialize(name, description, options, &block)
|
6
6
|
options.validate_options!(:description, :required, :flag, :array,
|
7
|
-
|
7
|
+
:allowed_values, :default)
|
8
8
|
@name = name
|
9
9
|
@description = description || options[:description] || ''
|
10
10
|
@options = options
|
@@ -63,7 +63,7 @@ module ForemanMaintain
|
|
63
63
|
return if within_allowed
|
64
64
|
error_msg = "'#{value}' not allowed for #{name} param."
|
65
65
|
raise ForemanMaintain::Error::UsageError,
|
66
|
-
|
66
|
+
"#{error_msg} Possible values are #{@allowed_values.join(', ')}"
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'thread'
|
2
1
|
require 'highline'
|
3
2
|
|
4
3
|
module ForemanMaintain
|
@@ -73,7 +72,7 @@ module ForemanMaintain
|
|
73
72
|
attr_accessor :select_option_counter
|
74
73
|
attr_reader :last_line, :max_length
|
75
74
|
|
76
|
-
def initialize(stdout =
|
75
|
+
def initialize(stdout = $stdout, stdin = $stdin, options = {})
|
77
76
|
@stdout = stdout
|
78
77
|
@stdin = stdin
|
79
78
|
options.validate_options!(:assumeyes)
|
@@ -127,9 +126,9 @@ module ForemanMaintain
|
|
127
126
|
@new_line_next_time = false
|
128
127
|
@last_line = ''
|
129
128
|
# add space at the end as otherwise highline would add new line there :/
|
130
|
-
message = "#{message} " unless
|
129
|
+
message = "#{message} " unless /\s\Z/.match?(message)
|
131
130
|
answer = @hl.ask(message) { |q| q.echo = false if options[:password] }
|
132
|
-
answer
|
131
|
+
answer&.to_s&.chomp
|
133
132
|
end
|
134
133
|
|
135
134
|
def new_line_if_needed
|
@@ -179,7 +178,7 @@ module ForemanMaintain
|
|
179
178
|
|
180
179
|
def single_step_decision(step, run_strategy)
|
181
180
|
answer = ask_decision("Continue with step [#{step.runtime_message}]?",
|
182
|
-
|
181
|
+
run_strategy: run_strategy)
|
183
182
|
if answer == :yes
|
184
183
|
step
|
185
184
|
else
|
@@ -339,13 +338,13 @@ module ForemanMaintain
|
|
339
338
|
|
340
339
|
In case the failures are false positives, use
|
341
340
|
--whitelist="%s"
|
342
|
-
|
341
|
+
MESSAGE
|
343
342
|
else
|
344
343
|
format(<<-MESSAGE.strip_heredoc, whitelist_labels)
|
345
344
|
Resolve the failed steps and rerun the command.
|
346
345
|
In case the failures are false positives, use
|
347
346
|
--whitelist="%s"
|
348
|
-
|
347
|
+
MESSAGE
|
349
348
|
end
|
350
349
|
end
|
351
350
|
end
|
@@ -10,17 +10,21 @@ module ForemanMaintain
|
|
10
10
|
DECISION_MAPPER = {
|
11
11
|
%w[y yes] => :yes,
|
12
12
|
%w[n next no] => :no,
|
13
|
-
%w[q quit] => :quit
|
13
|
+
%w[q quit] => :quit,
|
14
14
|
}.freeze
|
15
15
|
|
16
16
|
# Each public method is a hook called by executor at the specific point
|
17
|
-
def before_scenario_starts(_scenario, _last_scenario = nil)
|
17
|
+
def before_scenario_starts(_scenario, _last_scenario = nil)
|
18
|
+
end
|
18
19
|
|
19
|
-
def before_execution_starts(_execution)
|
20
|
+
def before_execution_starts(_execution)
|
21
|
+
end
|
20
22
|
|
21
|
-
def after_execution_finishes(_execution)
|
23
|
+
def after_execution_finishes(_execution)
|
24
|
+
end
|
22
25
|
|
23
|
-
def after_scenario_finishes(_scenario)
|
26
|
+
def after_scenario_finishes(_scenario)
|
27
|
+
end
|
24
28
|
|
25
29
|
def on_next_steps(steps, run_strategy = :fail_fast)
|
26
30
|
return if steps.empty?
|
@@ -36,11 +40,14 @@ module ForemanMaintain
|
|
36
40
|
yield DummySpinner.new
|
37
41
|
end
|
38
42
|
|
39
|
-
def print(_message)
|
43
|
+
def print(_message)
|
44
|
+
end
|
40
45
|
|
41
|
-
def puts(_message)
|
46
|
+
def puts(_message)
|
47
|
+
end
|
42
48
|
|
43
|
-
def ask(_message)
|
49
|
+
def ask(_message)
|
50
|
+
end
|
44
51
|
|
45
52
|
def assumeyes?
|
46
53
|
@assumeyes
|
@@ -100,7 +107,6 @@ module ForemanMaintain
|
|
100
107
|
decision
|
101
108
|
end
|
102
109
|
|
103
|
-
# rubocop:disable Metrics/MethodLength
|
104
110
|
def ask_to_select(message, steps, run_strategy)
|
105
111
|
if assumeyes?
|
106
112
|
puts('(assuming first option)')
|
@@ -122,7 +128,6 @@ module ForemanMaintain
|
|
122
128
|
end
|
123
129
|
end
|
124
130
|
end
|
125
|
-
# rubocop:enable Metrics/MethodLength
|
126
131
|
|
127
132
|
# loop over the block until it returns some non-false value
|
128
133
|
def until_valid_decision
|
@@ -4,11 +4,7 @@ module ForemanMaintain::RepositoryManager
|
|
4
4
|
include ForemanMaintain::Concerns::SystemHelpers
|
5
5
|
|
6
6
|
def disable_repos(repo_ids)
|
7
|
-
|
8
|
-
execute!("yum-config-manager #{config_manager_options(repo_ids, 'disable')}")
|
9
|
-
else
|
10
|
-
execute!("dnf config-manager #{config_manager_options(repo_ids, 'set-disabled')}")
|
11
|
-
end
|
7
|
+
execute!("dnf config-manager #{config_manager_options(repo_ids, 'set-disabled')}")
|
12
8
|
end
|
13
9
|
|
14
10
|
def rhsm_disable_repos(repo_ids)
|
@@ -22,11 +18,7 @@ module ForemanMaintain::RepositoryManager
|
|
22
18
|
end
|
23
19
|
|
24
20
|
def enable_repos(repo_ids)
|
25
|
-
|
26
|
-
execute!("yum-config-manager #{config_manager_options(repo_ids, 'enable')}")
|
27
|
-
else
|
28
|
-
execute!("dnf config-manager #{config_manager_options(repo_ids, 'enable')}")
|
29
|
-
end
|
21
|
+
execute!("dnf config-manager #{config_manager_options(repo_ids, 'enable')}")
|
30
22
|
end
|
31
23
|
|
32
24
|
def rhsm_enable_repos(repo_ids)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'foreman_maintain/repository_manager/el'
|
2
|
-
include ForemanMaintain::Concerns::OsFacts
|
3
2
|
module ForemanMaintain
|
3
|
+
extend ForemanMaintain::Concerns::OsFacts
|
4
|
+
|
4
5
|
def self.repository_manager
|
5
6
|
@repository_manager ||= if el?
|
6
7
|
ForemanMaintain::RepositoryManager::El.new
|
@@ -78,7 +78,7 @@ module ForemanMaintain
|
|
78
78
|
elsif @last_scenario.steps_with_warning(:whitelisted => false).any?
|
79
79
|
@last_scenario_continuation_confirmed = true
|
80
80
|
reporter.ask_decision("Continue with [#{scenario.description}]",
|
81
|
-
|
81
|
+
run_strategy: scenario.run_strategy)
|
82
82
|
end
|
83
83
|
|
84
84
|
ask_to_quit if [:quit, :no].include?(decision)
|
@@ -93,7 +93,7 @@ module ForemanMaintain
|
|
93
93
|
def add_steps(*steps)
|
94
94
|
# we we add the steps at the beginning, but still keeping the
|
95
95
|
# order of steps passed in the arguments
|
96
|
-
steps.
|
96
|
+
steps.reverse_each do |step|
|
97
97
|
@steps_to_run.unshift(step)
|
98
98
|
end
|
99
99
|
end
|
@@ -125,9 +125,9 @@ module ForemanMaintain
|
|
125
125
|
def run_step(step)
|
126
126
|
@reporter.puts('Rerunning the check after fix procedure') if rerun_check?(step)
|
127
127
|
execution = Execution.new(step, @reporter,
|
128
|
-
|
129
|
-
|
130
|
-
|
128
|
+
:whitelisted => whitelisted_step?(step),
|
129
|
+
:storage => storage,
|
130
|
+
:force => @force)
|
131
131
|
execution.run
|
132
132
|
execution
|
133
133
|
ensure
|
@@ -88,10 +88,12 @@ module ForemanMaintain
|
|
88
88
|
end
|
89
89
|
|
90
90
|
# Override to compose steps for the scenario
|
91
|
-
def compose
|
91
|
+
def compose
|
92
|
+
end
|
92
93
|
|
93
94
|
# Override to map context for the scenario
|
94
|
-
def set_context_mapping
|
95
|
+
def set_context_mapping
|
96
|
+
end
|
95
97
|
|
96
98
|
def preparation_steps
|
97
99
|
# we first take the preparation steps defined for the scenario + collect
|
@@ -146,7 +146,6 @@ module ForemanMaintain
|
|
146
146
|
|
147
147
|
private
|
148
148
|
|
149
|
-
# rubocop:disable Metrics/MethodLength
|
150
149
|
def rollback_pre_migrations
|
151
150
|
raise "Unexpected phase #{phase}, expecting pre_migrations" unless phase == :pre_migrations
|
152
151
|
|
@@ -169,7 +168,6 @@ module ForemanMaintain
|
|
169
168
|
The upgrade failed and system was restored to pre-upgrade state.
|
170
169
|
MESSAGE
|
171
170
|
end
|
172
|
-
# rubocop:enable Metrics/MethodLength
|
173
171
|
|
174
172
|
def with_non_empty_scenario(phase)
|
175
173
|
next_scenario = scenario(phase)
|
@@ -8,42 +8,30 @@ module ForemanMaintain
|
|
8
8
|
include Concerns::SystemHelpers
|
9
9
|
|
10
10
|
attr_accessor :standard_files, :katello_online_files, :katello_offline_files,
|
11
|
-
|
12
|
-
|
11
|
+
:foreman_online_files, :foreman_offline_files, :fpc_offline_files,
|
12
|
+
:fpc_online_files
|
13
13
|
|
14
|
-
# rubocop:disable Metrics/MethodLength
|
15
14
|
def initialize(backup_dir)
|
16
15
|
# fpc stands for foreman proxy w/ content
|
17
16
|
@backup_dir = backup_dir
|
18
17
|
@standard_files = ['config_files.tar.gz']
|
19
18
|
@foreman_online_files = ['foreman.dump']
|
20
19
|
@foreman_offline_files = ['pgsql_data.tar.gz']
|
21
|
-
@katello_online_files = ['candlepin.dump', '
|
20
|
+
@katello_online_files = @foreman_online_files + ['candlepin.dump', 'pulpcore.dump']
|
22
21
|
@katello_offline_files = ['pgsql_data.tar.gz']
|
23
|
-
|
24
|
-
|
25
|
-
@katello_offline_files << 'mongo_data.tar.gz'
|
26
|
-
@fpc_online_files = ['mongo_dump']
|
27
|
-
@fpc_offline_files = ['mongo_data.tar.gz']
|
28
|
-
elsif feature(:pulpcore_database)
|
29
|
-
@katello_online_files << 'foreman.dump'
|
30
|
-
@fpc_online_files = ['pulpcore.dump']
|
31
|
-
@fpc_offline_files = ['pgsql_data.tar.gz']
|
32
|
-
end
|
22
|
+
@fpc_online_files = ['pulpcore.dump']
|
23
|
+
@fpc_offline_files = ['pgsql_data.tar.gz']
|
33
24
|
end
|
34
|
-
# rubocop:enable Metrics/MethodLength
|
35
25
|
|
36
26
|
def file_map
|
37
27
|
@file_map ||= {
|
38
|
-
:mongo_data => map_file(@backup_dir, 'mongo_data.tar.gz'),
|
39
28
|
:pgsql_data => map_file(@backup_dir, 'pgsql_data.tar.gz'),
|
40
29
|
:pulp_data => map_file(@backup_dir, 'pulp_data.tar'),
|
41
30
|
:foreman_dump => map_file(@backup_dir, 'foreman.dump'),
|
42
31
|
:candlepin_dump => map_file(@backup_dir, 'candlepin.dump'),
|
43
|
-
:mongo_dump => map_file(@backup_dir, 'mongo_dump'),
|
44
32
|
:config_files => map_file(@backup_dir, 'config_files.tar.gz'),
|
45
33
|
:metadata => map_file(@backup_dir, 'metadata.yml'),
|
46
|
-
:pulpcore_dump => map_file(@backup_dir, 'pulpcore.dump')
|
34
|
+
:pulpcore_dump => map_file(@backup_dir, 'pulpcore.dump'),
|
47
35
|
}
|
48
36
|
end
|
49
37
|
|
@@ -52,7 +40,7 @@ module ForemanMaintain
|
|
52
40
|
present = File.exist?(file_path)
|
53
41
|
{
|
54
42
|
:present => present,
|
55
|
-
:path => file_path
|
43
|
+
:path => file_path,
|
56
44
|
}
|
57
45
|
end
|
58
46
|
|
@@ -77,7 +65,6 @@ module ForemanMaintain
|
|
77
65
|
|
78
66
|
def valid_fpc_backup?
|
79
67
|
fpc_online_backup? || fpc_standard_backup? || fpc_logical_backup? || \
|
80
|
-
# fpc can have setup where mongo or pulpcore db is external but not both
|
81
68
|
fpc_hybrid_db_backup?
|
82
69
|
end
|
83
70
|
|
@@ -109,118 +96,52 @@ module ForemanMaintain
|
|
109
96
|
|
110
97
|
def katello_standard_backup?
|
111
98
|
present = [:pgsql_data]
|
112
|
-
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump
|
113
|
-
if feature(:pulpcore_database) && !feature(:pulp2)
|
114
|
-
absent.concat [:mongo_data]
|
115
|
-
elsif feature(:pulp2)
|
116
|
-
present.concat [:mongo_data]
|
117
|
-
else
|
118
|
-
return false
|
119
|
-
end
|
99
|
+
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump]
|
120
100
|
check_file_existence(:present => present,
|
121
|
-
|
101
|
+
:absent => absent)
|
122
102
|
end
|
123
103
|
|
124
104
|
def katello_online_backup?
|
125
|
-
present = [:candlepin_dump, :foreman_dump]
|
126
|
-
absent = [:
|
127
|
-
if feature(:pulpcore_database) && !feature(:pulp2)
|
128
|
-
present.concat [:pulpcore_dump]
|
129
|
-
absent.concat [:mongo_dump]
|
130
|
-
elsif feature(:pulp2) && feature(:pulpcore_database)
|
131
|
-
present.concat [:mongo_dump, :pulpcore_dump]
|
132
|
-
elsif feature(:pulp2)
|
133
|
-
present.concat [:mongo_dump]
|
134
|
-
absent.concat [:pulpcore_dump]
|
135
|
-
else
|
136
|
-
return false
|
137
|
-
end
|
105
|
+
present = [:candlepin_dump, :foreman_dump, :pulpcore_dump]
|
106
|
+
absent = [:pgsql_data]
|
138
107
|
check_file_existence(:present => present,
|
139
|
-
|
108
|
+
:absent => absent)
|
140
109
|
end
|
141
110
|
|
142
111
|
def katello_logical_backup?
|
143
|
-
present = [:pgsql_data, :candlepin_dump, :foreman_dump]
|
112
|
+
present = [:pgsql_data, :candlepin_dump, :foreman_dump, :pulpcore_dump]
|
144
113
|
absent = []
|
145
|
-
if feature(:pulpcore_database) && !feature(:pulp2)
|
146
|
-
present.concat [:pulpcore_dump]
|
147
|
-
absent.concat [:mongo_dump, :mongo_data]
|
148
|
-
elsif feature(:pulp2) && feature(:pulpcore_database)
|
149
|
-
present.concat [:mongo_dump, :mongo_data, :pulpcore_dump]
|
150
|
-
elsif feature(:pulp2)
|
151
|
-
present.concat [:mongo_dump, :mongo_data]
|
152
|
-
absent.concat [:pulpcore_dump]
|
153
|
-
else
|
154
|
-
return false
|
155
|
-
end
|
156
114
|
check_file_existence(:present => present,
|
157
|
-
|
115
|
+
:absent => absent)
|
158
116
|
end
|
159
117
|
|
160
118
|
def katello_hybrid_db_backup?
|
161
|
-
all_dbs = { :pgsql_data => %w[candlepin foreman
|
162
|
-
all_dbs[:pgsql_data] << 'pulpcore' if feature(:pulpcore_database)
|
163
|
-
all_dbs[:mongo_data] << 'mongo' if feature(:mongo)
|
119
|
+
all_dbs = { :pgsql_data => %w[candlepin foreman pulpcore] }
|
164
120
|
present, absent = dumps_for_hybrid_db_setup(all_dbs)
|
165
121
|
check_file_existence(:present => present, :absent => absent)
|
166
122
|
end
|
167
123
|
|
168
124
|
def fpc_standard_backup?
|
169
|
-
present = []
|
170
|
-
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump
|
171
|
-
if feature(:pulpcore_database) && !feature(:pulp2)
|
172
|
-
present.concat [:pgsql_data]
|
173
|
-
absent.concat [:mongo_data]
|
174
|
-
elsif feature(:pulp2) && feature(:pulpcore_database)
|
175
|
-
present.concat [:mongo_data, :pgsql_data]
|
176
|
-
elsif feature(:pulp2)
|
177
|
-
present.concat [:mongo_data]
|
178
|
-
absent.concat [:pgsql_data]
|
179
|
-
else
|
180
|
-
return false
|
181
|
-
end
|
125
|
+
present = [:pgsql_data]
|
126
|
+
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump]
|
182
127
|
check_file_existence(:present => present,
|
183
|
-
|
128
|
+
:absent => absent)
|
184
129
|
end
|
185
130
|
|
186
131
|
def fpc_online_backup?
|
187
|
-
present = []
|
188
|
-
absent = [:
|
189
|
-
if feature(:pulpcore_database) && !feature(:pulp2)
|
190
|
-
present.concat [:pulpcore_dump]
|
191
|
-
absent.concat [:mongo_dump]
|
192
|
-
elsif feature(:pulp2) && feature(:pulpcore_database)
|
193
|
-
present.concat [:mongo_dump, :pulpcore_dump]
|
194
|
-
elsif feature(:pulp2)
|
195
|
-
present.concat [:mongo_dump]
|
196
|
-
absent.concat [:pulpcore_dump]
|
197
|
-
else
|
198
|
-
return false
|
199
|
-
end
|
132
|
+
present = [:pulpcore_dump]
|
133
|
+
absent = [:pgsql_data, :candlepin_dump, :foreman_dump]
|
200
134
|
check_file_existence(:present => present, :absent => absent)
|
201
135
|
end
|
202
136
|
|
203
137
|
def fpc_logical_backup?
|
204
|
-
present = []
|
138
|
+
present = [:pulpcore_dump, :pgsql_data]
|
205
139
|
absent = [:candlepin_dump, :foreman_dump]
|
206
|
-
if feature(:pulpcore_database) && !feature(:pulp2)
|
207
|
-
present.concat [:pulpcore_dump, :pgsql_data]
|
208
|
-
absent.concat [:mongo_dump, :mongo_data]
|
209
|
-
elsif feature(:pulp2) && feature(:pulpcore_database)
|
210
|
-
present.concat [:mongo_dump, :mongo_data, :pulpcore_dump, :pgsql_data]
|
211
|
-
elsif feature(:pulp2)
|
212
|
-
present.concat [:mongo_dump, :mongo_data]
|
213
|
-
absent.concat [:pulpcore_dump, :pgsql_data]
|
214
|
-
else
|
215
|
-
return false
|
216
|
-
end
|
217
140
|
check_file_existence(:present => present, :absent => absent)
|
218
141
|
end
|
219
142
|
|
220
143
|
def fpc_hybrid_db_backup?
|
221
|
-
all_dbs = { :pgsql_data => []
|
222
|
-
all_dbs[:pgsql_data] << 'pulpcore' if feature(:pulpcore_database)
|
223
|
-
all_dbs[:mongo_data] << 'mongo' if feature(:mongo)
|
144
|
+
all_dbs = { :pgsql_data => ['pulpcore'] }
|
224
145
|
present, absent = dumps_for_hybrid_db_setup(all_dbs)
|
225
146
|
absent.concat [:candlepin_dump, :foreman_dump]
|
226
147
|
check_file_existence(:present => present, :absent => absent)
|
@@ -228,28 +149,25 @@ module ForemanMaintain
|
|
228
149
|
|
229
150
|
def foreman_standard_backup?
|
230
151
|
check_file_existence(:present => [:pgsql_data],
|
231
|
-
|
232
|
-
:mongo_data, :mongo_dump])
|
152
|
+
:absent => [:candlepin_dump, :foreman_dump, :pulpcore_dump])
|
233
153
|
end
|
234
154
|
|
235
155
|
def foreman_online_backup?
|
236
156
|
check_file_existence(:present => [:foreman_dump],
|
237
|
-
|
238
|
-
:mongo_data, :mongo_dump, :pulpcore_dump])
|
157
|
+
:absent => [:candlepin_dump, :pgsql_data, :pulpcore_dump])
|
239
158
|
end
|
240
159
|
|
241
160
|
def foreman_logical_backup?
|
242
161
|
check_file_existence(:present => [:pgsql_data, :foreman_dump],
|
243
|
-
|
162
|
+
:absent => [:candlepin_dump, :pulpcore_dump])
|
244
163
|
end
|
245
164
|
|
246
|
-
# rubocop:disable Metrics/MethodLength
|
247
165
|
def dumps_for_hybrid_db_setup(dbs_hash)
|
248
166
|
present = []
|
249
167
|
absent = []
|
250
168
|
dbs_hash.each do |data_file, dbs|
|
251
169
|
dbs.each do |db|
|
252
|
-
feature_label =
|
170
|
+
feature_label = "#{db}_database"
|
253
171
|
dump_file = "#{db}_dump"
|
254
172
|
if feature(feature_label.to_sym).local?
|
255
173
|
present |= [data_file]
|
@@ -262,7 +180,6 @@ module ForemanMaintain
|
|
262
180
|
end
|
263
181
|
[present, absent]
|
264
182
|
end
|
265
|
-
# rubocop:enable Metrics/MethodLength
|
266
183
|
|
267
184
|
def validate_hostname?
|
268
185
|
# make sure that the system hostname is the same as the backup
|
@@ -319,8 +236,7 @@ module ForemanMaintain
|
|
319
236
|
end
|
320
237
|
|
321
238
|
def tar_backups_exist?
|
322
|
-
file_map[:
|
323
|
-
file_map[:pulp_data][:present] ||
|
239
|
+
file_map[:pulp_data][:present] ||
|
324
240
|
file_map[:pgsql_data][:present]
|
325
241
|
end
|
326
242
|
|