foreman_maintain 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/checks/disk/available_space_postgresql12.rb +45 -0
- data/definitions/checks/non_rh_packages.rb +6 -1
- data/definitions/checks/services_up.rb +3 -1
- data/definitions/features/foreman_proxy.rb +5 -4
- data/definitions/features/service.rb +7 -7
- data/definitions/procedures/pulp/remove.rb +28 -18
- data/definitions/scenarios/upgrade_to_satellite_6_8.rb +1 -0
- data/definitions/scenarios/upgrade_to_satellite_6_9.rb +1 -0
- data/lib/foreman_maintain/concerns/base_database.rb +1 -1
- data/lib/foreman_maintain/concerns/downstream.rb +24 -26
- data/lib/foreman_maintain/concerns/system_helpers.rb +25 -0
- data/lib/foreman_maintain/runner.rb +8 -2
- data/lib/foreman_maintain/utils/disk/io_device.rb +4 -0
- data/lib/foreman_maintain/utils/facter.rb +0 -4
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7e6e1bff90945614408bb1ae3e73b9a12fd43d75d7d164da74c9292e87f7d56
|
4
|
+
data.tar.gz: 8f7d7d509bd2e88738a9025bd53c2a09f21933a65c4d1ce617ade128a2473542
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69b30ba9d0f4aa6bd74ac5ec609c8e6baaa26954aee7b50291c244dd90571546381ba7f929ec36466eae92a745e62f9ce5855a5f671c851b87a8cb5ecc69f82f
|
7
|
+
data.tar.gz: 76f1d2b051c4b062e1719303b0b87c450847702b4dd2c784f7afa31195886e46e6fe44a342fad9d3d3d130ac514dc4addbb9bdff32cd03fb75a165024cc9f295
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Checks
|
2
|
+
module Disk
|
3
|
+
class AvailableSpacePostgresql12 < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
label :available_space_for_postgresql12
|
6
|
+
description 'Check to make sure PostgreSQL 12 work directory has enough space for upgrade'
|
7
|
+
confine do
|
8
|
+
(feature(:foreman_database) || feature(:candlepin_database)) && \
|
9
|
+
(file_exists?('/var/lib/pgsql') && \
|
10
|
+
file_exists?('/var/opt/rh/rh-postgresql12'))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
assert(psql_12_available_space >= psql_9_consumed_space, warning_message, :warn => true)
|
16
|
+
end
|
17
|
+
|
18
|
+
def pgsql_dir(version)
|
19
|
+
if version == 9
|
20
|
+
'/var/lib/pgsql/'
|
21
|
+
elsif version == 12
|
22
|
+
'/var/opt/rh/rh-postgresql12/'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def psql_9_consumed_space
|
27
|
+
io_obj = ForemanMaintain::Utils::Disk::IODevice.new(pgsql_dir(9))
|
28
|
+
io_obj.space_used
|
29
|
+
end
|
30
|
+
|
31
|
+
def psql_12_available_space
|
32
|
+
io_obj = ForemanMaintain::Utils::Disk::IODevice.new(pgsql_dir(12))
|
33
|
+
io_obj.available_space
|
34
|
+
end
|
35
|
+
|
36
|
+
def warning_message
|
37
|
+
sat_version = feature(:satellite).current_version.version[0..2]
|
38
|
+
"Satellite #{sat_version} uses PostgreSQL 12. \nThis changes PostgreSQL "\
|
39
|
+
"work directory to #{pgsql_dir(12)}\n"\
|
40
|
+
"The new work directory requires at least #{psql_9_consumed_space}"\
|
41
|
+
'MiB free space for upgrade!'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -11,7 +11,8 @@ class Checks::NonRhPackages < ForemanMaintain::Check
|
|
11
11
|
def run
|
12
12
|
rpm_query_format = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH} : %{VENDOR}\n'
|
13
13
|
all_packages = package_manager.list_installed_packages(rpm_query_format)
|
14
|
-
non_rh_packages = all_packages -
|
14
|
+
non_rh_packages = all_packages - \
|
15
|
+
all_packages.grep(Regexp.union(rh_regexp_list + ansible_runner_regexp_list))
|
15
16
|
assert(non_rh_packages.empty?, error_msg(non_rh_packages), :warn => true)
|
16
17
|
end
|
17
18
|
|
@@ -26,4 +27,8 @@ class Checks::NonRhPackages < ForemanMaintain::Check
|
|
26
27
|
/-qpid-router-server/, /java-client/, /pulp-client/, /katello-default-ca/, /katello-server-ca/,
|
27
28
|
/katello-ca-consumer/, /gpg-pubkey/, /-tomcat/]
|
28
29
|
end
|
30
|
+
|
31
|
+
def ansible_runner_regexp_list
|
32
|
+
[/ansible-runner/, /[python\d]+-ansible-runner/]
|
33
|
+
end
|
29
34
|
end
|
@@ -6,7 +6,9 @@ class Checks::ServicesUp < ForemanMaintain::Check
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def run
|
9
|
-
|
9
|
+
all_services = feature(:service).existing_services
|
10
|
+
failed_services = feature(:service).filter_disabled_services!('status', all_services).
|
11
|
+
reject(&:running?)
|
10
12
|
restart_procedure = Procedures::Service::Restart.new(
|
11
13
|
:only => failed_services,
|
12
14
|
:wait_for_server_response => true
|
@@ -28,10 +28,11 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def services
|
31
|
-
[
|
32
|
-
|
33
|
-
system_service('
|
34
|
-
|
31
|
+
services = [system_service('foreman-proxy', 40)]
|
32
|
+
if check_max_version('foreman-proxy', '2.4')
|
33
|
+
services << system_service('smart_proxy_dynflow_core', 20)
|
34
|
+
end
|
35
|
+
services
|
35
36
|
end
|
36
37
|
|
37
38
|
def features
|
@@ -43,6 +43,13 @@ class Features::Service < ForemanMaintain::Feature
|
|
43
43
|
action_word_modified(action) + 'ed'
|
44
44
|
end
|
45
45
|
|
46
|
+
def filter_disabled_services!(action, service_list)
|
47
|
+
if %w[start stop restart status].include?(action)
|
48
|
+
service_list.select!(&:enabled?)
|
49
|
+
end
|
50
|
+
service_list
|
51
|
+
end
|
52
|
+
|
46
53
|
private
|
47
54
|
|
48
55
|
def use_system_service(action, options, spinner)
|
@@ -135,13 +142,6 @@ class Features::Service < ForemanMaintain::Feature
|
|
135
142
|
end
|
136
143
|
# rubocop:enable Metrics/AbcSize
|
137
144
|
|
138
|
-
def filter_disabled_services!(action, service_list)
|
139
|
-
if %w[start stop restart status].include?(action)
|
140
|
-
service_list.select!(&:enabled?)
|
141
|
-
end
|
142
|
-
service_list
|
143
|
-
end
|
144
|
-
|
145
145
|
def include_unregistered_services(service_list, services_filter)
|
146
146
|
return service_list unless services_filter
|
147
147
|
return service_list unless services_filter.any?
|
@@ -22,26 +22,38 @@ module Procedures::Pulp
|
|
22
22
|
]
|
23
23
|
end
|
24
24
|
|
25
|
+
# rubocop:disable Metrics/MethodLength
|
25
26
|
def pulp_packages
|
26
|
-
[
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
possible = %w[pulp-admin-client pulp-agent pulp-consumer-client pulp-deb-admin-extensions
|
28
|
+
pulp-deb-plugins pulp-docker-admin-extensions pulp-docker-plugins
|
29
|
+
pulp-nodes-admin-extensions pulp-nodes-child pulp-nodes-common
|
30
|
+
pulp-nodes-consumer-extensions pulp-nodes-parent pulp-ostree-admin-extensions
|
31
|
+
pulp-ostree-plugins pulp-puppet-admin-extensions
|
32
|
+
pulp-puppet-consumer-extensions pulp-puppet-handlers pulp-puppet-plugins
|
33
|
+
pulp-puppet-tools pulp-python-admin-extensions pulp-python-plugins
|
34
|
+
pulp-rpm-admin-extensions pulp-rpm-consumer-extensions pulp-rpm-handlers
|
35
|
+
pulp-rpm-plugins pulp-rpm-yumplugins pulp-selinux pulp-server python-bson
|
36
|
+
python-crane python-isodate python-mongoengine python-nectar
|
37
|
+
python-pulp-agent-lib python-pulp-bindings python-pulp-client-lib
|
38
|
+
python-pulp-common python-pulp-deb-common python-pulp-devel
|
39
|
+
python-pulp-docker-common python-pulp-integrity python-pulp-manifest
|
40
|
+
python-pulp-oid_validation python-pulp-ostree-common python-pulp-puppet-common
|
41
|
+
python-pulp-python-common python-pulp-repoauth python-pulp-rpm-common
|
42
|
+
python-pulp-streamer python-pymongo python-pymongo-gridfs python2-amqp
|
43
|
+
python2-billiard python2-celery python2-debpkgr python2-django python2-kombu
|
44
|
+
python2-solv python2-vine pulp-katello]
|
45
|
+
|
46
|
+
@installed_pulp_packages ||= possible.select { |pkg| find_package(pkg) }
|
47
|
+
@installed_pulp_packages
|
36
48
|
end
|
37
49
|
|
38
50
|
def data_dir_removal_cmds
|
39
|
-
pulp_data_dirs.
|
51
|
+
pulp_data_dirs.select { |dir| File.directory?(dir) }.map { |dir| "rm -rf #{dir}" }
|
40
52
|
end
|
41
53
|
|
42
54
|
def ask_to_proceed(rm_cmds)
|
43
55
|
question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n" \
|
44
|
-
"\n#
|
56
|
+
"\n# rpm -e #{pulp_packages.join(' ')}" \
|
45
57
|
"\n# yum remove rh-mongodb34-*" \
|
46
58
|
"\n\nAll pulp2 data will be removed.\n"
|
47
59
|
question += rm_cmds.collect { |cmd| "\n# #{cmd}" }.join
|
@@ -52,18 +64,18 @@ module Procedures::Pulp
|
|
52
64
|
|
53
65
|
def run
|
54
66
|
rm_cmds = data_dir_removal_cmds
|
55
|
-
ask_to_proceed(rm_cmds)
|
67
|
+
ask_to_proceed(rm_cmds) if rm_cmds.any?
|
56
68
|
|
57
69
|
remove_pulp
|
58
70
|
|
59
71
|
remove_mongo
|
60
72
|
|
61
|
-
delete_pulp_data(rm_cmds)
|
73
|
+
delete_pulp_data(rm_cmds) if rm_cmds.any?
|
62
74
|
end
|
63
75
|
|
64
76
|
def remove_pulp
|
65
77
|
with_spinner('Removing pulp2 packages') do
|
66
|
-
|
78
|
+
execute!("rpm -e #{pulp_packages.join(' ')}")
|
67
79
|
end
|
68
80
|
end
|
69
81
|
|
@@ -76,9 +88,7 @@ module Procedures::Pulp
|
|
76
88
|
def delete_pulp_data(rm_cmds)
|
77
89
|
with_spinner('Deleting pulp2 data directories') do |spinner|
|
78
90
|
rm_cmds.each do |cmd|
|
79
|
-
|
80
|
-
execute!(cmd)
|
81
|
-
end
|
91
|
+
execute!(cmd)
|
82
92
|
end
|
83
93
|
spinner.update('Done deleting pulp2 data directories')
|
84
94
|
end
|
@@ -28,6 +28,7 @@ module Scenarios::Satellite_6_8
|
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
30
|
add_step(Checks::Foreman::CheckpointSegments)
|
31
|
+
add_step(Checks::Disk::AvailableSpacePostgresql12)
|
31
32
|
add_step(Checks::Repositories::Validate.new(:version => '6.8'))
|
32
33
|
end
|
33
34
|
end
|
@@ -28,6 +28,7 @@ module Scenarios::Satellite_6_9
|
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
30
|
add_step(Checks::Foreman::CheckpointSegments)
|
31
|
+
add_step(Checks::Disk::AvailableSpacePostgresql12)
|
31
32
|
add_step(Checks::Repositories::Validate.new(:version => '6.9'))
|
32
33
|
end
|
33
34
|
end
|
@@ -62,53 +62,51 @@ module ForemanMaintain
|
|
62
62
|
|
63
63
|
def rh_repos(server_version)
|
64
64
|
server_version = version(server_version)
|
65
|
-
|
66
|
-
rh_repos = main_rh_repos(rh_version_major)
|
67
|
-
|
65
|
+
rh_repos = main_rh_repos
|
68
66
|
server_version_full = "#{server_version.major}.#{server_version.minor}"
|
69
|
-
rh_repos.concat(product_specific_repos(
|
70
|
-
|
67
|
+
rh_repos.concat(product_specific_repos(server_version_full))
|
71
68
|
if server_version > version('6.3')
|
72
|
-
rh_repos << ansible_repo(server_version
|
69
|
+
rh_repos << ansible_repo(server_version)
|
73
70
|
end
|
74
71
|
|
75
72
|
rh_repos
|
76
73
|
end
|
77
74
|
|
78
|
-
def ansible_repo(server_version
|
75
|
+
def ansible_repo(server_version)
|
79
76
|
if server_version >= version('6.8')
|
80
|
-
"rhel-#{
|
77
|
+
"rhel-#{el_major_version}-server-ansible-2.9-rpms"
|
81
78
|
elsif server_version >= version('6.6')
|
82
|
-
"rhel-#{
|
79
|
+
"rhel-#{el_major_version}-server-ansible-2.8-rpms"
|
83
80
|
elsif server_version >= version('6.4')
|
84
|
-
"rhel-#{
|
81
|
+
"rhel-#{el_major_version}-server-ansible-2.6-rpms"
|
85
82
|
end
|
86
83
|
end
|
87
84
|
|
88
|
-
|
89
|
-
def product_specific_repos(rh_version_major, full_version)
|
85
|
+
def product_specific_repos(full_version)
|
90
86
|
repos = []
|
91
87
|
repos << if ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
|
92
|
-
"rhel-server-#{
|
88
|
+
"rhel-server-#{el_major_version}-#{package_name}-6-beta-rpms"
|
93
89
|
else
|
94
|
-
"rhel-#{
|
90
|
+
"rhel-#{el_major_version}-server-#{package_name}-#{full_version}-rpms"
|
95
91
|
end
|
92
|
+
repos << puppet4_repo(full_version) unless puppet4_repo(full_version).nil?
|
93
|
+
repos.concat(common_repos(full_version))
|
94
|
+
end
|
95
|
+
|
96
|
+
def puppet4_repo(full_version)
|
96
97
|
if current_minor_version == '6.3' && full_version.to_s != '6.4' && (
|
97
98
|
feature(:puppet_server) && feature(:puppet_server).puppet_version.major == 4)
|
98
|
-
|
99
|
-
repos << "rhel-#{rh_version_major}-server-satellite-tools-6.3-puppet4-rpms"
|
99
|
+
"rhel-#{el_major_version}-server-#{package_name}-tools-6.3-puppet4-rpms"
|
100
100
|
end
|
101
|
-
|
102
|
-
repos.concat(common_repos(rh_version_major, full_version))
|
103
101
|
end
|
104
102
|
|
105
|
-
def common_repos(
|
103
|
+
def common_repos(full_version)
|
106
104
|
repos_arrary = if ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
|
107
|
-
["rhel-#{
|
108
|
-
"rhel-#{
|
105
|
+
["rhel-#{el_major_version}-server-satellite-maintenance-6-beta-rpms",
|
106
|
+
"rhel-#{el_major_version}-server-satellite-tools-6-beta-rpms"]
|
109
107
|
else
|
110
|
-
["rhel-#{
|
111
|
-
"rhel-#{
|
108
|
+
["rhel-#{el_major_version}-server-satellite-maintenance-6-rpms",
|
109
|
+
"rhel-#{el_major_version}-server-satellite-tools-#{full_version}-rpms"]
|
112
110
|
end
|
113
111
|
|
114
112
|
return repos_arrary.first(1) if feature(:satellite)
|
@@ -116,9 +114,9 @@ module ForemanMaintain
|
|
116
114
|
repos_arrary
|
117
115
|
end
|
118
116
|
|
119
|
-
def main_rh_repos
|
120
|
-
["rhel-#{
|
121
|
-
"rhel-server-rhscl-#{
|
117
|
+
def main_rh_repos
|
118
|
+
["rhel-#{el_major_version}-server-rpms",
|
119
|
+
"rhel-server-rhscl-#{el_major_version}-rpms"]
|
122
120
|
end
|
123
121
|
|
124
122
|
def version_from_source
|
@@ -192,6 +192,31 @@ module ForemanMaintain
|
|
192
192
|
yield current_version
|
193
193
|
end
|
194
194
|
end
|
195
|
+
|
196
|
+
def os_facts
|
197
|
+
facter = ForemanMaintain::Utils::Facter.path
|
198
|
+
@os_facts ||= JSON.parse(execute("#{facter} -j os"))
|
199
|
+
end
|
200
|
+
|
201
|
+
def el?
|
202
|
+
os_facts['os']['family'] == 'RedHat'
|
203
|
+
end
|
204
|
+
|
205
|
+
def debian?
|
206
|
+
os_facts['os']['family'] == 'Debian'
|
207
|
+
end
|
208
|
+
|
209
|
+
def el7?
|
210
|
+
os_facts['os']['release']['major'] = '7' && el?
|
211
|
+
end
|
212
|
+
|
213
|
+
def el8?
|
214
|
+
os_facts['os']['release']['major'] = '8' && el?
|
215
|
+
end
|
216
|
+
|
217
|
+
def el_major_version
|
218
|
+
return os_facts['os']['release']['major'] if el?
|
219
|
+
end
|
195
220
|
end
|
196
221
|
end
|
197
222
|
end
|
@@ -15,6 +15,7 @@ module ForemanMaintain
|
|
15
15
|
@reporter = reporter
|
16
16
|
@scenarios = Array(scenarios)
|
17
17
|
@quit = false
|
18
|
+
@rescue = false
|
18
19
|
@last_scenario = nil
|
19
20
|
@last_scenario_continuation_confirmed = false
|
20
21
|
@exit_code = 0
|
@@ -29,12 +30,17 @@ module ForemanMaintain
|
|
29
30
|
@assumeyes
|
30
31
|
end
|
31
32
|
|
33
|
+
def rescue?
|
34
|
+
@rescue
|
35
|
+
end
|
36
|
+
|
32
37
|
def run
|
33
38
|
@scenarios.each do |scenario|
|
34
39
|
run_scenario(scenario)
|
35
40
|
next unless @quit
|
36
41
|
|
37
42
|
if @rescue_scenario
|
43
|
+
@rescue = true
|
38
44
|
logger.debug('=== Rescue scenario found. Executing ===')
|
39
45
|
execute_scenario_steps(@rescue_scenario, true)
|
40
46
|
end
|
@@ -44,10 +50,10 @@ module ForemanMaintain
|
|
44
50
|
|
45
51
|
def run_scenario(scenario)
|
46
52
|
return if scenario.steps.empty?
|
47
|
-
raise 'The runner is already in quit state' if quit?
|
53
|
+
raise 'The runner is already in quit state' if quit? && !rescue?
|
48
54
|
|
49
55
|
confirm_scenario(scenario)
|
50
|
-
return if quit?
|
56
|
+
return if quit? && !rescue?
|
51
57
|
|
52
58
|
execute_scenario_steps(scenario)
|
53
59
|
ensure
|
@@ -26,6 +26,10 @@ module ForemanMaintain
|
|
26
26
|
execute!("df #{dir}|awk {'print $5'}|tail -1").to_i
|
27
27
|
end
|
28
28
|
|
29
|
+
def space_used
|
30
|
+
convert_kb_to_mb(execute!("du -ks #{dir} | awk {'print $1'}").to_i)
|
31
|
+
end
|
32
|
+
|
29
33
|
private
|
30
34
|
|
31
35
|
# In fio command, --direct option bypass the cache page
|
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.8.
|
4
|
+
version: 0.8.2
|
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: 2021-
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- definitions/checks/check_tmout.rb
|
127
127
|
- definitions/checks/disk/available_space.rb
|
128
128
|
- definitions/checks/disk/available_space_candlepin.rb
|
129
|
+
- definitions/checks/disk/available_space_postgresql12.rb
|
129
130
|
- definitions/checks/disk/performance.rb
|
130
131
|
- definitions/checks/env_proxy.rb
|
131
132
|
- definitions/checks/foreman/check_checkpoint_segments.rb
|