foreman_maintain 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/checks/foreman_proxy/check_tftp_storage.rb +52 -0
- data/definitions/checks/repositories/check_non_rh_repository.rb +2 -2
- data/definitions/features/capsule.rb +2 -1
- data/definitions/features/foreman_proxy.rb +30 -5
- data/definitions/features/foreman_server.rb +1 -1
- data/definitions/procedures/content/switchover.rb +2 -1
- data/definitions/scenarios/restore.rb +13 -0
- data/lib/foreman_maintain/cli/restore_command.rb +2 -1
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +3 -4
- data/definitions/scenarios/upgrade_to_capsule_6_7.rb +0 -88
- data/definitions/scenarios/upgrade_to_capsule_6_7_z.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c41499ac6685ff43c89736a3d159f9b969315668d09bf03c3d4e2517d76a6a8
|
4
|
+
data.tar.gz: fb8ba4ab1265156bb620852859ef7ef962abd403d93c72bfa35e1c5de9a40014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a60e3f5ea25daf3ce10ba16bb48135da6d27cb623c206a990cf6cab092b1e9cf450644973eef1da0c3ab5d5567d506af39b201887afe05d346e59275f273eb5e
|
7
|
+
data.tar.gz: 05bbaba6dd6ddad08aa20da138c105b9931d64e1d7453d2256036abc22b7f381a1e01f7df6fc83dd036744ed50e76cb2e5479dd3c026346e0a5d4f66a7a8c80d
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Checks::ForemanProxy
|
2
|
+
class CheckTftpStorage < ForemanMaintain::Check
|
3
|
+
metadata do
|
4
|
+
label :check_tftp_storage
|
5
|
+
description 'Clean old Kernel and initramfs files from tftp-boot'
|
6
|
+
tags :default
|
7
|
+
confine do
|
8
|
+
feature(:satellite) && feature(:foreman_proxy) &&
|
9
|
+
feature(:foreman_proxy).features.include?('tftp') && non_zero_token_duration?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
if Dir.exist?(tftp_boot_directory)
|
15
|
+
files = old_files_from_tftp_boot
|
16
|
+
assert(files.empty?,
|
17
|
+
'There are old initrd and vmlinuz files present in tftp',
|
18
|
+
:next_steps => Procedures::Files::Remove.new(:files => files))
|
19
|
+
else
|
20
|
+
skip "TFTP #{tftp_boot_directory} directory doesn't exist."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def old_files_from_tftp_boot
|
25
|
+
Dir.entries(tftp_boot_directory).map do |file|
|
26
|
+
unless File.directory?(file)
|
27
|
+
file_path = tftp_boot_directory + file
|
28
|
+
file_path if File.mtime(file_path) + (token_duration * 60) < Time.now
|
29
|
+
end
|
30
|
+
end.compact
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.non_zero_token_duration?
|
34
|
+
lookup_token_duration != 0
|
35
|
+
end
|
36
|
+
|
37
|
+
def tftp_boot_directory
|
38
|
+
@tftp_boot_directory ||= "#{feature(:foreman_proxy).tftp_root_directory}/boot/"
|
39
|
+
end
|
40
|
+
|
41
|
+
def token_duration
|
42
|
+
@token_duration ||= self.class.lookup_token_duration
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.lookup_token_duration
|
46
|
+
data = feature(:foreman_database). \
|
47
|
+
query("select s.value, s.default from settings s \
|
48
|
+
where category = 'Setting::Provisioning' and name = 'token_duration'")
|
49
|
+
YAML.load(data[0]['value'] || data[0]['default'])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -2,7 +2,7 @@ module Checks::Repositories
|
|
2
2
|
class CheckNonRhRepository < ForemanMaintain::Check
|
3
3
|
metadata do
|
4
4
|
label :check_non_redhat_repository
|
5
|
-
description
|
5
|
+
description 'Check whether system has any non Red Hat repositories (e.g.: EPEL) enabled'
|
6
6
|
tags :pre_upgrade
|
7
7
|
confine do
|
8
8
|
feature(:instance).downstream
|
@@ -11,7 +11,7 @@ module Checks::Repositories
|
|
11
11
|
|
12
12
|
def run
|
13
13
|
with_spinner('Checking repositories enabled on the system') do
|
14
|
-
assert(!epel_enabled?, 'System is subscribed to non Red Hat repositories
|
14
|
+
assert(!epel_enabled?, 'System is subscribed to non Red Hat repositories')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -5,7 +5,8 @@ class Features::Capsule < ForemanMaintain::Feature
|
|
5
5
|
label :capsule
|
6
6
|
|
7
7
|
confine do
|
8
|
-
package_manager.installed?(['satellite
|
8
|
+
!package_manager.installed?(['satellite']) &&
|
9
|
+
package_manager.installed?(['satellite-capsule']) ||
|
9
10
|
package_manager.installed?(['capsule-installer'])
|
10
11
|
end
|
11
12
|
end
|
@@ -12,6 +12,9 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
12
12
|
FOREMAN_PROXY_DHCP_YML_PATHS = ['/etc/foreman-proxy/settings.d/dhcp.yml',
|
13
13
|
'/usr/local/etc/foreman-proxy/settings.d/dhcp.yml'].freeze
|
14
14
|
|
15
|
+
FOREMAN_PROXY_TFTP_YML_PATHS = ['/etc/foreman-proxy/settings.d/tftp.yml',
|
16
|
+
'/usr/local/etc/foreman-proxy/settings.d/tftp.yml'].freeze
|
17
|
+
|
15
18
|
def valid_dhcp_configs?
|
16
19
|
dhcp_req_pass? && !syntax_error_exists?
|
17
20
|
end
|
@@ -66,7 +69,7 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
66
69
|
|
67
70
|
configs.push('/var/lib/tftpboot') if backup_features.include?('tftp')
|
68
71
|
configs += ['/var/named/', '/etc/named*'] if backup_features.include?('dns')
|
69
|
-
if backup_features.include?('dhcp')
|
72
|
+
if backup_features.include?('dhcp') && dhcp_isc_provider?
|
70
73
|
configs += ['/var/lib/dhcpd', File.dirname(dhcpd_config_file)]
|
71
74
|
end
|
72
75
|
configs.push('/usr/share/xml/scap') if backup_features.include?('openscap')
|
@@ -113,6 +116,10 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
113
116
|
@dhcpd_config_file ||= lookup_dhcpd_config_file
|
114
117
|
end
|
115
118
|
|
119
|
+
def tftp_root_directory
|
120
|
+
@tftp_root_directory ||= lookup_tftp_root_directory
|
121
|
+
end
|
122
|
+
|
116
123
|
private
|
117
124
|
|
118
125
|
def backup_features(for_features)
|
@@ -209,11 +216,22 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
209
216
|
dhcpd_config_file
|
210
217
|
end
|
211
218
|
|
212
|
-
def
|
213
|
-
|
214
|
-
raise "Couldn't find dhcp.yml file under foreman-proxy" unless
|
219
|
+
def dhcp_yml_path
|
220
|
+
dhcp_path = lookup_into(FOREMAN_PROXY_DHCP_YML_PATHS)
|
221
|
+
raise "Couldn't find dhcp.yml file under foreman-proxy" unless dhcp_path
|
222
|
+
|
223
|
+
dhcp_path
|
224
|
+
end
|
225
|
+
|
226
|
+
def configs_from_dhcp_yml
|
227
|
+
@configs_from_dhcp_yml ||= yaml_load(dhcp_yml_path)
|
228
|
+
end
|
229
|
+
|
230
|
+
def dhcp_isc_provider?
|
231
|
+
configs_from_dhcp_yml[:use_provider] == 'dhcp_isc'
|
232
|
+
end
|
215
233
|
|
216
|
-
|
234
|
+
def lookup_using_dhcp_yml
|
217
235
|
if configs_from_dhcp_yml.key?(:dhcp_config)
|
218
236
|
return configs_from_dhcp_yml[:dhcp_config]
|
219
237
|
elsif configs_from_dhcp_yml.key?(:use_provider)
|
@@ -226,6 +244,13 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
226
244
|
end
|
227
245
|
end
|
228
246
|
|
247
|
+
def lookup_tftp_root_directory
|
248
|
+
tftp_yml_path = lookup_into(FOREMAN_PROXY_TFTP_YML_PATHS)
|
249
|
+
raise "Couldn't find tftp.yml file under foreman-proxy" unless tftp_yml_path
|
250
|
+
|
251
|
+
yaml_load(tftp_yml_path)[:tftproot]
|
252
|
+
end
|
253
|
+
|
229
254
|
def yaml_load(path)
|
230
255
|
YAML.load_file(path) || {}
|
231
256
|
end
|
@@ -15,7 +15,8 @@ module Procedures::Content
|
|
15
15
|
puts 'Re-running the installer to switch specified content over to pulp3'
|
16
16
|
args = ['--foreman-proxy-content-proxy-pulp-isos-to-pulpcore=true',
|
17
17
|
'--katello-use-pulp-2-for-file=false',
|
18
|
-
'--katello-use-pulp-2-for-docker=false'
|
18
|
+
'--katello-use-pulp-2-for-docker=false',
|
19
|
+
'--katello-use-pulp-2-for-yum=false']
|
19
20
|
feature(:installer).run(args.join(' '))
|
20
21
|
end
|
21
22
|
end
|
@@ -20,6 +20,7 @@ module ForemanMaintain::Scenarios
|
|
20
20
|
Checks::Restore::ValidateHostname,
|
21
21
|
Procedures::Selinux::SetFileSecurity,
|
22
22
|
Procedures::Restore::Configs)
|
23
|
+
add_step_with_context(Procedures::Crond::Stop) if feature(:cron)
|
23
24
|
unless backup.incremental?
|
24
25
|
add_steps_with_context(Procedures::Restore::EnsureMongoEngineMatches,
|
25
26
|
Procedures::Restore::InstallerReset)
|
@@ -41,6 +42,7 @@ module ForemanMaintain::Scenarios
|
|
41
42
|
add_steps_with_context(Procedures::Restore::RegenerateQueues) if backup.online_backup?
|
42
43
|
add_steps_with_context(Procedures::Service::Start,
|
43
44
|
Procedures::Service::DaemonReload)
|
45
|
+
add_step_with_context(Procedures::Crond::Start) if feature(:cron)
|
44
46
|
end
|
45
47
|
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize
|
46
48
|
|
@@ -98,4 +100,15 @@ module ForemanMaintain::Scenarios
|
|
98
100
|
Procedures::Selinux::SetFileSecurity => :incremental_backup)
|
99
101
|
end
|
100
102
|
end
|
103
|
+
|
104
|
+
class RestoreRescue < ForemanMaintain::Scenario
|
105
|
+
metadata do
|
106
|
+
description 'Resuce Restore backup'
|
107
|
+
manual_detection
|
108
|
+
end
|
109
|
+
|
110
|
+
def compose
|
111
|
+
add_step_with_context(Procedures::Crond::Stop) if feature(:cron)
|
112
|
+
end
|
113
|
+
end
|
101
114
|
end
|
@@ -13,7 +13,8 @@ module ForemanMaintain
|
|
13
13
|
:backup_dir => @backup_dir,
|
14
14
|
:incremental_backup => @incremental || incremental_backup?
|
15
15
|
)
|
16
|
-
|
16
|
+
rescue_scenario = Scenarios::RestoreRescue.new
|
17
|
+
run_scenario(scenario, rescue_scenario)
|
17
18
|
exit runner.exit_code
|
18
19
|
end
|
19
20
|
|
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.6
|
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-06-
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- definitions/checks/foreman/puppet_class_duplicates.rb
|
134
134
|
- definitions/checks/foreman/validate_external_db_version.rb
|
135
135
|
- definitions/checks/foreman_openscap/invalid_report_associations.rb
|
136
|
+
- definitions/checks/foreman_proxy/check_tftp_storage.rb
|
136
137
|
- definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb
|
137
138
|
- definitions/checks/foreman_tasks/invalid/check_old.rb
|
138
139
|
- definitions/checks/foreman_tasks/invalid/check_pending_state.rb
|
@@ -284,8 +285,6 @@ files:
|
|
284
285
|
- definitions/scenarios/packages.rb
|
285
286
|
- definitions/scenarios/restore.rb
|
286
287
|
- definitions/scenarios/services.rb
|
287
|
-
- definitions/scenarios/upgrade_to_capsule_6_7.rb
|
288
|
-
- definitions/scenarios/upgrade_to_capsule_6_7_z.rb
|
289
288
|
- definitions/scenarios/upgrade_to_capsule_6_8.rb
|
290
289
|
- definitions/scenarios/upgrade_to_capsule_6_8_z.rb
|
291
290
|
- definitions/scenarios/upgrade_to_satellite_6_2.rb
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Scenarios::Capsule_6_7
|
2
|
-
class Abstract < ForemanMaintain::Scenario
|
3
|
-
def self.upgrade_metadata(&block)
|
4
|
-
metadata do
|
5
|
-
tags :upgrade_scenario
|
6
|
-
confine do
|
7
|
-
feature(:capsule) &&
|
8
|
-
(feature(:capsule).current_minor_version == '6.6' || \
|
9
|
-
ForemanMaintain.upgrade_in_progress == '6.7')
|
10
|
-
end
|
11
|
-
instance_eval(&block)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def target_version
|
16
|
-
'6.7'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class PreUpgradeCheck < Abstract
|
21
|
-
upgrade_metadata do
|
22
|
-
description 'Checks before upgrading to Capsule 6.7'
|
23
|
-
tags :pre_upgrade_checks
|
24
|
-
run_strategy :fail_slow
|
25
|
-
end
|
26
|
-
|
27
|
-
def compose
|
28
|
-
add_steps(find_checks(:default))
|
29
|
-
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Repositories::Validate.new(:version => '6.7'))
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class PreMigrations < Abstract
|
35
|
-
upgrade_metadata do
|
36
|
-
description 'Procedures before migrating to Capsule 6.7'
|
37
|
-
tags :pre_migrations
|
38
|
-
end
|
39
|
-
|
40
|
-
def compose
|
41
|
-
add_steps(find_procedures(:pre_migrations))
|
42
|
-
add_step(Procedures::Service::Stop.new)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class Migrations < Abstract
|
47
|
-
upgrade_metadata do
|
48
|
-
description 'Migration scripts to Capsule 6.7'
|
49
|
-
tags :migrations
|
50
|
-
end
|
51
|
-
|
52
|
-
def set_context_mapping
|
53
|
-
context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
|
54
|
-
end
|
55
|
-
|
56
|
-
def compose
|
57
|
-
add_step(Procedures::Repositories::Setup.new(:version => '6.7'))
|
58
|
-
add_step(Procedures::Packages::UnlockVersions.new)
|
59
|
-
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
60
|
-
add_step_with_context(Procedures::Installer::Upgrade)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
class PostMigrations < Abstract
|
65
|
-
upgrade_metadata do
|
66
|
-
description 'Procedures after migrating to Capsule 6.7'
|
67
|
-
tags :post_migrations
|
68
|
-
end
|
69
|
-
|
70
|
-
def compose
|
71
|
-
add_step(Procedures::Service::Start.new)
|
72
|
-
add_steps(find_procedures(:post_migrations))
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class PostUpgradeChecks < Abstract
|
77
|
-
upgrade_metadata do
|
78
|
-
description 'Checks after upgrading to Capsule 6.7'
|
79
|
-
tags :post_upgrade_checks
|
80
|
-
run_strategy :fail_slow
|
81
|
-
end
|
82
|
-
|
83
|
-
def compose
|
84
|
-
add_steps(find_checks(:default))
|
85
|
-
add_steps(find_checks(:post_upgrade))
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Scenarios::Capsule_6_7_z
|
2
|
-
class Abstract < ForemanMaintain::Scenario
|
3
|
-
def self.upgrade_metadata(&block)
|
4
|
-
metadata do
|
5
|
-
tags :upgrade_scenario
|
6
|
-
confine do
|
7
|
-
feature(:capsule) &&
|
8
|
-
(feature(:capsule).current_minor_version == '6.7' || \
|
9
|
-
ForemanMaintain.upgrade_in_progress == '6.7.z')
|
10
|
-
end
|
11
|
-
instance_eval(&block)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def target_version
|
16
|
-
'6.7.z'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class PreUpgradeCheck < Abstract
|
21
|
-
upgrade_metadata do
|
22
|
-
description 'Checks before upgrading to Capsule 6.7.z'
|
23
|
-
tags :pre_upgrade_checks
|
24
|
-
run_strategy :fail_slow
|
25
|
-
end
|
26
|
-
|
27
|
-
def compose
|
28
|
-
add_steps(find_checks(:default))
|
29
|
-
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Repositories::Validate.new(:version => '6.7'))
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class PreMigrations < Abstract
|
35
|
-
upgrade_metadata do
|
36
|
-
description 'Procedures before migrating to Capsule 6.7.z'
|
37
|
-
tags :pre_migrations
|
38
|
-
end
|
39
|
-
|
40
|
-
def compose
|
41
|
-
add_steps(find_procedures(:pre_migrations))
|
42
|
-
add_step(Procedures::Service::Stop.new)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class Migrations < Abstract
|
47
|
-
upgrade_metadata do
|
48
|
-
description 'Migration scripts to Capsule 6.7.z'
|
49
|
-
tags :migrations
|
50
|
-
end
|
51
|
-
|
52
|
-
def set_context_mapping
|
53
|
-
context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
|
54
|
-
end
|
55
|
-
|
56
|
-
def compose
|
57
|
-
add_step(Procedures::Repositories::Setup.new(:version => '6.7'))
|
58
|
-
add_step(Procedures::Packages::UnlockVersions.new)
|
59
|
-
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
60
|
-
add_step_with_context(Procedures::Installer::Upgrade)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
class PostMigrations < Abstract
|
65
|
-
upgrade_metadata do
|
66
|
-
description 'Procedures after migrating to Capsule 6.7.z'
|
67
|
-
tags :post_migrations
|
68
|
-
end
|
69
|
-
|
70
|
-
def compose
|
71
|
-
add_step(Procedures::Service::Start.new)
|
72
|
-
add_steps(find_procedures(:post_migrations))
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class PostUpgradeChecks < Abstract
|
77
|
-
upgrade_metadata do
|
78
|
-
description 'Checks after upgrading to Capsule 6.7.z'
|
79
|
-
tags :post_upgrade_checks
|
80
|
-
run_strategy :fail_slow
|
81
|
-
end
|
82
|
-
|
83
|
-
def compose
|
84
|
-
add_steps(find_checks(:default))
|
85
|
-
add_steps(find_checks(:post_upgrade))
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|