foreman_maintain 0.6.9 → 0.6.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/definitions/checks/foreman/check_checkpoint_segments.rb +51 -0
- data/definitions/checks/foreman/check_duplicate_permission.rb +33 -0
- data/definitions/checks/foreman_proxy/check_tftp_storage.rb +2 -3
- data/definitions/features/installer.rb +4 -0
- data/definitions/procedures/foreman/remove_duplicate_permissions.rb +70 -0
- data/definitions/procedures/installer/upgrade.rb +1 -1
- data/definitions/scenarios/upgrade_to_satellite_6_8.rb +1 -0
- data/lib/foreman_maintain/cli/packages_command.rb +1 -1
- data/lib/foreman_maintain/cli/upgrade_command.rb +3 -0
- data/lib/foreman_maintain/concerns/downstream.rb +4 -2
- data/lib/foreman_maintain/reporter/cli_reporter.rb +1 -1
- data/lib/foreman_maintain/runner.rb +1 -0
- data/lib/foreman_maintain/scenario.rb +5 -2
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e382b3653ec4332ef6bc891b83e92263874dfc079fb84c1f3db951696804832e
|
4
|
+
data.tar.gz: 03b8467289528688c03ed6ad7b8361befee931c9eb0d51a897aa38a755b9ad8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f9b4071adbda3fb4f39c84a6c02891aa4e54c0138d8245dfb2da93844bbc6b51e8db88a0424a006fde8563b7b4806b833176caeacaaa9c4b3101ef23824c4f0
|
7
|
+
data.tar.gz: a00abc28ccc812b76de1ca75849f471bd16944fb3cd8bc7ead833f0c077c17e1860626ba6e9c52af834fa1f21c2a6c6b0c331551bc435d921926fdc694cda045
|
data/README.md
CHANGED
@@ -488,6 +488,15 @@ Here, 0=ON & 1=OFF.
|
|
488
488
|
If users would like to check whether maintenance-mode is ON/OFF on system in their external script then
|
489
489
|
they can use subcommand `foreman-maintain maintenance-mode is-enabled`.
|
490
490
|
|
491
|
+
## Exit codes with special meanings -
|
492
|
+
|
493
|
+
Every command returns an exit code. Any other exit status than 0 indicates a failure of some kind. Foreman Maintain uses following exit codes with special meaning.
|
494
|
+
|
495
|
+
| Exit Code | Description |
|
496
|
+
| -----------| -----------------------------------|
|
497
|
+
| 75 | Temporary failure and needs re-run |
|
498
|
+
| 78 | Command executed with warning(s) |
|
499
|
+
|
491
500
|
## How to contribute?
|
492
501
|
|
493
502
|
Generally, follow the [Foreman guidelines](https://theforeman.org/contribute.html). For code-related contributions, fork this project and send a pull request with all changes. Some things to keep in mind:
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Checks
|
2
|
+
module Foreman
|
3
|
+
class CheckpointSegments < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
label :check_postgresql_checkpoint_segments
|
6
|
+
description 'Check if checkpoint_segments configuration exists on the system'
|
7
|
+
confine do
|
8
|
+
feature(:foreman) && feature(:installer) &&
|
9
|
+
File.exist?(feature(:installer).custom_hiera_file)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
failure_message = check_custom_hiera
|
15
|
+
fail! failure_message if failure_message
|
16
|
+
end
|
17
|
+
|
18
|
+
# rubocop:disable Metrics/MethodLength
|
19
|
+
def check_custom_hiera
|
20
|
+
hiera_file = feature(:installer).custom_hiera_file
|
21
|
+
if (config = YAML.load_file(hiera_file)) &&
|
22
|
+
config.key?('postgresql::server::config_entries')
|
23
|
+
if config['postgresql::server::config_entries'].nil?
|
24
|
+
return <<-MESSAGE.strip_heredoc
|
25
|
+
ERROR: 'postgresql::server::config_entries' cannot be null.
|
26
|
+
Please remove it from following file and re-run the command.
|
27
|
+
- #{hiera_file}
|
28
|
+
MESSAGE
|
29
|
+
elsif config['postgresql::server::config_entries'].key?('checkpoint_segments')
|
30
|
+
message = <<-MESSAGE.strip_heredoc
|
31
|
+
ERROR: Tuning option 'checkpoint_segments' found.
|
32
|
+
This option is no longer valid for PostgreSQL 9.5 or newer.
|
33
|
+
Please remove it from following file and re-run the command.
|
34
|
+
- #{hiera_file}
|
35
|
+
MESSAGE
|
36
|
+
if feature(:katello)
|
37
|
+
message += <<-MESSAGE.strip_heredoc
|
38
|
+
The presence of checkpoint_segments in #{hiera_file} indicates manual tuning.
|
39
|
+
Manual tuning can override values provided by the --tuning parameter.
|
40
|
+
Review #{hiera_file} for values that are already provided by the built in tuning profiles.
|
41
|
+
Built in tuning profiles also provide a supported upgrade path.
|
42
|
+
MESSAGE
|
43
|
+
end
|
44
|
+
return message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
# rubocop:enable Metrics/MethodLength
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Checks
|
2
|
+
module Foreman
|
3
|
+
class CheckDuplicatePermissions < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
label :duplicate_permissions
|
6
|
+
for_feature :foreman_database
|
7
|
+
description 'Check for duplicate permissions from database'
|
8
|
+
tags :pre_upgrade
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
duplicate_permissions = find_duplicate_permissions
|
13
|
+
assert(
|
14
|
+
duplicate_permissions.empty?,
|
15
|
+
'Duplicate permissions in your database',
|
16
|
+
:next_steps => [
|
17
|
+
Procedures::Foreman::RemoveDuplicatePermissions.new
|
18
|
+
]
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def find_duplicate_permissions
|
23
|
+
feature(:foreman_database).query(self.class.query_to_get_duplicate_permission)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.query_to_get_duplicate_permission
|
27
|
+
<<-SQL
|
28
|
+
SELECT id,name FROM permissions p WHERE (SELECT count(name) FROM permissions pr WHERE p.name =pr.name) > 1
|
29
|
+
SQL
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -22,10 +22,9 @@ module Checks::ForemanProxy
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def old_files_from_tftp_boot
|
25
|
-
Dir.
|
25
|
+
Dir.glob("#{tftp_boot_directory}*-{vmlinuz,initrd.img}").map do |file|
|
26
26
|
unless File.directory?(file)
|
27
|
-
|
28
|
-
file_path if File.mtime(file_path) + (token_duration * 60) < Time.now
|
27
|
+
file if File.mtime(file) + (token_duration * 60) < Time.now
|
29
28
|
end
|
30
29
|
end.compact
|
31
30
|
end
|
@@ -53,6 +53,10 @@ class Features::Installer < ForemanMaintain::Feature
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def custom_hiera_file
|
57
|
+
@custom_hiera_file ||= File.join(config_directory, 'custom-hiera.yaml')
|
58
|
+
end
|
59
|
+
|
56
60
|
def can_upgrade?
|
57
61
|
@installer_type == :scenarios || @installer_type == :legacy_katello
|
58
62
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Procedures::Foreman
|
2
|
+
class RemoveDuplicatePermissions < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
for_feature :foreman_database
|
5
|
+
description 'Remove duplicate permissions from database'
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
duplicate_permissions = feature(:foreman_database).query(
|
10
|
+
Checks::Foreman::CheckDuplicatePermissions.query_to_get_duplicate_permission
|
11
|
+
).group_by { |permission| permission['name'] }
|
12
|
+
unassigned_permissions = []
|
13
|
+
duplicate_permissions.each_value do |permissions|
|
14
|
+
permission_ids = permissions.map { |i| i['id'] }
|
15
|
+
filterings = check_permissions_assign_to_filter(permission_ids)
|
16
|
+
assigned_permissions = filterings.keys
|
17
|
+
unassigned_permissions << permission_ids - assigned_permissions
|
18
|
+
fix_permissions(assigned_permissions) if assigned_permissions.length > 1
|
19
|
+
end
|
20
|
+
delete_permission(unassigned_permissions.flatten) unless unassigned_permissions.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def check_permissions_assign_to_filter(permission_ids)
|
26
|
+
sql = <<-SQL
|
27
|
+
SELECT id, filter_id, permission_id FROM filterings WHERE permission_id IN (#{permission_ids.join(',')})
|
28
|
+
SQL
|
29
|
+
feature(:foreman_database).query(sql).group_by { |filtering| filtering['permission_id'] }
|
30
|
+
end
|
31
|
+
|
32
|
+
def fix_permissions(assigned_permissions)
|
33
|
+
persist_permission = assigned_permissions.shift
|
34
|
+
filter_ids = filters_for_permission(persist_permission)
|
35
|
+
update_filtering(assigned_permissions, persist_permission, filter_ids)
|
36
|
+
delete_filtering(assigned_permissions)
|
37
|
+
delete_permission(assigned_permissions)
|
38
|
+
end
|
39
|
+
|
40
|
+
def filters_for_permission(permission)
|
41
|
+
feature(:foreman_database).query(
|
42
|
+
"SELECT filter_id FROM filterings WHERE permission_id = #{permission.to_i}"
|
43
|
+
).map { |filter| filter['filter_id'] }
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_filtering(old_ids, new_id, filter_ids)
|
47
|
+
sql = <<-SQL
|
48
|
+
WITH rows AS (
|
49
|
+
UPDATE filterings SET permission_id = '#{new_id}' WHERE permission_id IN (#{old_ids.join(',')}) AND filter_id NOT IN (#{filter_ids.join(',')})
|
50
|
+
RETURNING id
|
51
|
+
)
|
52
|
+
SELECT id
|
53
|
+
FROM rows
|
54
|
+
SQL
|
55
|
+
feature(:foreman_database).query(sql)
|
56
|
+
end
|
57
|
+
|
58
|
+
def delete_filtering(permission_ids)
|
59
|
+
feature(:foreman_database).psql(
|
60
|
+
"DELETE FROM filterings where permission_id IN (#{permission_ids.join(',')})"
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete_permission(permission_ids)
|
65
|
+
feature(:foreman_database).psql(
|
66
|
+
"DELETE FROM permissions where id IN (#{permission_ids.join(',')})"
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -38,7 +38,7 @@ module ForemanMaintain
|
|
38
38
|
|
39
39
|
subcommand 'update', 'Update packages in an unlocked session' do
|
40
40
|
interactive_option
|
41
|
-
parameter '[PACKAGES ...
|
41
|
+
parameter '[PACKAGES] ...', 'packages to update', :attribute_name => :packages
|
42
42
|
|
43
43
|
def execute
|
44
44
|
run_scenarios_and_exit(
|
@@ -53,7 +53,10 @@ module ForemanMaintain
|
|
53
53
|
end
|
54
54
|
|
55
55
|
subcommand 'list-versions', 'List versions this system is upgradable to' do
|
56
|
+
disable_self_upgrade_option
|
57
|
+
|
56
58
|
def execute
|
59
|
+
ForemanMaintain.perform_self_upgrade unless disable_self_upgrade?
|
57
60
|
print_versions(UpgradeRunner.available_targets)
|
58
61
|
end
|
59
62
|
end
|
@@ -72,7 +72,9 @@ module ForemanMaintain
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def ansible_repo(server_version, rh_version_major)
|
75
|
-
if server_version >= version('6.
|
75
|
+
if server_version >= version('6.8')
|
76
|
+
"rhel-#{rh_version_major}-server-ansible-2.9-rpms"
|
77
|
+
elsif server_version >= version('6.6')
|
76
78
|
"rhel-#{rh_version_major}-server-ansible-2.8-rpms"
|
77
79
|
elsif server_version >= version('6.4')
|
78
80
|
"rhel-#{rh_version_major}-server-ansible-2.6-rpms"
|
@@ -105,7 +107,7 @@ module ForemanMaintain
|
|
105
107
|
"rhel-#{rh_version_major}-server-satellite-tools-#{full_version}-rpms"]
|
106
108
|
end
|
107
109
|
|
108
|
-
return repos_arrary.first(1) if feature(:
|
110
|
+
return repos_arrary.first(1) if feature(:satellite)
|
109
111
|
|
110
112
|
repos_arrary
|
111
113
|
end
|
@@ -276,7 +276,7 @@ module ForemanMaintain
|
|
276
276
|
|
277
277
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
278
278
|
def scenario_failure_message(scenario)
|
279
|
-
return if scenario.passed?
|
279
|
+
return if scenario.passed? && !scenario.warning?
|
280
280
|
message = []
|
281
281
|
message << <<-MESSAGE.strip_heredoc
|
282
282
|
Scenario [#{scenario.description}] failed.
|
@@ -129,8 +129,11 @@ module ForemanMaintain
|
|
129
129
|
|
130
130
|
def passed?
|
131
131
|
(steps_with_abort(:whitelisted => false) +
|
132
|
-
steps_with_error(:whitelisted => false)
|
133
|
-
|
132
|
+
steps_with_error(:whitelisted => false)).empty?
|
133
|
+
end
|
134
|
+
|
135
|
+
def warning?
|
136
|
+
!steps_with_warning(:whitelisted => false).empty?
|
134
137
|
end
|
135
138
|
|
136
139
|
def failed?
|
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: 0.6.
|
4
|
+
version: 0.6.10
|
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: 2020-
|
11
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -127,7 +127,9 @@ files:
|
|
127
127
|
- definitions/checks/disk/available_space.rb
|
128
128
|
- definitions/checks/disk/performance.rb
|
129
129
|
- definitions/checks/env_proxy.rb
|
130
|
+
- definitions/checks/foreman/check_checkpoint_segments.rb
|
130
131
|
- definitions/checks/foreman/check_corrupted_roles.rb
|
132
|
+
- definitions/checks/foreman/check_duplicate_permission.rb
|
131
133
|
- definitions/checks/foreman/check_duplicate_roles.rb
|
132
134
|
- definitions/checks/foreman/db_up.rb
|
133
135
|
- definitions/checks/foreman/facts_names.rb
|
@@ -226,6 +228,7 @@ files:
|
|
226
228
|
- definitions/procedures/foreman/apipie_cache.rb
|
227
229
|
- definitions/procedures/foreman/fix_corrupted_roles.rb
|
228
230
|
- definitions/procedures/foreman/remove_duplicate_obsolete_roles.rb
|
231
|
+
- definitions/procedures/foreman/remove_duplicate_permissions.rb
|
229
232
|
- definitions/procedures/foreman_docker/remove_foreman_docker.rb
|
230
233
|
- definitions/procedures/foreman_openscap/invalid_report_associations.rb
|
231
234
|
- definitions/procedures/foreman_proxy/features.rb
|