foreman_maintain 1.12.3 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/definitions/checks/candlepin/db_index.rb +25 -0
- data/definitions/checks/foreman/db_index.rb +25 -0
- data/definitions/checks/pulpcore/db_index.rb +25 -0
- data/definitions/checks/restore/validate_backup.rb +5 -10
- data/definitions/checks/system_registration.rb +5 -3
- data/definitions/features/iop.rb +44 -0
- data/definitions/features/service.rb +4 -58
- data/definitions/features/timer.rb +96 -0
- data/definitions/procedures/iop/image_prune.rb +19 -0
- data/definitions/procedures/iop/update.rb +25 -0
- data/definitions/procedures/knowledge_base_article.rb +1 -0
- data/definitions/procedures/restore/extract_files.rb +0 -18
- data/definitions/procedures/timer/start.rb +20 -0
- data/definitions/procedures/timer/stop.rb +20 -0
- data/definitions/reports/bookmarks.rb +51 -0
- data/definitions/reports/disconnected_environment.rb +23 -0
- data/definitions/reports/grouping.rb +58 -0
- data/definitions/reports/lab_features.rb +19 -0
- data/definitions/reports/personal_access_token.rb +26 -0
- data/definitions/reports/selinux.rb +27 -0
- data/definitions/reports/webhooks.rb +37 -0
- data/definitions/scenarios/backup.rb +3 -3
- data/definitions/scenarios/foreman_upgrade.rb +2 -0
- data/definitions/scenarios/maintenance_mode.rb +2 -0
- data/definitions/scenarios/restore.rb +4 -6
- data/definitions/scenarios/satellite_upgrade.rb +4 -0
- data/definitions/scenarios/update.rb +5 -1
- data/lib/foreman_maintain/cli/base.rb +3 -3
- data/lib/foreman_maintain/concerns/base_database.rb +34 -0
- data/lib/foreman_maintain/concerns/systemd.rb +50 -0
- data/lib/foreman_maintain/feature.rb +9 -0
- data/lib/foreman_maintain/utils/backup.rb +10 -39
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +16 -3
- data/definitions/checks/backup/incremental_parent_type.rb +0 -33
- data/definitions/procedures/restore/reindex_databases.rb +0 -28
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Reports
|
4
|
+
class LabFeatures < ForemanMaintain::Report
|
5
|
+
metadata do
|
6
|
+
description 'Checks if lab features are enabled'
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
data_field('lab_features_enabled') do
|
11
|
+
lab_features_setting = sql_setting('lab_features')
|
12
|
+
return false if lab_features_setting.nil?
|
13
|
+
|
14
|
+
# Parse the YAML setting value and convert to boolean
|
15
|
+
YAML.safe_load(lab_features_setting) == true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Reports
|
4
|
+
class PersonalAccessToken < ForemanMaintain::Report
|
5
|
+
metadata do
|
6
|
+
description 'Report about Personal Access Token usage'
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
# Total count of non-revoked personal access tokens
|
11
|
+
data_field('pat_counts') do
|
12
|
+
sql_count('personal_access_tokens WHERE revoked = false')
|
13
|
+
end
|
14
|
+
|
15
|
+
# Count of tokens that were used recently (updated in last 2 months)
|
16
|
+
data_field('pat_recently_used_count') do
|
17
|
+
sql_count("personal_access_tokens WHERE updated_at >= NOW() - INTERVAL '2 months'")
|
18
|
+
end
|
19
|
+
|
20
|
+
# Count of revoked personal access tokens
|
21
|
+
data_field('revoked_pats_count') do
|
22
|
+
sql_count('personal_access_tokens WHERE revoked = true')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Reports
|
4
|
+
class Selinux < ForemanMaintain::Report
|
5
|
+
metadata do
|
6
|
+
description 'Report about SELinux enforcement status'
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
data_field('selinux_enforced') { selinux_enforced? }
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def selinux_enforced?
|
16
|
+
# Check if getenforce command exists and SELinux is installed
|
17
|
+
return false unless command_present?('getenforce')
|
18
|
+
|
19
|
+
# Execute getenforce command and check if SELinux is enforcing
|
20
|
+
status = execute('getenforce').strip.downcase
|
21
|
+
status == 'enforcing'
|
22
|
+
rescue StandardError
|
23
|
+
# If any error occurs, assume SELinux is not enforced
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Reports
|
4
|
+
class Webhooks < ForemanMaintain::Report
|
5
|
+
metadata do
|
6
|
+
description 'Report about webhook usage'
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
data_field('webhooks_enabled_count') { sql_count('webhooks WHERE enabled = true') }
|
11
|
+
data_field('webhooks_subscribed_events') { webhooks_subscribed_events }
|
12
|
+
data_field('shell_hooks_count') { sql_count('webhooks WHERE proxy_authorization = true') }
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def webhooks_subscribed_events
|
18
|
+
# Extract all events from webhooks table and join into comma-separated string
|
19
|
+
events_data = query('SELECT events FROM webhooks')
|
20
|
+
|
21
|
+
all_events = []
|
22
|
+
events_data.each do |row|
|
23
|
+
events_value = row['events']
|
24
|
+
next if events_value.nil? || events_value.empty?
|
25
|
+
|
26
|
+
# Parse the array-like string - handle both JSON array format and simple arrays
|
27
|
+
# Remove outer brackets/braces, quotes, and split by comma
|
28
|
+
cleaned_value = events_value.gsub(/^[\[{]|[\]}]$/, '').gsub(/["']/, '')
|
29
|
+
parsed_events = cleaned_value.split(',').map(&:strip)
|
30
|
+
all_events.concat(parsed_events)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Remove duplicates and join with commas
|
34
|
+
all_events.uniq.reject(&:empty?).join(',')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -18,8 +18,9 @@ module ForemanMaintain::Scenarios
|
|
18
18
|
|
19
19
|
def compose
|
20
20
|
check_valid_strategy
|
21
|
-
|
22
|
-
|
21
|
+
add_step(Checks::Foreman::DBIndex)
|
22
|
+
add_step(Checks::Candlepin::DBIndex)
|
23
|
+
add_step(Checks::Pulpcore::DBIndex)
|
23
24
|
add_step(Checks::ForemanTasks::NotRunning.new(:wait_for_tasks => wait_for_tasks?))
|
24
25
|
add_step(Checks::Pulpcore::NoRunningTasks.new(:wait_for_tasks => wait_for_tasks?))
|
25
26
|
add_step_with_context(Procedures::Backup::AccessibilityConfirmation) if strategy == :offline
|
@@ -55,7 +56,6 @@ module ForemanMaintain::Scenarios
|
|
55
56
|
context.map(:preserve_dir,
|
56
57
|
Procedures::Backup::PrepareDirectory => :preserve_dir)
|
57
58
|
context.map(:incremental_dir,
|
58
|
-
Checks::Backup::IncrementalParentType => :incremental_dir,
|
59
59
|
Procedures::Backup::PrepareDirectory => :incremental_dir,
|
60
60
|
Procedures::Backup::Metadata => :incremental_dir)
|
61
61
|
context.map(:proxy_features,
|
@@ -72,6 +72,7 @@ module Scenarios::Foreman
|
|
72
72
|
add_steps(
|
73
73
|
Procedures::MaintenanceMode::EnableMaintenanceMode,
|
74
74
|
Procedures::Crond::Stop,
|
75
|
+
Procedures::Timer::Stop,
|
75
76
|
Procedures::SyncPlans::Disable
|
76
77
|
)
|
77
78
|
end
|
@@ -113,6 +114,7 @@ module Scenarios::Foreman
|
|
113
114
|
Procedures::RefreshFeatures,
|
114
115
|
Procedures::Service::Start,
|
115
116
|
Procedures::Crond::Start,
|
117
|
+
Procedures::Timer::Start,
|
116
118
|
Procedures::SyncPlans::Enable,
|
117
119
|
Procedures::MaintenanceMode::DisableMaintenanceMode
|
118
120
|
)
|
@@ -10,6 +10,7 @@ module ForemanMaintain::Scenarios
|
|
10
10
|
def compose
|
11
11
|
add_step(Procedures::MaintenanceMode::EnableMaintenanceMode)
|
12
12
|
add_step(Procedures::Crond::Stop)
|
13
|
+
add_step(Procedures::Timer::Stop)
|
13
14
|
add_step(Procedures::SyncPlans::Disable)
|
14
15
|
end
|
15
16
|
end
|
@@ -25,6 +26,7 @@ module ForemanMaintain::Scenarios
|
|
25
26
|
def compose
|
26
27
|
add_step(Procedures::SyncPlans::Enable)
|
27
28
|
add_step(Procedures::Crond::Start)
|
29
|
+
add_step(Procedures::Timer::Start)
|
28
30
|
add_step(Procedures::MaintenanceMode::DisableMaintenanceMode)
|
29
31
|
end
|
30
32
|
end
|
@@ -29,26 +29,23 @@ module ForemanMaintain::Scenarios
|
|
29
29
|
Procedures::Restore::RequiredPackages,
|
30
30
|
Procedures::Restore::Configs)
|
31
31
|
add_step_with_context(Procedures::Crond::Stop)
|
32
|
+
add_step_with_context(Procedures::Timer::Stop)
|
32
33
|
unless backup.incremental?
|
33
34
|
add_steps_with_context(Procedures::Restore::InstallerReset)
|
34
35
|
end
|
35
36
|
add_step_with_context(Procedures::Service::Stop)
|
36
|
-
add_steps_with_context(Procedures::Restore::ExtractFiles) if backup.tar_backups_exist?
|
37
37
|
|
38
38
|
if backup.sql_needs_dump_restore?
|
39
39
|
add_steps_with_context(Procedures::Restore::DropDatabases)
|
40
40
|
restore_sql_dumps(backup)
|
41
41
|
end
|
42
42
|
|
43
|
-
if
|
44
|
-
!backup.online_backup? &&
|
45
|
-
backup.different_source_os?
|
46
|
-
add_step_with_context(Procedures::Restore::ReindexDatabases)
|
47
|
-
end
|
43
|
+
add_steps_with_context(Procedures::Restore::ExtractFiles) if backup.tar_backups_exist?
|
48
44
|
|
49
45
|
add_step(Procedures::Installer::Run.new(:assumeyes => true))
|
50
46
|
add_step_with_context(Procedures::Installer::UpgradeRakeTask)
|
51
47
|
add_step_with_context(Procedures::Crond::Start)
|
48
|
+
add_step_with_context(Procedures::Timer::Start)
|
52
49
|
end
|
53
50
|
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize
|
54
51
|
|
@@ -119,6 +116,7 @@ module ForemanMaintain::Scenarios
|
|
119
116
|
|
120
117
|
def compose
|
121
118
|
add_step_with_context(Procedures::Crond::Stop)
|
119
|
+
add_step_with_context(Procedures::Timer::Stop)
|
122
120
|
end
|
123
121
|
end
|
124
122
|
end
|
@@ -74,6 +74,7 @@ module Scenarios::Satellite
|
|
74
74
|
add_steps(
|
75
75
|
Procedures::MaintenanceMode::EnableMaintenanceMode,
|
76
76
|
Procedures::Crond::Stop,
|
77
|
+
Procedures::Timer::Stop,
|
77
78
|
Procedures::SyncPlans::Disable,
|
78
79
|
)
|
79
80
|
end
|
@@ -97,6 +98,7 @@ module Scenarios::Satellite
|
|
97
98
|
:assumeyes => true,
|
98
99
|
:download_only => true
|
99
100
|
),
|
101
|
+
Procedures::Iop::Update.new(:version => target_version),
|
100
102
|
Procedures::Service::Stop,
|
101
103
|
Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false),
|
102
104
|
)
|
@@ -116,8 +118,10 @@ module Scenarios::Satellite
|
|
116
118
|
Procedures::RefreshFeatures,
|
117
119
|
Procedures::Service::Start,
|
118
120
|
Procedures::Crond::Start,
|
121
|
+
Procedures::Timer::Start,
|
119
122
|
Procedures::SyncPlans::Enable,
|
120
123
|
Procedures::MaintenanceMode::DisableMaintenanceMode,
|
124
|
+
Procedures::Iop::ImagePrune,
|
121
125
|
)
|
122
126
|
end
|
123
127
|
end
|
@@ -69,8 +69,10 @@ module Scenarios::Update
|
|
69
69
|
:assumeyes => true,
|
70
70
|
:download_only => true
|
71
71
|
),
|
72
|
+
Procedures::Iop::Update.new(:version => feature(:instance).current_major_version),
|
72
73
|
Procedures::MaintenanceMode::EnableMaintenanceMode,
|
73
74
|
Procedures::Crond::Stop,
|
75
|
+
Procedures::Timer::Stop,
|
74
76
|
Procedures::SyncPlans::Disable
|
75
77
|
)
|
76
78
|
end
|
@@ -104,8 +106,10 @@ module Scenarios::Update
|
|
104
106
|
Procedures::RefreshFeatures,
|
105
107
|
Procedures::Service::Start,
|
106
108
|
Procedures::Crond::Start,
|
109
|
+
Procedures::Timer::Start,
|
107
110
|
Procedures::SyncPlans::Enable,
|
108
|
-
Procedures::MaintenanceMode::DisableMaintenanceMode
|
111
|
+
Procedures::MaintenanceMode::DisableMaintenanceMode,
|
112
|
+
Procedures::Iop::ImagePrune,
|
109
113
|
)
|
110
114
|
end
|
111
115
|
end
|
@@ -137,7 +137,7 @@ module ForemanMaintain
|
|
137
137
|
option '--label', 'label',
|
138
138
|
'Run only a specific check with a label. ' \
|
139
139
|
'(Use "list" command to see available labels)' do |label|
|
140
|
-
raise ArgumentError, 'value
|
140
|
+
raise ArgumentError, 'no value provided' if label.nil? || label.empty?
|
141
141
|
underscorize(label).to_sym
|
142
142
|
end
|
143
143
|
end
|
@@ -147,7 +147,7 @@ module ForemanMaintain
|
|
147
147
|
'Run only those with all specific set of tags. ' \
|
148
148
|
'(Use list-tags command to see available tags)',
|
149
149
|
:multivalued => true) do |tags|
|
150
|
-
raise ArgumentError, 'value
|
150
|
+
raise ArgumentError, 'no value provided' if tags.nil? || tags.empty?
|
151
151
|
tags.map { |tag| underscorize(tag).to_sym }
|
152
152
|
end
|
153
153
|
end
|
@@ -166,7 +166,7 @@ module ForemanMaintain
|
|
166
166
|
if opts.include?('whitelist')
|
167
167
|
option(['-w', '--whitelist'], 'whitelist',
|
168
168
|
'Comma-separated list of labels of steps to be skipped') do |whitelist|
|
169
|
-
raise ArgumentError, 'value
|
169
|
+
raise ArgumentError, 'no value provided' if whitelist.nil? || whitelist.empty?
|
170
170
|
whitelist.split(',').map(&:strip)
|
171
171
|
end
|
172
172
|
end
|
@@ -140,6 +140,40 @@ module ForemanMaintain
|
|
140
140
|
' Make sure system has psql utility installed.'
|
141
141
|
end
|
142
142
|
|
143
|
+
def amcheck
|
144
|
+
# executing the check requires superuser privileges
|
145
|
+
return unless local?
|
146
|
+
|
147
|
+
return unless amcheck_installed?
|
148
|
+
|
149
|
+
psqlcmd = "runuser - postgres -c 'psql --set=ON_ERROR_STOP=on #{configuration['database']}'"
|
150
|
+
|
151
|
+
amcheck_query = <<~SQL
|
152
|
+
SELECT bt_index_check(index => c.oid, heapallindexed => i.indisunique),
|
153
|
+
c.relname,
|
154
|
+
c.relpages
|
155
|
+
FROM pg_index i
|
156
|
+
JOIN pg_opclass op ON i.indclass[0] = op.oid
|
157
|
+
JOIN pg_am am ON op.opcmethod = am.oid
|
158
|
+
JOIN pg_class c ON i.indexrelid = c.oid
|
159
|
+
JOIN pg_namespace n ON c.relnamespace = n.oid
|
160
|
+
WHERE am.amname = 'btree' AND n.nspname = 'public'
|
161
|
+
-- Don't check temp tables, which may be from another session:
|
162
|
+
AND c.relpersistence != 't'
|
163
|
+
-- Function may throw an error when this is omitted:
|
164
|
+
AND c.relkind = 'i' AND i.indisready AND i.indisvalid
|
165
|
+
ORDER BY c.relpages DESC;
|
166
|
+
SQL
|
167
|
+
|
168
|
+
execute_with_status(psqlcmd, :stdin => amcheck_query)
|
169
|
+
end
|
170
|
+
|
171
|
+
def amcheck_installed?
|
172
|
+
sql = "select 'amcheck_installed' from pg_extension where extname='amcheck'"
|
173
|
+
result = query(sql)
|
174
|
+
!result.nil? && !result.empty?
|
175
|
+
end
|
176
|
+
|
143
177
|
private
|
144
178
|
|
145
179
|
def base_env
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Concerns
|
3
|
+
module Systemd
|
4
|
+
def action_noun(action)
|
5
|
+
action_word_modified(action) + 'ing'
|
6
|
+
end
|
7
|
+
|
8
|
+
def action_past_tense(action)
|
9
|
+
action_word_modified(action) + 'ed'
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def format_status(output, exit_code, options)
|
15
|
+
status = ''
|
16
|
+
if !options[:failing] || exit_code > 0
|
17
|
+
if options[:brief]
|
18
|
+
status += format_brief_status(exit_code)
|
19
|
+
elsif !(output.nil? || output.empty?)
|
20
|
+
status += "\n" + output
|
21
|
+
end
|
22
|
+
end
|
23
|
+
status
|
24
|
+
end
|
25
|
+
|
26
|
+
def format_brief_status(exit_code)
|
27
|
+
result = (exit_code == 0) ? reporter.status_label(:success) : reporter.status_label(:fail)
|
28
|
+
padding = reporter.max_length - reporter.last_line.to_s.length - 30
|
29
|
+
"#{' ' * padding} #{result}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def allowed_action?(action)
|
33
|
+
%w[start stop restart status enable disable].include?(action)
|
34
|
+
end
|
35
|
+
|
36
|
+
def action_word_modified(action)
|
37
|
+
case action
|
38
|
+
when 'status'
|
39
|
+
'display'
|
40
|
+
when 'enable', 'disable'
|
41
|
+
action.chomp('e')
|
42
|
+
when 'stop'
|
43
|
+
action + 'p'
|
44
|
+
else
|
45
|
+
action
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -25,6 +25,15 @@ module ForemanMaintain
|
|
25
25
|
[]
|
26
26
|
end
|
27
27
|
|
28
|
+
# Override method with list of applicable timers for feature.
|
29
|
+
# Services have a number for priority in order to ensure
|
30
|
+
# they are started and stopped in the correct order.
|
31
|
+
# example:
|
32
|
+
# [ system_service('foo', 10), system_service('bar', 20) ]
|
33
|
+
def timers
|
34
|
+
[]
|
35
|
+
end
|
36
|
+
|
28
37
|
# Override to generate additional feature instances that can't be
|
29
38
|
# autodetected directly
|
30
39
|
def additional_features
|
@@ -7,9 +7,8 @@ module ForemanMaintain
|
|
7
7
|
class Backup
|
8
8
|
include Concerns::SystemHelpers
|
9
9
|
|
10
|
-
attr_accessor :standard_files, :katello_online_files,
|
11
|
-
:foreman_online_files, :
|
12
|
-
:fpc_online_files
|
10
|
+
attr_accessor :standard_files, :katello_online_files,
|
11
|
+
:foreman_online_files, :fpc_online_files
|
13
12
|
|
14
13
|
ONLINE_BACKUP = 'online'.freeze
|
15
14
|
OFFLINE_BACKUP = 'offline'.freeze
|
@@ -19,16 +18,12 @@ module ForemanMaintain
|
|
19
18
|
@backup_dir = backup_dir
|
20
19
|
@standard_files = ['config_files.tar.gz']
|
21
20
|
@foreman_online_files = ['foreman.dump']
|
22
|
-
@foreman_offline_files = ['pgsql_data.tar.gz']
|
23
21
|
@katello_online_files = @foreman_online_files + ['candlepin.dump', 'pulpcore.dump']
|
24
|
-
@katello_offline_files = ['pgsql_data.tar.gz']
|
25
22
|
@fpc_online_files = ['pulpcore.dump']
|
26
|
-
@fpc_offline_files = ['pgsql_data.tar.gz']
|
27
23
|
end
|
28
24
|
|
29
25
|
def file_map
|
30
26
|
@file_map ||= {
|
31
|
-
:pgsql_data => map_file(@backup_dir, 'pgsql_data.tar.gz'),
|
32
27
|
:pulp_data => map_file(@backup_dir, 'pulp_data.tar'),
|
33
28
|
:foreman_dump => map_file(@backup_dir, 'foreman.dump'),
|
34
29
|
:iop_advisor_dump => map_file(@backup_dir, 'iop_advisor.dump'),
|
@@ -72,15 +67,15 @@ module ForemanMaintain
|
|
72
67
|
end
|
73
68
|
|
74
69
|
def valid_fpc_backup?
|
75
|
-
fpc_online_backup?
|
70
|
+
fpc_online_backup?
|
76
71
|
end
|
77
72
|
|
78
73
|
def valid_katello_backup?
|
79
|
-
katello_online_backup?
|
74
|
+
katello_online_backup?
|
80
75
|
end
|
81
76
|
|
82
77
|
def valid_foreman_backup?
|
83
|
-
|
78
|
+
foreman_online_backup?
|
84
79
|
end
|
85
80
|
|
86
81
|
def check_file_existence(existence_map)
|
@@ -99,41 +94,22 @@ module ForemanMaintain
|
|
99
94
|
true
|
100
95
|
end
|
101
96
|
|
102
|
-
def katello_standard_backup?
|
103
|
-
present = [:pgsql_data]
|
104
|
-
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump]
|
105
|
-
check_file_existence(:present => present,
|
106
|
-
:absent => absent)
|
107
|
-
end
|
108
|
-
|
109
97
|
def katello_online_backup?
|
110
98
|
present = [:candlepin_dump, :foreman_dump, :pulpcore_dump]
|
111
|
-
absent = [
|
112
|
-
check_file_existence(:present => present,
|
113
|
-
:absent => absent)
|
114
|
-
end
|
115
|
-
|
116
|
-
def fpc_standard_backup?
|
117
|
-
present = [:pgsql_data]
|
118
|
-
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump]
|
99
|
+
absent = []
|
119
100
|
check_file_existence(:present => present,
|
120
101
|
:absent => absent)
|
121
102
|
end
|
122
103
|
|
123
104
|
def fpc_online_backup?
|
124
105
|
present = [:pulpcore_dump]
|
125
|
-
absent = [:
|
106
|
+
absent = [:candlepin_dump, :foreman_dump]
|
126
107
|
check_file_existence(:present => present, :absent => absent)
|
127
108
|
end
|
128
109
|
|
129
|
-
def foreman_standard_backup?
|
130
|
-
check_file_existence(:present => [:pgsql_data],
|
131
|
-
:absent => [:candlepin_dump, :foreman_dump, :pulpcore_dump])
|
132
|
-
end
|
133
|
-
|
134
110
|
def foreman_online_backup?
|
135
111
|
check_file_existence(:present => [:foreman_dump],
|
136
|
-
:absent => [:candlepin_dump, :
|
112
|
+
:absent => [:candlepin_dump, :pulpcore_dump])
|
137
113
|
end
|
138
114
|
|
139
115
|
def validate_hostname?
|
@@ -174,12 +150,7 @@ module ForemanMaintain
|
|
174
150
|
end
|
175
151
|
|
176
152
|
def tar_backups_exist?
|
177
|
-
file_map[:pulp_data][:present]
|
178
|
-
file_map[:pgsql_data][:present]
|
179
|
-
end
|
180
|
-
|
181
|
-
def sql_tar_files_exist?
|
182
|
-
file_map[:pgsql_data][:present]
|
153
|
+
file_map[:pulp_data][:present]
|
183
154
|
end
|
184
155
|
|
185
156
|
def sql_dump_files_exist?
|
@@ -189,7 +160,7 @@ module ForemanMaintain
|
|
189
160
|
end
|
190
161
|
|
191
162
|
def sql_needs_dump_restore?
|
192
|
-
|
163
|
+
sql_dump_files_exist?
|
193
164
|
end
|
194
165
|
|
195
166
|
def incremental?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
@@ -156,7 +156,7 @@ files:
|
|
156
156
|
- config/foreman_maintain.yml.packaging
|
157
157
|
- config/hammer.yml.example
|
158
158
|
- definitions/checks/backup/certs_tar_exist.rb
|
159
|
-
- definitions/checks/
|
159
|
+
- definitions/checks/candlepin/db_index.rb
|
160
160
|
- definitions/checks/candlepin/db_up.rb
|
161
161
|
- definitions/checks/check_hotfix_installed.rb
|
162
162
|
- definitions/checks/check_ipv6_disable.rb
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- definitions/checks/foreman/check_external_db_evr_permissions.rb
|
175
175
|
- definitions/checks/foreman/check_puppet_capsules.rb
|
176
176
|
- definitions/checks/foreman/check_tuning_requirements.rb
|
177
|
+
- definitions/checks/foreman/db_index.rb
|
177
178
|
- definitions/checks/foreman/db_up.rb
|
178
179
|
- definitions/checks/foreman/facts_names.rb
|
179
180
|
- definitions/checks/foreman/validate_external_db_version.rb
|
@@ -193,6 +194,7 @@ files:
|
|
193
194
|
- definitions/checks/maintenance_mode/check_consistency.rb
|
194
195
|
- definitions/checks/non_rh_packages.rb
|
195
196
|
- definitions/checks/package_manager/dnf/validate_dnf_config.rb
|
197
|
+
- definitions/checks/pulpcore/db_index.rb
|
196
198
|
- definitions/checks/pulpcore/db_up.rb
|
197
199
|
- definitions/checks/pulpcore/no_running_tasks.rb
|
198
200
|
- definitions/checks/puppet/verify_no_empty_cacert_requests.rb
|
@@ -245,6 +247,7 @@ files:
|
|
245
247
|
- definitions/features/service.rb
|
246
248
|
- definitions/features/sync_plans.rb
|
247
249
|
- definitions/features/tar.rb
|
250
|
+
- definitions/features/timer.rb
|
248
251
|
- definitions/procedures/backup/accessibility_confirmation.rb
|
249
252
|
- definitions/procedures/backup/clean.rb
|
250
253
|
- definitions/procedures/backup/compress_data.rb
|
@@ -275,6 +278,8 @@ files:
|
|
275
278
|
- definitions/procedures/hammer_setup.rb
|
276
279
|
- definitions/procedures/installer/run.rb
|
277
280
|
- definitions/procedures/installer/upgrade_rake_task.rb
|
281
|
+
- definitions/procedures/iop/image_prune.rb
|
282
|
+
- definitions/procedures/iop/update.rb
|
278
283
|
- definitions/procedures/knowledge_base_article.rb
|
279
284
|
- definitions/procedures/maintenance_mode/disable_maintenance_mode.rb
|
280
285
|
- definitions/procedures/maintenance_mode/enable_maintenance_mode.rb
|
@@ -316,7 +321,6 @@ files:
|
|
316
321
|
- definitions/procedures/restore/iop_vmaas_dump.rb
|
317
322
|
- definitions/procedures/restore/iop_vulnerability_dump.rb
|
318
323
|
- definitions/procedures/restore/pulpcore_dump.rb
|
319
|
-
- definitions/procedures/restore/reindex_databases.rb
|
320
324
|
- definitions/procedures/restore/required_packages.rb
|
321
325
|
- definitions/procedures/service/base.rb
|
322
326
|
- definitions/procedures/service/daemon_reload.rb
|
@@ -329,26 +333,34 @@ files:
|
|
329
333
|
- definitions/procedures/service/stop.rb
|
330
334
|
- definitions/procedures/sync_plans/disable.rb
|
331
335
|
- definitions/procedures/sync_plans/enable.rb
|
336
|
+
- definitions/procedures/timer/start.rb
|
337
|
+
- definitions/procedures/timer/stop.rb
|
332
338
|
- definitions/reports/advisor_on_prem_remediations.rb
|
333
339
|
- definitions/reports/alternate_content_sources.rb
|
340
|
+
- definitions/reports/bookmarks.rb
|
334
341
|
- definitions/reports/compliance.rb
|
335
342
|
- definitions/reports/content.rb
|
343
|
+
- definitions/reports/disconnected_environment.rb
|
336
344
|
- definitions/reports/external_auth_source.rb
|
337
345
|
- definitions/reports/grouping.rb
|
338
346
|
- definitions/reports/image_mode_hosts.rb
|
339
347
|
- definitions/reports/instance.rb
|
340
348
|
- definitions/reports/inventory.rb
|
341
349
|
- definitions/reports/kerberos.rb
|
350
|
+
- definitions/reports/lab_features.rb
|
342
351
|
- definitions/reports/ldap_auth_source.rb
|
343
352
|
- definitions/reports/networking.rb
|
344
353
|
- definitions/reports/oidc_usage.rb
|
354
|
+
- definitions/reports/personal_access_token.rb
|
345
355
|
- definitions/reports/platform.rb
|
346
356
|
- definitions/reports/provisioning.rb
|
347
357
|
- definitions/reports/rbac.rb
|
348
358
|
- definitions/reports/recurring_logics.rb
|
359
|
+
- definitions/reports/selinux.rb
|
349
360
|
- definitions/reports/template
|
350
361
|
- definitions/reports/virt_who.rb
|
351
362
|
- definitions/reports/vmware.rb
|
363
|
+
- definitions/reports/webhooks.rb
|
352
364
|
- definitions/scenarios/backup.rb
|
353
365
|
- definitions/scenarios/foreman_upgrade.rb
|
354
366
|
- definitions/scenarios/maintenance_mode.rb
|
@@ -405,6 +417,7 @@ files:
|
|
405
417
|
- lib/foreman_maintain/concerns/scenario_metadata.rb
|
406
418
|
- lib/foreman_maintain/concerns/system_helpers.rb
|
407
419
|
- lib/foreman_maintain/concerns/system_service.rb
|
420
|
+
- lib/foreman_maintain/concerns/systemd.rb
|
408
421
|
- lib/foreman_maintain/concerns/upstream.rb
|
409
422
|
- lib/foreman_maintain/concerns/versions.rb
|
410
423
|
- lib/foreman_maintain/config.rb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Checks::Backup
|
2
|
-
class IncrementalParentType < ForemanMaintain::Check
|
3
|
-
metadata do
|
4
|
-
description 'Check if the incremental backup has the right type'
|
5
|
-
tags :backup
|
6
|
-
param :incremental_dir, 'Path to existing backup directory'
|
7
|
-
param :online_backup, 'Select for online backup', :flag => true, :default => false
|
8
|
-
manual_detection
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
return unless @incremental_dir
|
13
|
-
|
14
|
-
backup = ForemanMaintain::Utils::Backup.new(@incremental_dir)
|
15
|
-
|
16
|
-
existing_type = backup.backup_type
|
17
|
-
new_type = if @online_backup
|
18
|
-
ForemanMaintain::Utils::Backup::ONLINE_BACKUP
|
19
|
-
else
|
20
|
-
ForemanMaintain::Utils::Backup::OFFLINE_BACKUP
|
21
|
-
end
|
22
|
-
msg = "The existing backup is an #{existing_type} backup, "\
|
23
|
-
"but an #{new_type} backup was requested."
|
24
|
-
assert(existing_type == new_type, msg)
|
25
|
-
|
26
|
-
unless @online_backup
|
27
|
-
msg = "The existing backup has PostgreSQL as a tarball, "\
|
28
|
-
"but the new one will have a dump."
|
29
|
-
assert(!backup.sql_tar_files_exist?, msg)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Procedures::Restore
|
2
|
-
class ReindexDatabases < ForemanMaintain::Procedure
|
3
|
-
include ForemanMaintain::Concerns::SystemService
|
4
|
-
include ForemanMaintain::Concerns::SystemHelpers
|
5
|
-
|
6
|
-
metadata do
|
7
|
-
description 'REINDEX databases'
|
8
|
-
|
9
|
-
confine do
|
10
|
-
feature(:instance).postgresql_local?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
with_spinner('Reindexing the databases') do |spinner|
|
16
|
-
feature(:service).handle_services(spinner, 'start', :only => ['postgresql'])
|
17
|
-
|
18
|
-
spinner.update('Reindexing the databases')
|
19
|
-
execute!('runuser - postgres -c "reindexdb -a"')
|
20
|
-
if check_min_version('python3.11-pulp-ansible', '0.20.0')
|
21
|
-
execute!('runuser -c '\
|
22
|
-
'\'echo "ALTER COLLATION pulp_ansible_semver REFRESH VERSION;"'\
|
23
|
-
'| psql pulpcore\' postgres')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|