foreman_maintain 1.8.1 → 1.9.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/foreman/check_external_db_evr_permissions.rb +61 -0
- data/definitions/checks/restore/validate_backup.rb +4 -9
- data/definitions/features/foreman_proxy.rb +1 -0
- data/definitions/features/puppet_server.rb +0 -4
- data/definitions/procedures/pulpcore/container_handle_image_metadata.rb +1 -2
- data/definitions/procedures/repositories/index_katello_repositories_container_metadata.rb +1 -2
- data/definitions/scenarios/foreman_upgrade.rb +1 -0
- data/definitions/scenarios/satellite_upgrade.rb +1 -0
- data/lib/foreman_maintain/utils/backup.rb +3 -56
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9209b1f3f4a9910f6a635cd5876edbb3f9fa59e1381e532ae4961e18627fe638
|
4
|
+
data.tar.gz: 8a7f2e3ba17c629eea5535f86b94bb1be409620d520da3c0d96c61c1aea5009f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97e0f20269bc3b480bc429e91d7d119520ea4592162362f75efd42e9a4bc71200f4d13ff07b7103185200293826a3d887db265f99a2b7c94c385bd94a2eab352
|
7
|
+
data.tar.gz: de0dce8771c46602be6124a04a58b935529c051b2efb7d7f38fc8b5dd25e7b0d2203580335eb9038f2e6b21b79e0dab87a361e38ba173cb6f936bcfcd7378beb
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Checks
|
2
|
+
module Foreman
|
3
|
+
class CheckExternalDbEvrPermissions < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
label :external_db_evr_permissions
|
6
|
+
for_feature :foreman_database
|
7
|
+
description 'Check that external databases have proper EVR extension permissions'
|
8
|
+
tags :pre_upgrade
|
9
|
+
confine do
|
10
|
+
feature(:foreman_database) && !feature(:foreman_database).local? && feature(:katello)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
return true unless evr_exists?
|
16
|
+
|
17
|
+
error_msg = 'The evr extension is not owned by the foreman database owner. ' \
|
18
|
+
'Please run the following command on the external foreman database to fix it: ' \
|
19
|
+
'UPDATE pg_extension SET extowner = (SELECT oid FROM pg_authid WHERE ' \
|
20
|
+
"rolname='#{foreman_db_user}') WHERE extname='evr';"
|
21
|
+
fail!(error_msg) unless foreman_owns_evr?
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def foreman_db_user
|
27
|
+
feature(:foreman_database).configuration['username'] || 'foreman'
|
28
|
+
end
|
29
|
+
|
30
|
+
def evr_exists?
|
31
|
+
evr_exists = feature(:foreman_database).query(query_for_evr_existence)
|
32
|
+
return false if evr_exists.empty?
|
33
|
+
return evr_exists.first['evr_exists'] == '1'
|
34
|
+
end
|
35
|
+
|
36
|
+
def foreman_owns_evr?
|
37
|
+
evr_owned_by_postgres = feature(:foreman_database).query(query_if_postgres_owns_evr)
|
38
|
+
unless evr_owned_by_postgres.empty?
|
39
|
+
return evr_owned_by_postgres.first['evr_owned_by_postgres'] == '0'
|
40
|
+
end
|
41
|
+
failure_msg = 'Could not determine if the evr extension is owned by the ' \
|
42
|
+
'foreman database owner. Check that the foreman database is accessible ' \
|
43
|
+
"and that the database connection configuration is up to date."
|
44
|
+
fail!(failure_msg)
|
45
|
+
end
|
46
|
+
|
47
|
+
def query_for_evr_existence
|
48
|
+
<<-SQL
|
49
|
+
SELECT 1 AS evr_exists FROM pg_extension WHERE extname = 'evr'
|
50
|
+
SQL
|
51
|
+
end
|
52
|
+
|
53
|
+
def query_if_postgres_owns_evr
|
54
|
+
<<-SQL
|
55
|
+
SELECT CASE WHEN r.rolname = '#{foreman_db_user}' THEN 0 ELSE 1 END AS evr_owned_by_postgres
|
56
|
+
FROM pg_extension e JOIN pg_roles r ON e.extowner = r.oid WHERE e.extname = 'evr'
|
57
|
+
SQL
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -42,35 +42,30 @@ module Checks::Restore
|
|
42
42
|
def required_katello_files(backup)
|
43
43
|
backup_files_message(
|
44
44
|
backup.katello_online_files.join(', '),
|
45
|
-
backup.katello_offline_files.join(', ')
|
46
|
-
[backup.katello_online_files + backup.katello_offline_files].join(', ')
|
45
|
+
backup.katello_offline_files.join(', ')
|
47
46
|
)
|
48
47
|
end
|
49
48
|
|
50
49
|
def required_fpc_files(backup)
|
51
50
|
backup_files_message(
|
52
51
|
backup.fpc_online_files.join(', '),
|
53
|
-
backup.fpc_offline_files.join(', ')
|
54
|
-
[backup.fpc_online_files + backup.fpc_offline_files].join(', ')
|
52
|
+
backup.fpc_offline_files.join(', ')
|
55
53
|
)
|
56
54
|
end
|
57
55
|
|
58
56
|
def required_foreman_files(backup)
|
59
57
|
backup_files_message(
|
60
58
|
backup.foreman_online_files.join(', '),
|
61
|
-
backup.foreman_offline_files.join(', ')
|
62
|
-
[backup.foreman_online_files + backup.foreman_offline_files].join(', ')
|
59
|
+
backup.foreman_offline_files.join(', ')
|
63
60
|
)
|
64
61
|
end
|
65
62
|
|
66
|
-
def backup_files_message(online_files, offline_files
|
63
|
+
def backup_files_message(online_files, offline_files)
|
67
64
|
message = ''
|
68
65
|
message += 'An online or remote database backup directory contains: '
|
69
66
|
message += "#{online_files}\n"
|
70
67
|
message += 'An offline backup directory contains: '
|
71
68
|
message += "#{offline_files}\n"
|
72
|
-
message += 'A logical backup directory contains: '
|
73
|
-
message += "#{logical_files}\n"
|
74
69
|
message
|
75
70
|
end
|
76
71
|
end
|
@@ -70,6 +70,7 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
70
70
|
configs += ['/var/lib/dhcpd', File.dirname(dhcpd_config_file)]
|
71
71
|
end
|
72
72
|
configs.push('/usr/share/xml/scap') if backup_features.include?('openscap')
|
73
|
+
configs.push('/etc/ansible') if backup_features.include?('ansible')
|
73
74
|
configs
|
74
75
|
end
|
75
76
|
|
@@ -26,10 +26,6 @@ class Features::PuppetServer < ForemanMaintain::Feature
|
|
26
26
|
find_package('puppetserver') ? [system_service('puppetserver', 30)] : []
|
27
27
|
end
|
28
28
|
|
29
|
-
def puppet_version
|
30
|
-
version(execute!("#{puppet_path} --version"))
|
31
|
-
end
|
32
|
-
|
33
29
|
def find_empty_cacert_request_files
|
34
30
|
cmd_output = execute!("find #{cacert_requests_directory} -type f -size 0 | paste -d, -s")
|
35
31
|
cmd_output.split(',')
|
@@ -14,8 +14,7 @@ module Procedures::Pulpcore
|
|
14
14
|
|
15
15
|
feature(:service).handle_services(spinner, 'start', :only => necessary_services)
|
16
16
|
|
17
|
-
spinner.update('Adding image metadata to pulp.
|
18
|
-
'system normally while the task runs in the background.')
|
17
|
+
spinner.update('Adding image metadata to pulp.')
|
19
18
|
execute!(pulpcore_manager('container-handle-image-data'))
|
20
19
|
end
|
21
20
|
end
|
@@ -8,8 +8,7 @@ module Procedures::Repositories
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run
|
11
|
-
with_spinner(
|
12
|
-
'system normally while the task runs in the background.')) do
|
11
|
+
with_spinner('Adding image metadata to Katello.') do
|
13
12
|
execute!('foreman-rake katello:import_container_manifest_labels')
|
14
13
|
end
|
15
14
|
end
|
@@ -40,6 +40,7 @@ module Scenarios::Foreman
|
|
40
40
|
Checks::Disk::AvailableSpaceCandlepin, # if candlepin
|
41
41
|
Checks::Disk::AvailableSpacePostgresql13,
|
42
42
|
Checks::Foreman::ValidateExternalDbVersion, # if external database
|
43
|
+
Checks::Foreman::CheckExternalDbEvrPermissions, # if external database
|
43
44
|
Checks::Foreman::CheckCorruptedRoles,
|
44
45
|
Checks::Foreman::CheckDuplicatePermissions,
|
45
46
|
Checks::Foreman::TuningRequirements, # if katello present
|
@@ -39,6 +39,7 @@ module Scenarios::Satellite
|
|
39
39
|
Checks::Disk::AvailableSpace,
|
40
40
|
Checks::Disk::AvailableSpaceCandlepin, # if candlepin
|
41
41
|
Checks::Foreman::ValidateExternalDbVersion, # if external database
|
42
|
+
Checks::Foreman::CheckExternalDbEvrPermissions, # if external database
|
42
43
|
Checks::Foreman::CheckCorruptedRoles,
|
43
44
|
Checks::Foreman::CheckDuplicatePermissions,
|
44
45
|
Checks::Foreman::TuningRequirements, # if katello present
|
@@ -67,18 +67,15 @@ module ForemanMaintain
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def valid_fpc_backup?
|
70
|
-
fpc_online_backup? || fpc_standard_backup?
|
71
|
-
fpc_hybrid_db_backup?
|
70
|
+
fpc_online_backup? || fpc_standard_backup?
|
72
71
|
end
|
73
72
|
|
74
73
|
def valid_katello_backup?
|
75
|
-
katello_online_backup? || katello_standard_backup?
|
76
|
-
# Katello can have setup where some of dbs are external but not all
|
77
|
-
katello_hybrid_db_backup?
|
74
|
+
katello_online_backup? || katello_standard_backup?
|
78
75
|
end
|
79
76
|
|
80
77
|
def valid_foreman_backup?
|
81
|
-
foreman_standard_backup? || foreman_online_backup?
|
78
|
+
foreman_standard_backup? || foreman_online_backup?
|
82
79
|
end
|
83
80
|
|
84
81
|
def check_file_existence(existence_map)
|
@@ -111,19 +108,6 @@ module ForemanMaintain
|
|
111
108
|
:absent => absent)
|
112
109
|
end
|
113
110
|
|
114
|
-
def katello_logical_backup?
|
115
|
-
present = [:pgsql_data, :candlepin_dump, :foreman_dump, :pulpcore_dump]
|
116
|
-
absent = []
|
117
|
-
check_file_existence(:present => present,
|
118
|
-
:absent => absent)
|
119
|
-
end
|
120
|
-
|
121
|
-
def katello_hybrid_db_backup?
|
122
|
-
all_dbs = { :pgsql_data => %w[candlepin foreman pulpcore] }
|
123
|
-
present, absent = dumps_for_hybrid_db_setup(all_dbs)
|
124
|
-
check_file_existence(:present => present, :absent => absent)
|
125
|
-
end
|
126
|
-
|
127
111
|
def fpc_standard_backup?
|
128
112
|
present = [:pgsql_data]
|
129
113
|
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump]
|
@@ -137,19 +121,6 @@ module ForemanMaintain
|
|
137
121
|
check_file_existence(:present => present, :absent => absent)
|
138
122
|
end
|
139
123
|
|
140
|
-
def fpc_logical_backup?
|
141
|
-
present = [:pulpcore_dump, :pgsql_data]
|
142
|
-
absent = [:candlepin_dump, :foreman_dump]
|
143
|
-
check_file_existence(:present => present, :absent => absent)
|
144
|
-
end
|
145
|
-
|
146
|
-
def fpc_hybrid_db_backup?
|
147
|
-
all_dbs = { :pgsql_data => ['pulpcore'] }
|
148
|
-
present, absent = dumps_for_hybrid_db_setup(all_dbs)
|
149
|
-
absent.concat [:candlepin_dump, :foreman_dump]
|
150
|
-
check_file_existence(:present => present, :absent => absent)
|
151
|
-
end
|
152
|
-
|
153
124
|
def foreman_standard_backup?
|
154
125
|
check_file_existence(:present => [:pgsql_data],
|
155
126
|
:absent => [:candlepin_dump, :foreman_dump, :pulpcore_dump])
|
@@ -160,30 +131,6 @@ module ForemanMaintain
|
|
160
131
|
:absent => [:candlepin_dump, :pgsql_data, :pulpcore_dump])
|
161
132
|
end
|
162
133
|
|
163
|
-
def foreman_logical_backup?
|
164
|
-
check_file_existence(:present => [:pgsql_data, :foreman_dump],
|
165
|
-
:absent => [:candlepin_dump, :pulpcore_dump])
|
166
|
-
end
|
167
|
-
|
168
|
-
def dumps_for_hybrid_db_setup(dbs_hash)
|
169
|
-
present = []
|
170
|
-
absent = []
|
171
|
-
dbs_hash.each do |data_file, dbs|
|
172
|
-
dbs.each do |db|
|
173
|
-
feature_label = "#{db}_database"
|
174
|
-
dump_file = "#{db}_dump"
|
175
|
-
if feature(feature_label.to_sym).local?
|
176
|
-
present |= [data_file]
|
177
|
-
absent << dump_file.to_sym
|
178
|
-
else
|
179
|
-
present << dump_file.to_sym
|
180
|
-
end
|
181
|
-
end
|
182
|
-
absent |= [data_file] unless present.include?(data_file)
|
183
|
-
end
|
184
|
-
[present, absent]
|
185
|
-
end
|
186
|
-
|
187
134
|
def validate_hostname?
|
188
135
|
# make sure that the system hostname is the same as the backup
|
189
136
|
metadata.fetch('hostname', nil) == hostname
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -142,7 +142,6 @@ email: inecas@redhat.com
|
|
142
142
|
executables:
|
143
143
|
- foreman-maintain
|
144
144
|
- foreman-maintain-complete
|
145
|
-
- foreman-maintain-rotate-tar
|
146
145
|
extensions: []
|
147
146
|
extra_rdoc_files:
|
148
147
|
- LICENSE
|
@@ -170,6 +169,7 @@ files:
|
|
170
169
|
- definitions/checks/env_proxy.rb
|
171
170
|
- definitions/checks/foreman/check_corrupted_roles.rb
|
172
171
|
- definitions/checks/foreman/check_duplicate_permission.rb
|
172
|
+
- definitions/checks/foreman/check_external_db_evr_permissions.rb
|
173
173
|
- definitions/checks/foreman/check_puppet_capsules.rb
|
174
174
|
- definitions/checks/foreman/check_tuning_requirements.rb
|
175
175
|
- definitions/checks/foreman/db_up.rb
|