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
@@ -2,9 +2,7 @@ module ForemanMaintain
|
|
2
2
|
module Concerns
|
3
3
|
module BaseDatabase
|
4
4
|
def data_dir
|
5
|
-
if
|
6
|
-
'/var/opt/rh/rh-postgresql12/lib/pgsql/data/'
|
7
|
-
elsif debian_or_ubuntu?
|
5
|
+
if debian_or_ubuntu?
|
8
6
|
deb_postgresql_data_dir
|
9
7
|
else
|
10
8
|
'/var/lib/pgsql/data/'
|
@@ -39,20 +37,13 @@ module ForemanMaintain
|
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
|
-
def restore_transform
|
43
|
-
if el8?
|
44
|
-
# this allows to transform an EL7 backup to EL8 paths
|
45
|
-
's,^var/opt/rh/rh-postgresql12/,var/,S'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
40
|
def configuration
|
50
41
|
raise NotImplementedError
|
51
42
|
end
|
52
43
|
|
53
44
|
def config_files
|
54
45
|
[
|
55
|
-
'/etc/systemd/system/postgresql.service'
|
46
|
+
'/etc/systemd/system/postgresql.service',
|
56
47
|
]
|
57
48
|
end
|
58
49
|
|
@@ -71,8 +62,8 @@ module ForemanMaintain
|
|
71
62
|
def psql(query, config = configuration)
|
72
63
|
if ping(config)
|
73
64
|
execute(psql_command(config),
|
74
|
-
|
75
|
-
|
65
|
+
:stdin => query,
|
66
|
+
:hidden_patterns => [config['password']])
|
76
67
|
else
|
77
68
|
raise_service_error
|
78
69
|
end
|
@@ -80,8 +71,8 @@ module ForemanMaintain
|
|
80
71
|
|
81
72
|
def ping(config = configuration)
|
82
73
|
execute?(psql_command(config),
|
83
|
-
|
84
|
-
|
74
|
+
:stdin => 'SELECT 1 as ping',
|
75
|
+
:hidden_patterns => [config['password']])
|
85
76
|
end
|
86
77
|
|
87
78
|
def backup_file_path(config = configuration)
|
@@ -116,8 +107,8 @@ module ForemanMaintain
|
|
116
107
|
tar_options = {
|
117
108
|
:archive => backup_file,
|
118
109
|
:command => command,
|
119
|
-
:transform => "s,^,#{dir[1
|
120
|
-
:files => '*'
|
110
|
+
:transform => "s,^,#{dir[1..]},S",
|
111
|
+
:files => '*',
|
121
112
|
}.merge(extra_tar_options)
|
122
113
|
feature(:tar).run(tar_options)
|
123
114
|
end
|
@@ -53,85 +53,27 @@ module ForemanMaintain
|
|
53
53
|
rh_repos = main_rh_repos
|
54
54
|
server_version_full = "#{server_version.major}.#{server_version.minor}"
|
55
55
|
rh_repos.concat(product_specific_repos(server_version_full))
|
56
|
-
if server_version > version('6.3')
|
57
|
-
ansible_repo = ansible_repo(server_version)
|
58
|
-
rh_repos << ansible_repo if ansible_repo
|
59
|
-
end
|
60
|
-
|
61
56
|
rh_repos
|
62
57
|
end
|
63
58
|
|
64
|
-
def ansible_repo(server_version)
|
65
|
-
if server_version >= version('6.8')
|
66
|
-
ansible_version = '2.9'
|
67
|
-
elsif server_version >= version('6.6')
|
68
|
-
ansible_version = '2.8'
|
69
|
-
elsif server_version >= version('6.4')
|
70
|
-
ansible_version = '2.6'
|
71
|
-
end
|
72
|
-
|
73
|
-
if el7?
|
74
|
-
"rhel-#{el_major_version}-server-ansible-#{ansible_version}-rpms"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
59
|
def use_beta_repos?
|
79
60
|
ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
|
80
61
|
end
|
81
62
|
|
82
63
|
def product_specific_repos(full_version)
|
83
|
-
|
84
|
-
repos = if el7? && use_beta_repos?
|
85
|
-
["rhel-server-#{el_major_version}-#{package_name}-#{maj_version}-beta-rpms"]
|
86
|
-
elsif el7?
|
87
|
-
["rhel-#{el_major_version}-server-#{package_name}-#{full_version}-rpms"]
|
88
|
-
elsif use_beta_repos?
|
89
|
-
["#{package_name}-#{maj_version}-beta-for-rhel-#{el_major_version}-x86_64-rpms"]
|
90
|
-
else
|
91
|
-
["#{package_name}-#{full_version}-for-rhel-#{el_major_version}-x86_64-rpms"]
|
92
|
-
end
|
93
|
-
|
94
|
-
repos << puppet4_repo(full_version) unless puppet4_repo(full_version).nil?
|
64
|
+
repos = ["#{package_name}-#{full_version}-for-rhel-#{el_major_version}-x86_64-rpms"]
|
95
65
|
repos.concat(common_repos(full_version))
|
96
66
|
end
|
97
67
|
|
98
|
-
def puppet4_repo(full_version)
|
99
|
-
if current_minor_version == '6.3' && full_version.to_s != '6.4' && (
|
100
|
-
feature(:puppet_server) && feature(:puppet_server).puppet_version.major == 4)
|
101
|
-
"rhel-#{el_major_version}-server-#{package_name}-tools-6.3-puppet4-rpms"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
68
|
def common_repos(full_version)
|
106
|
-
|
107
|
-
full_version
|
108
|
-
else
|
109
|
-
full_version[0]
|
110
|
-
end
|
111
|
-
|
112
|
-
# rubocop:disable Metrics/LineLength
|
113
|
-
repos = if el7? && use_beta_repos?
|
114
|
-
["rhel-#{el_major_version}-server-satellite-maintenance-#{sat_maint_version}-beta-rpms"]
|
115
|
-
elsif el7?
|
116
|
-
["rhel-#{el_major_version}-server-satellite-maintenance-#{sat_maint_version}-rpms"]
|
117
|
-
elsif use_beta_repos?
|
118
|
-
["satellite-maintenance-#{sat_maint_version}-beta-for-rhel-#{el_major_version}-x86_64-rpms"]
|
119
|
-
else
|
120
|
-
["satellite-maintenance-#{sat_maint_version}-for-rhel-#{el_major_version}-x86_64-rpms"]
|
121
|
-
end
|
122
|
-
# rubocop:enable Metrics/LineLength
|
123
|
-
|
124
|
-
repos
|
69
|
+
["satellite-maintenance-#{full_version}-for-rhel-#{el_major_version}-x86_64-rpms"]
|
125
70
|
end
|
126
71
|
|
127
72
|
def main_rh_repos
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
["rhel-#{el_major_version}-for-x86_64-baseos-rpms",
|
133
|
-
"rhel-#{el_major_version}-for-x86_64-appstream-rpms"]
|
134
|
-
end
|
73
|
+
[
|
74
|
+
"rhel-#{el_major_version}-for-x86_64-baseos-rpms",
|
75
|
+
"rhel-#{el_major_version}-for-x86_64-appstream-rpms",
|
76
|
+
]
|
135
77
|
end
|
136
78
|
|
137
79
|
def version_from_source
|
@@ -2,19 +2,20 @@ module ForemanMaintain
|
|
2
2
|
module Concerns
|
3
3
|
module PrimaryChecks
|
4
4
|
def validate_downstream_packages
|
5
|
-
return unless detector.feature(:installer)
|
5
|
+
return unless detector.feature(:installer)&.with_scenarios?
|
6
6
|
if (package = package_name) && !package_manager.installed?(package)
|
7
7
|
raise ForemanMaintain::Error::Fail,
|
8
|
-
|
9
|
-
|
8
|
+
"Error: Important rpm package #{package} is not installed!"\
|
9
|
+
"\nInstall #{package} rpm to ensure system consistency."
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def package_name
|
14
14
|
installed_scenario = detector.feature(:installer).last_scenario
|
15
|
-
|
15
|
+
case installed_scenario
|
16
|
+
when 'satellite'
|
16
17
|
'satellite'
|
17
|
-
|
18
|
+
when 'capsule'
|
18
19
|
'satellite-capsule'
|
19
20
|
end
|
20
21
|
end
|
@@ -6,16 +6,9 @@ module ForemanMaintain
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def exclude_from_backup
|
9
|
-
# For pulp2:
|
10
|
-
# Exclude /var/lib/pulp/katello-export and /var/lib/pulp/cache
|
11
|
-
# since the tar is run from /var/lib/pulp, list subdir paths only
|
12
|
-
# For pulp3/pulpcore:
|
13
|
-
pulp2_dirs = %w[katello-export cache]
|
14
|
-
# For pulp3/pulpcore:
|
15
9
|
# Only need to backup media directory of /var/lib/pulp
|
16
10
|
# All below directories and their contents are regenerated on installer run
|
17
|
-
|
18
|
-
pulp2_dirs + pulpcore_dirs
|
11
|
+
%w[assets exports imports sync_imports tmp]
|
19
12
|
end
|
20
13
|
end
|
21
14
|
end
|
@@ -127,7 +127,7 @@ module ForemanMaintain
|
|
127
127
|
def parse_csv(data)
|
128
128
|
parsed_data = CSV.parse(data)
|
129
129
|
header = parsed_data.first
|
130
|
-
parsed_data[1
|
130
|
+
parsed_data[1..].map do |row|
|
131
131
|
Hash[*header.zip(row).flatten(1)]
|
132
132
|
end
|
133
133
|
end
|
@@ -191,11 +191,9 @@ module ForemanMaintain
|
|
191
191
|
ForemanMaintain.repository_manager
|
192
192
|
end
|
193
193
|
|
194
|
-
def ruby_prefix
|
194
|
+
def ruby_prefix
|
195
195
|
if debian_or_ubuntu?
|
196
196
|
'ruby-'
|
197
|
-
elsif el7? && scl
|
198
|
-
'tfm-rubygem-'
|
199
197
|
else
|
200
198
|
'rubygem-'
|
201
199
|
end
|
@@ -213,8 +211,7 @@ module ForemanMaintain
|
|
213
211
|
else
|
214
212
|
proxy_plugin_prefix = 'smart_proxy_'
|
215
213
|
end
|
216
|
-
|
217
|
-
ruby_prefix(scl) + proxy_plugin_prefix + plugin
|
214
|
+
ruby_prefix + proxy_plugin_prefix + plugin
|
218
215
|
end
|
219
216
|
|
220
217
|
def hammer_plugin_name(plugin)
|
@@ -86,7 +86,7 @@ module ForemanMaintain
|
|
86
86
|
repoids_and_urls = {}
|
87
87
|
repository_manager.enabled_repos.each do |repo, url|
|
88
88
|
repo_urls.each do |regex|
|
89
|
-
repoids_and_urls[repo] = url if url
|
89
|
+
repoids_and_urls[repo] = url if url&.match?(regex)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
repoids_and_urls
|
@@ -95,8 +95,8 @@ module ForemanMaintain
|
|
95
95
|
private
|
96
96
|
|
97
97
|
def repo_urls
|
98
|
-
[%r{yum.theforeman.org
|
99
|
-
%r{yum.puppetlabs.com
|
98
|
+
[%r{yum.theforeman.org/*},
|
99
|
+
%r{yum.puppetlabs.com/*}]
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -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
|
@@ -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
|
@@ -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,9 +5,7 @@ require 'foreman_maintain/package_manager/apt'
|
|
5
5
|
|
6
6
|
module ForemanMaintain
|
7
7
|
def self.package_manager
|
8
|
-
@package_manager ||= if
|
9
|
-
ForemanMaintain::PackageManager::Yum.new
|
10
|
-
elsif el?
|
8
|
+
@package_manager ||= if el?
|
11
9
|
ForemanMaintain::PackageManager::Dnf.new
|
12
10
|
elsif debian_or_ubuntu?
|
13
11
|
ForemanMaintain::PackageManager::Apt.new
|
@@ -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
|