foreman_maintain 1.1.1 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/features/foreman_database.rb +7 -1
- data/definitions/features/installer.rb +3 -1
- data/definitions/features/nftables.rb +5 -3
- data/definitions/features/puppet_server.rb +0 -2
- data/definitions/procedures/backup/config_files.rb +25 -10
- data/definitions/procedures/backup/metadata.rb +11 -7
- data/definitions/procedures/backup/offline/foreman_db.rb +30 -9
- data/definitions/procedures/backup/online/safety_confirmation.rb +1 -1
- data/definitions/procedures/content/prepare.rb +1 -0
- data/definitions/procedures/content/switchover.rb +1 -0
- data/definitions/procedures/foreman/apipie_cache.rb +1 -1
- data/definitions/procedures/installer/run_for_6_11.rb +52 -0
- data/definitions/procedures/maintenance_mode/disable_maintenance_mode.rb +2 -1
- data/definitions/procedures/maintenance_mode/enable_maintenance_mode.rb +1 -30
- data/definitions/procedures/packages/update.rb +3 -1
- data/definitions/procedures/restore/extract_files.rb +4 -0
- data/definitions/procedures/selinux/set_file_security.rb +3 -0
- data/definitions/scenarios/backup.rb +10 -0
- data/definitions/scenarios/packages.rb +2 -2
- data/definitions/scenarios/puppet.rb +3 -0
- data/definitions/scenarios/self_upgrade.rb +14 -61
- data/definitions/scenarios/upgrade_to_capsule_6_12.rb +90 -0
- data/definitions/scenarios/upgrade_to_capsule_6_12_z.rb +90 -0
- data/definitions/scenarios/upgrade_to_satellite_6_11.rb +1 -1
- data/definitions/scenarios/upgrade_to_satellite_6_12.rb +92 -0
- data/definitions/scenarios/upgrade_to_satellite_6_12_z.rb +91 -0
- data/lib/foreman_maintain/cli/packages_command.rb +26 -7
- data/lib/foreman_maintain/cli/self_upgrade_command.rb +1 -7
- data/lib/foreman_maintain/concerns/base_database.rb +31 -3
- data/lib/foreman_maintain/concerns/downstream.rb +2 -3
- data/lib/foreman_maintain/concerns/firewall/maintenance_mode.rb +31 -0
- data/lib/foreman_maintain/concerns/firewall/nftables_maintenance_mode.rb +3 -3
- data/lib/foreman_maintain/concerns/metadata.rb +4 -0
- data/lib/foreman_maintain/concerns/os_facts.rb +26 -2
- data/lib/foreman_maintain/concerns/system_helpers.rb +18 -10
- data/lib/foreman_maintain/package_manager/apt.rb +71 -0
- data/lib/foreman_maintain/package_manager/yum.rb +8 -4
- data/lib/foreman_maintain/package_manager.rb +6 -4
- data/lib/foreman_maintain/reporter/cli_reporter.rb +24 -6
- data/lib/foreman_maintain/repository_manager/el.rb +15 -4
- data/lib/foreman_maintain/repository_manager.rb +1 -1
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +1 -0
- metadata +9 -7
- data/bin/passenger-recycler +0 -89
- data/config/passenger-recycler.yaml +0 -38
- data/definitions/procedures/passenger_recycler.rb +0 -14
- data/extras/passenger-recycler.cron +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a8f35db6a3abfa83bcb5570efadb4e1bf8af20c4375dbf53b58eba26e9c0e08
|
4
|
+
data.tar.gz: a7a449095345a738b168a8e5657804426855e66d53d46686a3b0fe391d661932
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d7556a2fd54939fe0aa1b80f6156f2df7427dfb962f746d0e0d58ab77038b1ed1b4e25105f46884c8b3f1a7d7aea53508f968c1c799d91a96bc3aa008298ff2
|
7
|
+
data.tar.gz: f67c0fac6450e02f4485ad2c8428867e3ba49430fcadf808fd32d79564bcaec18ad10e923277a454e809f8acd2a9403169864b7328f1af42962a5a3776eadf8f
|
@@ -16,7 +16,13 @@ class Features::ForemanDatabase < ForemanMaintain::Feature
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def config_files
|
19
|
-
[postgresql_conf]
|
19
|
+
el? ? [postgresql_conf] : []
|
20
|
+
end
|
21
|
+
|
22
|
+
def config_dirs
|
23
|
+
# On Debian config files reside in /etc/postgresql/#{version}/main/
|
24
|
+
# There could be more than on config dir because of multiple versions
|
25
|
+
deb_postgresql_config_dirs
|
20
26
|
end
|
21
27
|
|
22
28
|
def services
|
@@ -64,7 +64,9 @@ class Features::Installer < ForemanMaintain::Feature
|
|
64
64
|
def config_files
|
65
65
|
Dir.glob(File.join(config_directory, '**/*')) +
|
66
66
|
[
|
67
|
-
'/usr/local/bin/validate_postgresql_connection.sh'
|
67
|
+
'/usr/local/bin/validate_postgresql_connection.sh',
|
68
|
+
'/opt/puppetlabs/puppet/cache/foreman_cache_data',
|
69
|
+
'/opt/puppetlabs/puppet/cache/pulpcore_cache_data'
|
68
70
|
]
|
69
71
|
end
|
70
72
|
|
@@ -25,12 +25,14 @@ class Features::Nftables < ForemanMaintain::Feature
|
|
25
25
|
execute!("nft add chain #{family} #{table} #{chain} #{chain_options}")
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def add_rules(options = {})
|
29
29
|
family = options.fetch(:family, ip_family)
|
30
30
|
table = options.fetch(:table, table_name)
|
31
31
|
chain = options.fetch(:chain, chain_name)
|
32
|
-
|
33
|
-
|
32
|
+
rules = options.fetch(:rules) # needs validation
|
33
|
+
rules.each do |rule|
|
34
|
+
execute!("nft add rule #{family} #{table} #{chain} #{rule}")
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
def table_exist?(name = table_name)
|
@@ -11,8 +11,6 @@ class Features::PuppetServer < ForemanMaintain::Feature
|
|
11
11
|
[
|
12
12
|
'/etc/puppet',
|
13
13
|
'/etc/puppetlabs',
|
14
|
-
'/opt/puppetlabs/puppet/cache/foreman_cache_data',
|
15
|
-
'/var/lib/puppet/foreman_cache_data',
|
16
14
|
'/opt/puppetlabs/puppet/ssl/',
|
17
15
|
'/var/lib/puppet/ssl',
|
18
16
|
'/var/lib/puppet',
|
@@ -45,10 +45,22 @@ module Procedures::Backup
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
# rubocop:enable Metrics/MethodLength
|
49
48
|
|
50
|
-
# rubocop:disable Metrics/AbcSize
|
51
49
|
def config_files
|
50
|
+
configs, exclude_configs = available_features_config
|
51
|
+
|
52
|
+
if feature(:foreman_proxy)
|
53
|
+
configs += foreman_proxy_configs
|
54
|
+
exclude_configs += foreman_proxy_exclude_configs
|
55
|
+
end
|
56
|
+
|
57
|
+
configs += config_dirs
|
58
|
+
configs.compact.select { |path| Dir.glob(path).any? }
|
59
|
+
exclude_configs.compact.select { |path| Dir.glob(path).any? }
|
60
|
+
[configs, exclude_configs]
|
61
|
+
end
|
62
|
+
|
63
|
+
def available_features_config
|
52
64
|
configs = []
|
53
65
|
exclude_configs = []
|
54
66
|
ForemanMaintain.available_features.each do |feature|
|
@@ -59,17 +71,20 @@ module Procedures::Backup
|
|
59
71
|
exclude_configs += feature.config_files_to_exclude
|
60
72
|
exclude_configs += feature.config_files_exclude_for_online if @online_backup
|
61
73
|
end
|
74
|
+
[configs, exclude_configs]
|
75
|
+
end
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
77
|
+
def foreman_proxy_configs
|
78
|
+
feature(:foreman_proxy).config_files(@proxy_features)
|
79
|
+
end
|
67
80
|
|
68
|
-
|
69
|
-
|
70
|
-
|
81
|
+
def foreman_proxy_exclude_configs
|
82
|
+
feature(:foreman_proxy).config_files_to_exclude(@proxy_features)
|
83
|
+
end
|
84
|
+
|
85
|
+
def config_dirs
|
86
|
+
debian_or_ubuntu? ? feature(:foreman_database).config_dirs : []
|
71
87
|
end
|
72
|
-
# rubocop:enable Metrics/AbcSize
|
73
88
|
|
74
89
|
private
|
75
90
|
|
@@ -17,7 +17,7 @@ module Procedures::Backup
|
|
17
17
|
metadata['os_version'] = release_info(spinner)
|
18
18
|
metadata['plugin_list'] = plugin_list(spinner) || []
|
19
19
|
metadata['proxy_features'] = proxy_feature_list(spinner) || []
|
20
|
-
metadata
|
20
|
+
installed_pkgs(metadata)
|
21
21
|
metadata['incremental'] = @incremental_dir || false
|
22
22
|
metadata['online'] = @online_backup
|
23
23
|
metadata['hostname'] = hostname
|
@@ -28,6 +28,15 @@ module Procedures::Backup
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def installed_pkgs(metadata)
|
32
|
+
installed_pkgs = package_manager.list_installed_packages
|
33
|
+
if el?
|
34
|
+
metadata[:rpms] = installed_pkgs
|
35
|
+
else
|
36
|
+
metadata[:debs] = installed_pkgs
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
def save_metadata(metadata, spinner)
|
32
41
|
spinner.update('Saving metadata to metadata.yml')
|
33
42
|
File.open(File.join(@backup_dir, 'metadata.yml'), 'w') do |metadata_file|
|
@@ -37,12 +46,7 @@ module Procedures::Backup
|
|
37
46
|
|
38
47
|
def release_info(spinner)
|
39
48
|
spinner.update('Collecting system release info')
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def rpms(spinner)
|
44
|
-
spinner.update('Collecting installed RPMs')
|
45
|
-
execute!('rpm -qa').split("\n")
|
49
|
+
"#{os_name} #{os_version}"
|
46
50
|
end
|
47
51
|
|
48
52
|
def plugin_list(spinner)
|
@@ -20,7 +20,7 @@ module Procedures::Backup
|
|
20
20
|
local_backup
|
21
21
|
end
|
22
22
|
else
|
23
|
-
puts "Backup of #{
|
23
|
+
puts "Backup of #{pg_data_dirs.join(',')} is not supported for remote databases." \
|
24
24
|
' Doing postgres dump instead...'
|
25
25
|
with_spinner('Getting Foreman DB dump') do
|
26
26
|
feature(:foreman_database).dump_db(File.join(@backup_dir, 'foreman.dump'))
|
@@ -31,22 +31,43 @@ module Procedures::Backup
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def local_backup
|
34
|
-
with_spinner("Collecting data from #{
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
:volume_size => @tar_volume_size,
|
39
|
-
:data_dir => pg_data_dir
|
40
|
-
)
|
34
|
+
with_spinner("Collecting data from #{pg_data_dirs.join(',')}") do
|
35
|
+
pg_data_dirs.each_with_index do |pg_dir, index|
|
36
|
+
do_backup(pg_dir, index == 0 ? 'create' : 'append')
|
37
|
+
end
|
41
38
|
end
|
42
39
|
end
|
43
40
|
|
41
|
+
def do_backup(pg_dir, cmd)
|
42
|
+
feature(:foreman_database).backup_local(
|
43
|
+
pg_backup_file,
|
44
|
+
:listed_incremental => File.join(@backup_dir, '.postgres.snar'),
|
45
|
+
:volume_size => @tar_volume_size,
|
46
|
+
:data_dir => pg_dir,
|
47
|
+
:command => cmd
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
44
51
|
def pg_backup_file
|
45
52
|
File.join(@backup_dir, 'pgsql_data.tar')
|
46
53
|
end
|
47
54
|
|
48
|
-
def
|
55
|
+
def pg_data_dirs
|
56
|
+
el? ? [pg_data_dir_el] : pg_data_dirs_deb
|
57
|
+
end
|
58
|
+
|
59
|
+
def pg_data_dirs_deb
|
60
|
+
# The Debian based OSes support multiple installations of Postgresql
|
61
|
+
# There could be situations where Foreman db is either of these versions
|
62
|
+
# To be sure we backup the system correctly without missing anything
|
63
|
+
# we backup all of the Postgresql dirs
|
64
|
+
# Yet to implement the snapshot backup!
|
65
|
+
feature(:foreman_database).data_dir
|
66
|
+
end
|
67
|
+
|
68
|
+
def pg_data_dir_el
|
49
69
|
return feature(:foreman_database).data_dir if @mount_dir.nil?
|
70
|
+
|
50
71
|
mount_point = File.join(@mount_dir, 'pgsql')
|
51
72
|
dir = feature(:foreman_database).find_base_directory(mount_point)
|
52
73
|
fail!("Snapshot of Foreman DB was not found mounted in #{mount_point}") if dir.nil?
|
@@ -19,7 +19,7 @@ module Procedures::Backup
|
|
19
19
|
'*** for debugging purposes only.' \
|
20
20
|
" The backup routine can not ensure 100% consistency while the\n" \
|
21
21
|
"*** backup is taking place as there is a chance there may be data mismatch between\n" \
|
22
|
-
'***
|
22
|
+
'*** the databases while the services are live.' \
|
23
23
|
" If you wish to utilize the #{substr}\n" \
|
24
24
|
'*** for production use you need to ensure that there are' \
|
25
25
|
" no modifications occurring during\n" \
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Procedures::Installer
|
2
|
+
class RunFor6_11 < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Run installer with Candlepin SSL CA'\
|
5
|
+
' when using external database with SSL'
|
6
|
+
param :assumeyes, 'Do not ask for confirmation'
|
7
|
+
manual_detection
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
if extdb_and_ssl?
|
12
|
+
run_installer_with_extra_option
|
13
|
+
else
|
14
|
+
run_installer
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def ext_db?
|
19
|
+
!feature(:foreman_database).local?
|
20
|
+
end
|
21
|
+
|
22
|
+
def installer_answers
|
23
|
+
@installer_answers ||= feature(:installer).answers
|
24
|
+
end
|
25
|
+
|
26
|
+
def server_db_with_ssl?
|
27
|
+
installer_answers.fetch('katello')['candlepin_db_ssl']
|
28
|
+
end
|
29
|
+
|
30
|
+
def extdb_and_ssl?
|
31
|
+
ext_db? && server_db_with_ssl?
|
32
|
+
end
|
33
|
+
|
34
|
+
def run_installer_with_extra_option
|
35
|
+
ssl_ca_path = installer_answers.fetch('foreman')['db_root_cert']
|
36
|
+
spinner_msg = "Running installer with --katello-candlepin-db-ssl-ca #{ssl_ca_path} argument!"
|
37
|
+
with_spinner(spinner_msg) do
|
38
|
+
installer_args = feature(:installer).installer_arguments
|
39
|
+
new_ssl_arg = " --katello-candlepin-db-ssl-ca #{ssl_ca_path}"
|
40
|
+
installer_args << new_ssl_arg
|
41
|
+
feature(:installer).run(installer_args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def run_installer
|
46
|
+
with_spinner('Executing installer') do
|
47
|
+
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
48
|
+
feature(:installer).upgrade(:interactive => !assumeyes_val)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Procedures::MaintenanceMode
|
2
2
|
class DisableMaintenanceMode < ForemanMaintain::Procedure
|
3
|
+
include ForemanMaintain::Concerns::Firewall::MaintenanceMode
|
3
4
|
metadata do
|
4
5
|
label :disable_maintenance_mode
|
5
6
|
description 'Remove maintenance mode table/chain from nftables/iptables'
|
@@ -11,7 +12,7 @@ module Procedures::MaintenanceMode
|
|
11
12
|
if feature(:instance).firewall
|
12
13
|
feature(:instance).firewall.disable_maintenance_mode
|
13
14
|
else
|
14
|
-
|
15
|
+
notify_and_ask_to_install_firewall_utility
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Procedures::MaintenanceMode
|
2
2
|
class EnableMaintenanceMode < ForemanMaintain::Procedure
|
3
|
+
include ForemanMaintain::Concerns::Firewall::MaintenanceMode
|
3
4
|
metadata do
|
4
5
|
label :enable_maintenance_mode
|
5
6
|
description 'Add maintenance_mode tables/chain to nftables/iptables'
|
@@ -14,35 +15,5 @@ module Procedures::MaintenanceMode
|
|
14
15
|
notify_and_ask_to_install_firewall_utility
|
15
16
|
end
|
16
17
|
end
|
17
|
-
|
18
|
-
def notify_and_ask_to_install_firewall_utility
|
19
|
-
puts 'Unable to find nftables or iptables!'
|
20
|
-
question, pkg = question_and_pkg_name
|
21
|
-
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
|
22
|
-
if answer == :yes
|
23
|
-
packages_action(:install, pkg)
|
24
|
-
feature(:instance).firewall.enable_maintenance_mode
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def can_install_nft?
|
29
|
-
nft_kernel_version = Gem::Version.new('3.13')
|
30
|
-
installed_kernel_version = Gem::Version.new(execute!('uname -r').split('-').first)
|
31
|
-
installed_kernel_version >= nft_kernel_version
|
32
|
-
end
|
33
|
-
|
34
|
-
def question_and_pkg_name
|
35
|
-
question = 'Do you want to install missing netfilter utility '
|
36
|
-
pkg_to_install = []
|
37
|
-
if can_install_nft?
|
38
|
-
question << 'nftables?'
|
39
|
-
pkg_to_install << 'nftables'
|
40
|
-
else
|
41
|
-
question << 'iptables?'
|
42
|
-
pkg_to_install << 'iptables'
|
43
|
-
end
|
44
|
-
question << "\nand start maintenance mode?"
|
45
|
-
[question, pkg_to_install]
|
46
|
-
end
|
47
18
|
end
|
48
19
|
end
|
@@ -6,12 +6,14 @@ module Procedures::Packages
|
|
6
6
|
param :force, 'Do not skip if package is installed', :flag => true, :default => false
|
7
7
|
param :warn_on_errors, 'Do not interrupt scenario on failure',
|
8
8
|
:flag => true, :default => false
|
9
|
+
param :yum_options, 'Extra yum options if any', :array => true, :default => []
|
9
10
|
end
|
10
11
|
|
11
12
|
def run
|
12
13
|
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
13
14
|
package_manager.clean_cache(:assumeyes => assumeyes_val)
|
14
|
-
|
15
|
+
opts = { :assumeyes => assumeyes_val, :yum_options => @yum_options }
|
16
|
+
packages_action(:update, @packages, opts)
|
15
17
|
rescue ForemanMaintain::Error::ExecutionError => e
|
16
18
|
if @warn_on_errors
|
17
19
|
set_status(:warning, e.message)
|
@@ -71,6 +71,10 @@ module Procedures::Restore
|
|
71
71
|
:transform => any_database.restore_transform
|
72
72
|
)
|
73
73
|
feature(:tar).run(pgsql_data_tar)
|
74
|
+
del_data_dir_param if el?
|
75
|
+
end
|
76
|
+
|
77
|
+
def del_data_dir_param
|
74
78
|
# workaround for https://tickets.puppetlabs.com/browse/MODULES-11160
|
75
79
|
execute("sed -i '/data_directory/d' #{any_database.postgresql_conf}")
|
76
80
|
end
|
@@ -19,6 +19,7 @@ module ForemanMaintain::Scenarios
|
|
19
19
|
param :tar_volume_size, 'Size of tar volume (indicates splitting)'
|
20
20
|
end
|
21
21
|
|
22
|
+
# rubocop:disable Metrics/MethodLength
|
22
23
|
def compose
|
23
24
|
check_valid_startegy
|
24
25
|
safety_confirmation
|
@@ -33,10 +34,19 @@ module ForemanMaintain::Scenarios
|
|
33
34
|
when :offline
|
34
35
|
add_offline_backup_steps
|
35
36
|
when :snapshot
|
37
|
+
deb_snapshot_msg
|
36
38
|
add_snapshot_backup_steps
|
37
39
|
end
|
38
40
|
add_step_with_context(Procedures::Backup::CompressData)
|
39
41
|
end
|
42
|
+
# rubocop:enable Metrics/MethodLength
|
43
|
+
|
44
|
+
def deb_snapshot_msg
|
45
|
+
if debian_or_ubuntu?
|
46
|
+
puts 'The snapshot backup is not yet available for Debian based OSes!'
|
47
|
+
exit 0
|
48
|
+
end
|
49
|
+
end
|
40
50
|
|
41
51
|
# rubocop:disable Metrics/MethodLength
|
42
52
|
def set_context_mapping
|
@@ -107,9 +107,9 @@ module ForemanMaintain::Scenarios
|
|
107
107
|
else
|
108
108
|
add_steps_with_context(
|
109
109
|
Procedures::Packages::UpdateAllConfirmation,
|
110
|
-
Procedures::Packages::InstallerConfirmation
|
111
|
-
Procedures::Packages::UnlockVersions
|
110
|
+
Procedures::Packages::InstallerConfirmation
|
112
111
|
)
|
112
|
+
add_step_with_context(Procedures::Packages::UnlockVersions)
|
113
113
|
add_step_with_context(Procedures::Packages::Update,
|
114
114
|
:force => true, :warn_on_errors => true)
|
115
115
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -15,6 +15,9 @@ module ForemanMaintain::Scenarios
|
|
15
15
|
add_step(Procedures::Puppet::RemovePuppet)
|
16
16
|
add_step(Procedures::Puppet::RemovePuppetData) if context.get(:remove_data)
|
17
17
|
add_step(Procedures::Service::Restart)
|
18
|
+
if server?
|
19
|
+
add_step(Procedures::Foreman::ApipieCache)
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -1,17 +1,6 @@
|
|
1
1
|
module ForemanMaintain::Scenarios
|
2
2
|
class SelfUpgradeBase < ForemanMaintain::Scenario
|
3
|
-
|
4
|
-
repository_manager.enabled_repos.keys
|
5
|
-
end
|
6
|
-
|
7
|
-
def enable_repos(repo_ids = stored_enabled_repos_ids)
|
8
|
-
add_step(Procedures::Repositories::Enable.new(repos: repo_ids))
|
9
|
-
end
|
10
|
-
|
11
|
-
def disable_repos(repo_ids = stored_enabled_repos_ids)
|
12
|
-
add_step(Procedures::Repositories::Disable.new(repos: repo_ids))
|
13
|
-
end
|
14
|
-
|
3
|
+
include ForemanMaintain::Concerns::Downstream
|
15
4
|
def target_version
|
16
5
|
current_full_version = feature(:instance).downstream.current_version
|
17
6
|
@target_version ||= current_full_version.bump
|
@@ -43,33 +32,6 @@ module ForemanMaintain::Scenarios
|
|
43
32
|
end
|
44
33
|
end
|
45
34
|
|
46
|
-
def maintenance_repo_version
|
47
|
-
return '6' if current_version == '6.10'
|
48
|
-
|
49
|
-
current_version
|
50
|
-
end
|
51
|
-
|
52
|
-
def stored_enabled_repos_ids
|
53
|
-
@stored_enabled_repos_ids ||= begin
|
54
|
-
path = File.expand_path('enabled_repos.yml', ForemanMaintain.config.backup_dir)
|
55
|
-
@stored_enabled_repos_ids = File.file?(path) ? YAML.load(File.read(path)) : []
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def all_maintenance_repos
|
60
|
-
repo_regex = if el7?
|
61
|
-
/rhel-\d-server-satellite-maintenance-\d.\d-rpms/
|
62
|
-
else
|
63
|
-
/satellite-maintenance-\d.\d-for-rhel-\d-x86_64-rpms/
|
64
|
-
end
|
65
|
-
stored_enabled_repos_ids.select { |id| !id.match(repo_regex).nil? }
|
66
|
-
end
|
67
|
-
|
68
|
-
def repos_ids_to_reenable
|
69
|
-
repos_ids_to_reenable = stored_enabled_repos_ids - all_maintenance_repos
|
70
|
-
repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
|
71
|
-
end
|
72
|
-
|
73
35
|
def use_rhsm?
|
74
36
|
return false if maintenance_repo_label
|
75
37
|
|
@@ -79,6 +41,14 @@ module ForemanMaintain::Scenarios
|
|
79
41
|
|
80
42
|
true
|
81
43
|
end
|
44
|
+
|
45
|
+
def req_repos_to_update_pkgs
|
46
|
+
if use_rhsm?
|
47
|
+
main_rh_repos + [maintenance_repo_id(target_version)]
|
48
|
+
else
|
49
|
+
[maintenance_repo_id(target_version)]
|
50
|
+
end
|
51
|
+
end
|
82
52
|
end
|
83
53
|
|
84
54
|
class SelfUpgrade < SelfUpgradeBase
|
@@ -92,28 +62,11 @@ module ForemanMaintain::Scenarios
|
|
92
62
|
def compose
|
93
63
|
if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
|
94
64
|
pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
enable_repos(repos_ids_to_reenable)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
class SelfUpgradeRescue < SelfUpgradeBase
|
106
|
-
metadata do
|
107
|
-
label :rescue_self_upgrade
|
108
|
-
description 'Disables all version specific maintenance repositories and,'\
|
109
|
-
"\nenables the repositories which were configured prior to self upgrade"
|
110
|
-
manual_detection
|
111
|
-
run_strategy :fail_slow
|
112
|
-
end
|
113
|
-
|
114
|
-
def compose
|
115
|
-
if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
|
116
|
-
enable_repos(repos_ids_to_reenable)
|
65
|
+
yum_options = req_repos_to_update_pkgs.map do |id|
|
66
|
+
"--enablerepo=#{id}"
|
67
|
+
end
|
68
|
+
add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
|
69
|
+
yum_options: yum_options))
|
117
70
|
end
|
118
71
|
end
|
119
72
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Scenarios::Capsule_6_12
|
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.11' || \
|
9
|
+
ForemanMaintain.upgrade_in_progress == '6.12')
|
10
|
+
end
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def target_version
|
16
|
+
'6.12'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class PreUpgradeCheck < Abstract
|
21
|
+
upgrade_metadata do
|
22
|
+
description 'Checks before upgrading to Capsule 6.12'
|
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::Foreman::CheckpointSegments)
|
31
|
+
add_step(Checks::Repositories::Validate.new(:version => '6.12'))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class PreMigrations < Abstract
|
36
|
+
upgrade_metadata do
|
37
|
+
description 'Procedures before migrating to Capsule 6.12'
|
38
|
+
tags :pre_migrations
|
39
|
+
end
|
40
|
+
|
41
|
+
def compose
|
42
|
+
add_steps(find_procedures(:pre_migrations))
|
43
|
+
add_step(Procedures::Service::Stop.new)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Migrations < Abstract
|
48
|
+
upgrade_metadata do
|
49
|
+
description 'Migration scripts to Capsule 6.12'
|
50
|
+
tags :migrations
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_context_mapping
|
54
|
+
context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
|
55
|
+
end
|
56
|
+
|
57
|
+
def compose
|
58
|
+
add_step(Procedures::Repositories::Setup.new(:version => '6.12'))
|
59
|
+
add_step(Procedures::Packages::UnlockVersions.new)
|
60
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
61
|
+
add_step_with_context(Procedures::Installer::Upgrade)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class PostMigrations < Abstract
|
66
|
+
upgrade_metadata do
|
67
|
+
description 'Procedures after migrating to Capsule 6.12'
|
68
|
+
tags :post_migrations
|
69
|
+
end
|
70
|
+
|
71
|
+
def compose
|
72
|
+
add_step(Procedures::RefreshFeatures)
|
73
|
+
add_step(Procedures::Service::Start.new)
|
74
|
+
add_steps(find_procedures(:post_migrations))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class PostUpgradeChecks < Abstract
|
79
|
+
upgrade_metadata do
|
80
|
+
description 'Checks after upgrading to Capsule 6.12'
|
81
|
+
tags :post_upgrade_checks
|
82
|
+
run_strategy :fail_slow
|
83
|
+
end
|
84
|
+
|
85
|
+
def compose
|
86
|
+
add_steps(find_checks(:default))
|
87
|
+
add_steps(find_checks(:post_upgrade))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|