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
@@ -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
|
|
@@ -68,37 +68,36 @@ module ForemanMaintain
|
|
68
68
|
|
69
69
|
def traverse_tree(dict, path)
|
70
70
|
return [dict, []] if path.nil? || path.empty?
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
result
|
71
|
+
if dict.key?(path.first)
|
72
|
+
if path.first.start_with?('-')
|
73
|
+
parse_option(dict, path)
|
74
|
+
else
|
75
|
+
parse_subcommand(dict, path)
|
76
|
+
end
|
77
|
+
elsif dict[:params]
|
78
|
+
# traverse params one by one
|
79
|
+
parse_params(dict, path)
|
80
|
+
else
|
81
|
+
# not found
|
82
|
+
[{}, path]
|
83
|
+
end
|
85
84
|
end
|
86
85
|
|
87
86
|
def parse_params(dict, path)
|
88
|
-
traverse_tree({ :params => dict[:params][1
|
87
|
+
traverse_tree({ :params => dict[:params][1..] }, path[1..])
|
89
88
|
end
|
90
89
|
|
91
90
|
def parse_subcommand(dict, path)
|
92
|
-
traverse_tree(dict[path.first], path[1
|
91
|
+
traverse_tree(dict[path.first], path[1..])
|
93
92
|
end
|
94
93
|
|
95
94
|
def parse_option(dict, path)
|
96
95
|
if dict[path.first][:type] == :flag # flag
|
97
|
-
traverse_tree(dict, path[1
|
96
|
+
traverse_tree(dict, path[1..])
|
98
97
|
elsif path.length >= 2 # option with value
|
99
|
-
traverse_tree(dict, path[2
|
98
|
+
traverse_tree(dict, path[2..])
|
100
99
|
else # option with value missing
|
101
|
-
[dict[path.first], path[1
|
100
|
+
[dict[path.first], path[1..]]
|
102
101
|
end
|
103
102
|
end
|
104
103
|
|
@@ -21,15 +21,13 @@ module ForemanMaintain
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def run
|
24
|
-
|
25
|
-
logger.debug(hide_strings("Running command #{@command} with stdin #{@stdin.inspect}"))
|
26
|
-
end
|
24
|
+
logger&.debug(hide_strings("Running command #{@command} with stdin #{@stdin.inspect}"))
|
27
25
|
if @interactive
|
28
26
|
run_interactively
|
29
27
|
else
|
30
28
|
run_non_interactively
|
31
29
|
end
|
32
|
-
logger
|
30
|
+
logger&.debug("output of the command:\n #{hide_strings(output)}")
|
33
31
|
end
|
34
32
|
|
35
33
|
def interactive?
|
@@ -52,14 +50,13 @@ module ForemanMaintain
|
|
52
50
|
|
53
51
|
def execution_error
|
54
52
|
raise Error::ExecutionError.new(hide_strings(@command),
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
exit_status,
|
54
|
+
hide_strings(@stdin),
|
55
|
+
@interactive ? nil : hide_strings(@output))
|
58
56
|
end
|
59
57
|
|
60
58
|
private
|
61
59
|
|
62
|
-
# rubocop:disable Metrics/MethodLength
|
63
60
|
def run_interactively
|
64
61
|
# use tmp files to capture output and exit status of the command when
|
65
62
|
# running interactively
|
@@ -82,7 +79,6 @@ module ForemanMaintain
|
|
82
79
|
log_file.close
|
83
80
|
exit_file.close
|
84
81
|
end
|
85
|
-
# rubocop:enable Metrics/MethodLength
|
86
82
|
|
87
83
|
def run_non_interactively
|
88
84
|
IO.popen(full_command, 'r+') do |f|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module ForemanMaintain::Utils
|
2
2
|
module HashTools
|
3
|
-
def self.deep_merge!(
|
4
|
-
|
3
|
+
def self.deep_merge!(hash, other_hash)
|
4
|
+
other_hash = symbolize_hash(other_hash)
|
5
5
|
|
6
|
-
|
6
|
+
hash.merge!(other_hash) do |_key, old_val, new_val|
|
7
7
|
if old_val.is_a?(Hash) && new_val.is_a?(Hash)
|
8
8
|
deep_merge!(old_val, new_val)
|
9
9
|
elsif old_val.is_a?(Array) && new_val.is_a?(Array)
|
@@ -14,8 +14,8 @@ module ForemanMaintain::Utils
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.symbolize_hash(
|
18
|
-
|
17
|
+
def self.symbolize_hash(hash)
|
18
|
+
hash.inject({}) { |sym_hash, (key, value)| sym_hash.update(key.to_sym => value) }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -2,6 +2,7 @@ module ForemanMaintain::Utils
|
|
2
2
|
module Service
|
3
3
|
class Systemd < Abstract
|
4
4
|
attr_reader :instance_parent_unit
|
5
|
+
|
5
6
|
def initialize(name, priority, options = {})
|
6
7
|
super
|
7
8
|
@sys = SystemHelpers.new
|
@@ -46,8 +47,7 @@ module ForemanMaintain::Utils
|
|
46
47
|
|
47
48
|
def exist?
|
48
49
|
if @sys.systemd_installed?
|
49
|
-
|
50
|
-
systemd == 'enabled' || systemd == 'disabled'
|
50
|
+
['enabled', 'disabled'].include?(service_enabled_status)
|
51
51
|
else
|
52
52
|
File.exist?("/etc/init.d/#{@name}")
|
53
53
|
end
|
@@ -73,14 +73,12 @@ module ForemanMaintain::Utils
|
|
73
73
|
# Enable and disable does not work well with globs since they treat them literally.
|
74
74
|
# We are skipping the pulpcore-workers@* for these actions until they are configured in
|
75
75
|
# a more managable way with systemd
|
76
|
-
# rubocop:disable Layout/IndentAssignment
|
77
76
|
msg =
|
78
|
-
"
|
77
|
+
"
|
79
78
|
\nWARNING: Skipping #{action} for #{name} as there are a variable amount of services to manage
|
80
79
|
and this command will not respond to glob operators. These services have been configured by
|
81
80
|
the installer and it is recommended to keep them enabled to prevent misconfiguration.\n
|
82
81
|
"
|
83
|
-
# rubocop:enable Layout/IndentAssignment
|
84
82
|
puts msg
|
85
83
|
end
|
86
84
|
end
|
@@ -5,7 +5,7 @@ require 'foreman_maintain/utils/service/remote_db'
|
|
5
5
|
module ForemanMaintain::Utils
|
6
6
|
def self.system_service(name, priority, options = {})
|
7
7
|
db_feature = options.fetch(:db_feature, nil)
|
8
|
-
if db_feature
|
8
|
+
if db_feature.respond_to?(:local?) && !db_feature.local?
|
9
9
|
Service::RemoteDB.new(name, priority, options)
|
10
10
|
else
|
11
11
|
Service::Systemd.new(name, priority, options)
|
@@ -4,6 +4,5 @@ require 'foreman_maintain/utils/disk'
|
|
4
4
|
require 'foreman_maintain/utils/bash'
|
5
5
|
require 'foreman_maintain/utils/hash_tools'
|
6
6
|
require 'foreman_maintain/utils/curl_response'
|
7
|
-
require 'foreman_maintain/utils/mongo_core'
|
8
7
|
require 'foreman_maintain/utils/service'
|
9
8
|
require 'foreman_maintain/utils/system_helpers'
|
data/lib/foreman_maintain.rb
CHANGED
@@ -60,7 +60,7 @@ module ForemanMaintain
|
|
60
60
|
'warn' => ::Logger::WARN,
|
61
61
|
'error' => ::Logger::ERROR,
|
62
62
|
'fatal' => ::Logger::FATAL,
|
63
|
-
'unknown' => ::Logger::UNKNOWN
|
63
|
+
'unknown' => ::Logger::UNKNOWN,
|
64
64
|
}.freeze
|
65
65
|
|
66
66
|
def setup(options = {})
|
@@ -98,7 +98,7 @@ module ForemanMaintain
|
|
98
98
|
$LOAD_PATH.concat(config.definitions_dirs)
|
99
99
|
config.definitions_dirs.each do |definitions_dir|
|
100
100
|
file_paths = File.expand_path(File.join(definitions_dir, '**', '*.rb'))
|
101
|
-
Dir.glob(file_paths).each { |f| require f }
|
101
|
+
Dir.glob(file_paths).sort.each { |f| require f }
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -192,7 +192,7 @@ module ForemanMaintain
|
|
192
192
|
end
|
193
193
|
|
194
194
|
def enable_maintenance_module
|
195
|
-
return unless el?
|
195
|
+
return unless el?
|
196
196
|
|
197
197
|
maintenance_module = 'satellite-maintenance:el8'
|
198
198
|
package_manager = ForemanMaintain.package_manager
|