foreman_maintain 1.1.1 → 1.1.2
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/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/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_satellite_6_11.rb +1 -1
- 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 +15 -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 +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a54e65aa9144d233ab256305556eebb5467cfd5c4fd9aa99b7971a13fdd81bac
|
4
|
+
data.tar.gz: ce6c5012139cc01bb4dee7f7cdb30a569ce3f05399d14d81d1c1cbf835588b31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b94662b70f86ed91889688a3288dbe67d44ec46c9b1d3830f5a9687b0293500048ffd2df86162964e417a0ffa1514d78a43a0c4a1f7168848986bb92abe9828e
|
7
|
+
data.tar.gz: 0f2351eddc6236e7be70c44bc94e0ac4ae24b19b8f21dcf9d0a726a8897c4bea34bcb5bd5562827d1efb3400c421e2807288d56d1f5a03d5685ab2c402aa21b7
|
@@ -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?
|
@@ -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
|
@@ -61,7 +61,7 @@ module Scenarios::Satellite_6_11
|
|
61
61
|
add_step(Procedures::Repositories::Setup.new(:version => '6.11'))
|
62
62
|
add_step(Procedures::Packages::UnlockVersions.new)
|
63
63
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
64
|
-
add_step_with_context(Procedures::Installer::
|
64
|
+
add_step_with_context(Procedures::Installer::RunFor6_11)
|
65
65
|
add_step(Procedures::Installer::UpgradeRakeTask)
|
66
66
|
end
|
67
67
|
end
|
@@ -2,23 +2,32 @@ module ForemanMaintain
|
|
2
2
|
module Cli
|
3
3
|
class PackagesCommand < Base
|
4
4
|
subcommand 'lock', 'Prevent packages from automatic update' do
|
5
|
+
# This command is not implemented for Debian based operating systems
|
5
6
|
interactive_option(['assumeyes'])
|
6
7
|
def execute
|
7
|
-
|
8
|
+
run_scenario_or_rescue do
|
9
|
+
run_scenarios_and_exit(Scenarios::Packages::Lock.new)
|
10
|
+
end
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
11
14
|
subcommand 'unlock', 'Enable packages for automatic update' do
|
15
|
+
# This command is not implemented for Debian based operating systems
|
12
16
|
interactive_option(['assumeyes'])
|
13
17
|
def execute
|
14
|
-
|
18
|
+
run_scenario_or_rescue do
|
19
|
+
run_scenarios_and_exit(Scenarios::Packages::Unlock.new)
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
18
24
|
subcommand 'status', 'Check if packages are protected against update' do
|
25
|
+
# This command is not implemented for Debian based operating systems
|
19
26
|
interactive_option(['assumeyes'])
|
20
27
|
def execute
|
21
|
-
|
28
|
+
run_scenario_or_rescue do
|
29
|
+
run_scenarios_and_exit(Scenarios::Packages::Status.new)
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
@@ -58,14 +67,24 @@ module ForemanMaintain
|
|
58
67
|
end
|
59
68
|
|
60
69
|
subcommand 'is-locked', 'Check if update of packages is allowed' do
|
70
|
+
# This command is not implemented for Debian based operating systems
|
61
71
|
interactive_option(['assumeyes'])
|
62
72
|
def execute
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
73
|
+
run_scenario_or_rescue do
|
74
|
+
locked = ForemanMaintain.package_manager.versions_locked?
|
75
|
+
puts "Packages are#{locked ? '' : ' not'} locked"
|
76
|
+
exit_code = locked ? 0 : 1
|
77
|
+
exit exit_code
|
78
|
+
end
|
67
79
|
end
|
68
80
|
end
|
81
|
+
|
82
|
+
def run_scenario_or_rescue
|
83
|
+
yield
|
84
|
+
rescue NotImplementedError
|
85
|
+
puts 'Command is not implemented for Debian based operating systems!'
|
86
|
+
exit 0
|
87
|
+
end
|
69
88
|
end
|
70
89
|
end
|
71
90
|
end
|
@@ -5,7 +5,7 @@ module ForemanMaintain
|
|
5
5
|
'Repository label from which packages should be updated.'\
|
6
6
|
'This can be used when standard CDN repositories are unavailable.'
|
7
7
|
def execute
|
8
|
-
run_scenario(upgrade_scenario
|
8
|
+
run_scenario(upgrade_scenario)
|
9
9
|
end
|
10
10
|
|
11
11
|
def upgrade_scenario
|
@@ -13,12 +13,6 @@ module ForemanMaintain
|
|
13
13
|
maintenance_repo_label: maintenance_repo_label
|
14
14
|
)
|
15
15
|
end
|
16
|
-
|
17
|
-
def upgrade_rescue_scenario
|
18
|
-
Scenarios::SelfUpgradeRescue.new(
|
19
|
-
maintenance_repo_label: maintenance_repo_label
|
20
|
-
)
|
21
|
-
end
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
@@ -4,13 +4,39 @@ module ForemanMaintain
|
|
4
4
|
def data_dir
|
5
5
|
if el7? && package_manager.installed?('rh-postgresql12-postgresql-server-syspaths')
|
6
6
|
'/var/opt/rh/rh-postgresql12/lib/pgsql/data/'
|
7
|
+
elsif debian_or_ubuntu?
|
8
|
+
deb_postgresql_data_dir
|
7
9
|
else
|
8
10
|
'/var/lib/pgsql/data/'
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
14
|
+
def deb_postgresql_data_dir
|
15
|
+
deb_postgresql_versions.map do |ver|
|
16
|
+
"/var/lib/postgresql/#{ver}/main/"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def deb_postgresql_versions
|
21
|
+
installed_pkgs = package_manager.list_installed_packages('${binary:Package}\n')
|
22
|
+
@deb_postgresql_versions ||= installed_pkgs.grep(/^postgresql-\d+$/).map do |name|
|
23
|
+
name.split('-').last
|
24
|
+
end
|
25
|
+
@deb_postgresql_versions
|
26
|
+
end
|
27
|
+
|
12
28
|
def postgresql_conf
|
13
|
-
"#{data_dir}/postgresql.conf"
|
29
|
+
return "#{data_dir}/postgresql.conf" if el?
|
30
|
+
|
31
|
+
deb_postgresql_config_dirs.map do |conf_dir|
|
32
|
+
"#{conf_dir}postgresql.conf"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def deb_postgresql_config_dirs
|
37
|
+
deb_postgresql_versions.map do |ver|
|
38
|
+
"/etc/postgresql/#{ver}/main/"
|
39
|
+
end
|
14
40
|
end
|
15
41
|
|
16
42
|
def restore_transform
|
@@ -89,11 +115,13 @@ module ForemanMaintain
|
|
89
115
|
|
90
116
|
def backup_local(backup_file, extra_tar_options = {})
|
91
117
|
dir = extra_tar_options.fetch(:data_dir, data_dir)
|
118
|
+
command = extra_tar_options.fetch(:command, 'create')
|
119
|
+
|
92
120
|
FileUtils.cd(dir) do
|
93
121
|
tar_options = {
|
94
122
|
:archive => backup_file,
|
95
|
-
:command =>
|
96
|
-
:transform => "s,^,#{
|
123
|
+
:command => command,
|
124
|
+
:transform => "s,^,#{dir[1..-1]},S",
|
97
125
|
:files => '*'
|
98
126
|
}.merge(extra_tar_options)
|
99
127
|
feature(:tar).run(tar_options)
|
@@ -66,7 +66,8 @@ module ForemanMaintain
|
|
66
66
|
server_version_full = "#{server_version.major}.#{server_version.minor}"
|
67
67
|
rh_repos.concat(product_specific_repos(server_version_full))
|
68
68
|
if server_version > version('6.3')
|
69
|
-
|
69
|
+
ansible_repo = ansible_repo(server_version)
|
70
|
+
rh_repos << ansible_repo if ansible_repo
|
70
71
|
end
|
71
72
|
|
72
73
|
rh_repos
|
@@ -83,8 +84,6 @@ module ForemanMaintain
|
|
83
84
|
|
84
85
|
if el7?
|
85
86
|
"rhel-#{el_major_version}-server-ansible-#{ansible_version}-rpms"
|
86
|
-
else
|
87
|
-
"ansible-#{ansible_version}-for-rhel-#{el_major_version}-x86_64-rpms"
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Concerns
|
3
|
+
module Firewall
|
4
|
+
module MaintenanceMode
|
5
|
+
def notify_and_ask_to_install_firewall_utility
|
6
|
+
puts 'Unable to find nftables or iptables!'
|
7
|
+
question, pkg = question_and_pkg_name
|
8
|
+
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
|
9
|
+
if answer == :yes
|
10
|
+
packages_action(:install, pkg)
|
11
|
+
feature(:instance).firewall.enable_maintenance_mode
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def can_install_nft?
|
16
|
+
# The nftables is default from EL8 and Debian 10(Buster)
|
17
|
+
(el? && el_major_version >= 8) ||
|
18
|
+
(debian? && deb_major_version >= 10) ||
|
19
|
+
(ubuntu? && ubuntu_major_version.to_i >= 22)
|
20
|
+
end
|
21
|
+
|
22
|
+
def question_and_pkg_name
|
23
|
+
pkg_to_install = can_install_nft? ? 'nftables' : 'iptables'
|
24
|
+
question = "Do you want to install missing netfilter utility #{pkg_to_install}?"\
|
25
|
+
"\nand start maintenance mode?"
|
26
|
+
[question, [pkg_to_install]]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -10,7 +10,7 @@ module ForemanMaintain
|
|
10
10
|
unless table_exist?
|
11
11
|
add_table
|
12
12
|
add_chain(:chain_options => nftables_chain_options)
|
13
|
-
|
13
|
+
add_rules(rules: nftables_rules)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -22,8 +22,8 @@ module ForemanMaintain
|
|
22
22
|
'{type filter hook input priority 0\\;}'
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
'tcp dport
|
25
|
+
def nftables_rules
|
26
|
+
['iifname "lo" accept', 'tcp dport 443 reject']
|
27
27
|
end
|
28
28
|
|
29
29
|
def status_for_maintenance_mode
|
@@ -100,6 +100,10 @@ module ForemanMaintain
|
|
100
100
|
@data[:advanced_run] = advanced_run
|
101
101
|
end
|
102
102
|
|
103
|
+
def do_not_whitelist
|
104
|
+
@data[:do_not_whitelist] = true
|
105
|
+
end
|
106
|
+
|
103
107
|
def self.eval_dsl(metadata, &block)
|
104
108
|
new(metadata).tap do |dsl|
|
105
109
|
dsl.instance_eval(&block)
|
@@ -46,12 +46,20 @@ module ForemanMaintain
|
|
46
46
|
facts.fetch('ID_LIKE', '').split
|
47
47
|
end
|
48
48
|
|
49
|
+
def os_name
|
50
|
+
facts.fetch('NAME')
|
51
|
+
end
|
52
|
+
|
49
53
|
def el?
|
50
54
|
File.exist?('/etc/redhat-release')
|
51
55
|
end
|
52
56
|
|
53
57
|
def debian?
|
54
|
-
|
58
|
+
os_id == 'debian'
|
59
|
+
end
|
60
|
+
|
61
|
+
def ubuntu?
|
62
|
+
os_id == 'ubuntu'
|
55
63
|
end
|
56
64
|
|
57
65
|
def el7?
|
@@ -63,7 +71,23 @@ module ForemanMaintain
|
|
63
71
|
end
|
64
72
|
|
65
73
|
def el_major_version
|
66
|
-
|
74
|
+
os_version_id.to_i if el?
|
75
|
+
end
|
76
|
+
|
77
|
+
def deb_major_version
|
78
|
+
os_version_id.to_i if debian?
|
79
|
+
end
|
80
|
+
|
81
|
+
def ubuntu_major_version
|
82
|
+
os_version_id if ubuntu?
|
83
|
+
end
|
84
|
+
|
85
|
+
def debian_or_ubuntu?
|
86
|
+
debian? || ubuntu?
|
87
|
+
end
|
88
|
+
|
89
|
+
def os_version
|
90
|
+
facts.fetch('VERSION')
|
67
91
|
end
|
68
92
|
end
|
69
93
|
end
|
@@ -100,12 +100,13 @@ module ForemanMaintain
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def packages_action(action, packages, options = {})
|
103
|
-
options.validate_options!(:assumeyes)
|
103
|
+
options.validate_options!(:assumeyes, :yum_options)
|
104
104
|
case action
|
105
105
|
when :install
|
106
106
|
package_manager.install(packages, :assumeyes => options[:assumeyes])
|
107
107
|
when :update
|
108
|
-
package_manager.update(packages, :assumeyes => options[:assumeyes]
|
108
|
+
package_manager.update(packages, :assumeyes => options[:assumeyes],
|
109
|
+
:yum_options => options[:yum_options])
|
109
110
|
when :remove
|
110
111
|
package_manager.remove(packages, :assumeyes => options[:assumeyes])
|
111
112
|
else
|
@@ -114,8 +115,12 @@ module ForemanMaintain
|
|
114
115
|
end
|
115
116
|
|
116
117
|
def package_version(name)
|
117
|
-
|
118
|
-
|
118
|
+
ver = if el?
|
119
|
+
'%{VERSION}'
|
120
|
+
elsif debian_or_ubuntu?
|
121
|
+
'${VERSION}'
|
122
|
+
end
|
123
|
+
pkg = package_manager.find_installed_package(name, ver)
|
119
124
|
version(pkg) unless pkg.nil?
|
120
125
|
end
|
121
126
|
|
@@ -184,7 +189,7 @@ module ForemanMaintain
|
|
184
189
|
end
|
185
190
|
|
186
191
|
def ruby_prefix(scl = true)
|
187
|
-
if
|
192
|
+
if debian_or_ubuntu?
|
188
193
|
'ruby-'
|
189
194
|
elsif el7? && scl
|
190
195
|
'tfm-rubygem-'
|
@@ -194,12 +199,12 @@ module ForemanMaintain
|
|
194
199
|
end
|
195
200
|
|
196
201
|
def foreman_plugin_name(plugin)
|
197
|
-
plugin = plugin.tr('_', '-') if
|
202
|
+
plugin = plugin.tr('_', '-') if debian_or_ubuntu?
|
198
203
|
ruby_prefix + plugin
|
199
204
|
end
|
200
205
|
|
201
206
|
def proxy_plugin_name(plugin)
|
202
|
-
if
|
207
|
+
if debian_or_ubuntu?
|
203
208
|
plugin = plugin.tr('_', '-')
|
204
209
|
proxy_plugin_prefix = 'smart-proxy-'
|
205
210
|
else
|
@@ -210,12 +215,12 @@ module ForemanMaintain
|
|
210
215
|
end
|
211
216
|
|
212
217
|
def hammer_plugin_name(plugin)
|
213
|
-
plugin = plugin.tr('_', '-') if
|
214
|
-
[hammer_package, plugin].join(
|
218
|
+
plugin = plugin.tr('_', '-') if debian_or_ubuntu?
|
219
|
+
[hammer_package, plugin].join(debian_or_ubuntu? ? '-' : '_')
|
215
220
|
end
|
216
221
|
|
217
222
|
def hammer_package
|
218
|
-
hammer_prefix = if
|
223
|
+
hammer_prefix = if debian_or_ubuntu?
|
219
224
|
'hammer-cli'
|
220
225
|
else
|
221
226
|
'hammer_cli'
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module ForemanMaintain::PackageManager
|
2
|
+
class Apt < Base
|
3
|
+
def installed?(packages)
|
4
|
+
packages_list = [packages].flatten(1).map { |pkg| "'#{pkg}'" }.join(' ')
|
5
|
+
status, output = sys.execute_with_status(%(dpkg --status #{packages_list}))
|
6
|
+
return false if status != 0
|
7
|
+
|
8
|
+
status_of_pkg = output.split("\n").grep(/^Status:/).first
|
9
|
+
status_of_pkg.include?('installed')
|
10
|
+
end
|
11
|
+
|
12
|
+
def install(packages, assumeyes: false)
|
13
|
+
apt_action('install', packages, :assumeyes => assumeyes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def remove(packages, assumeyes: false)
|
17
|
+
apt_action('remove', packages, :assumeyes => assumeyes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(packages = [], assumeyes: false)
|
21
|
+
action = packages.any? ? '--only-upgrade install' : 'upgrade'
|
22
|
+
apt_action(action, packages, :assumeyes => assumeyes)
|
23
|
+
end
|
24
|
+
|
25
|
+
def clean_cache(assumeyes: false)
|
26
|
+
apt_action('clean', :assumeyes => assumeyes)
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_installed_package(name, queryfm = '')
|
30
|
+
return unless installed?(name)
|
31
|
+
|
32
|
+
dpkg_cmd = "dpkg-query --show #{name}"
|
33
|
+
unless queryfm.empty?
|
34
|
+
dpkg_cmd = "dpkg-query --showformat='#{queryfm}' --show #{name}"
|
35
|
+
end
|
36
|
+
_, result = sys.execute_with_status(dpkg_cmd)
|
37
|
+
result
|
38
|
+
end
|
39
|
+
|
40
|
+
def check_update(packages: nil, with_status: false)
|
41
|
+
apt_action('upgrade --dry-run', packages, :with_status => with_status)
|
42
|
+
end
|
43
|
+
|
44
|
+
def list_installed_packages(queryfm = '${binary:Package}-${VERSION}\n')
|
45
|
+
# The queryfm should only include valid tag(s) as per `dpkg-query` man page.
|
46
|
+
# If any special formatting is required with querytag then it should be provided with tag i.e,
|
47
|
+
# querytag = "--%{VERSION}"
|
48
|
+
# The queryfm string must end with '\n'
|
49
|
+
sys.execute!("dpkg-query --showformat='#{queryfm}' -W").split("\n")
|
50
|
+
end
|
51
|
+
|
52
|
+
def version_locking_supported?
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
56
|
+
def apt_action(action, packages, with_status: false, assumeyes: false, valid_exit_statuses: [0])
|
57
|
+
apt_options = []
|
58
|
+
packages = [packages].flatten(1)
|
59
|
+
apt_options << '-y' if assumeyes
|
60
|
+
apt_options_s = apt_options.empty? ? '' : ' ' + apt_options.join(' ')
|
61
|
+
packages_s = packages.empty? ? '' : ' ' + packages.join(' ')
|
62
|
+
if with_status
|
63
|
+
sys.execute_with_status("apt-get#{apt_options_s} #{action}#{packages_s}",
|
64
|
+
:interactive => !assumeyes)
|
65
|
+
else
|
66
|
+
sys.execute!("apt-get#{apt_options_s} #{action}#{packages_s}",
|
67
|
+
:interactive => !assumeyes, :valid_exit_statuses => valid_exit_statuses)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -59,8 +59,8 @@ module ForemanMaintain::PackageManager
|
|
59
59
|
yum_action('remove', packages, :assumeyes => assumeyes)
|
60
60
|
end
|
61
61
|
|
62
|
-
def update(packages = [], assumeyes: false)
|
63
|
-
yum_action('update', packages, :assumeyes => assumeyes)
|
62
|
+
def update(packages = [], assumeyes: false, yum_options: [])
|
63
|
+
yum_action('update', packages, :assumeyes => assumeyes, :yum_options => yum_options)
|
64
64
|
end
|
65
65
|
|
66
66
|
def clean_cache(assumeyes: false)
|
@@ -120,8 +120,12 @@ module ForemanMaintain::PackageManager
|
|
120
120
|
File.open(protector_config_file, 'w') { |file| file.puts config }
|
121
121
|
end
|
122
122
|
|
123
|
-
|
124
|
-
|
123
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
124
|
+
def yum_action(action, packages, options)
|
125
|
+
with_status = options.fetch(:with_status, false)
|
126
|
+
assumeyes = options.fetch(:assumeyes, false)
|
127
|
+
valid_exit_statuses = options.fetch(:valid_exit_statuses, [0])
|
128
|
+
yum_options = options.fetch(:yum_options, [])
|
125
129
|
packages = [packages].flatten(1)
|
126
130
|
yum_options << '-y' if assumeyes
|
127
131
|
yum_options << '--disableplugin=foreman-protector'
|
@@ -1,14 +1,16 @@
|
|
1
1
|
require 'foreman_maintain/package_manager/base'
|
2
2
|
require 'foreman_maintain/package_manager/yum'
|
3
3
|
require 'foreman_maintain/package_manager/dnf'
|
4
|
+
require 'foreman_maintain/package_manager/apt'
|
4
5
|
|
5
6
|
module ForemanMaintain
|
6
7
|
def self.package_manager
|
7
|
-
@package_manager ||=
|
8
|
-
when 'dnf'
|
9
|
-
ForemanMaintain::PackageManager::Dnf.new
|
10
|
-
when 'yum'
|
8
|
+
@package_manager ||= if el7?
|
11
9
|
ForemanMaintain::PackageManager::Yum.new
|
10
|
+
elsif el?
|
11
|
+
ForemanMaintain::PackageManager::Dnf.new
|
12
|
+
elsif debian_or_ubuntu?
|
13
|
+
ForemanMaintain::PackageManager::Apt.new
|
12
14
|
else
|
13
15
|
raise 'No supported package manager was found'
|
14
16
|
end
|
@@ -317,7 +317,11 @@ module ForemanMaintain
|
|
317
317
|
|
318
318
|
steps_with_error = scenario.steps_with_error(:whitelisted => false)
|
319
319
|
steps_with_skipped = scenario.steps_with_skipped(:whitelisted => true)
|
320
|
-
|
320
|
+
not_skippable_steps = scenario.steps_with_error.select do |step|
|
321
|
+
step.metadata[:do_not_whitelist] == true
|
322
|
+
end
|
323
|
+
|
324
|
+
steps_to_whitelist = steps_with_error + steps_with_skipped - not_skippable_steps
|
321
325
|
unless steps_with_error.empty?
|
322
326
|
message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
|
323
327
|
The following steps ended up in failing state:
|
@@ -325,11 +329,25 @@ module ForemanMaintain
|
|
325
329
|
%s
|
326
330
|
MESSAGE
|
327
331
|
whitelist_labels = steps_to_whitelist.map(&:label_dashed).join(',')
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
332
|
+
unless whitelist_labels.empty?
|
333
|
+
recommend << if scenario.detector.feature(:instance).downstream
|
334
|
+
format(<<-MESSAGE.strip_heredoc, whitelist_labels)
|
335
|
+
Resolve the failed steps and rerun the command.
|
336
|
+
|
337
|
+
If the situation persists and, you are unclear what to do next,
|
338
|
+
contact Red Hat Technical Support.
|
339
|
+
|
340
|
+
In case the failures are false positives, use
|
341
|
+
--whitelist="%s"
|
342
|
+
MESSAGE
|
343
|
+
else
|
344
|
+
format(<<-MESSAGE.strip_heredoc, whitelist_labels)
|
345
|
+
Resolve the failed steps and rerun the command.
|
346
|
+
In case the failures are false positives, use
|
347
|
+
--whitelist="%s"
|
348
|
+
MESSAGE
|
349
|
+
end
|
350
|
+
end
|
333
351
|
end
|
334
352
|
|
335
353
|
steps_with_warning = scenario.steps_with_warning(:whitelisted => false)
|
@@ -76,10 +76,21 @@ module ForemanMaintain::RepositoryManager
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def hash_of_repoids_urls(repos, regex)
|
79
|
-
Hash[*repos.split("\n").grep(regex).map do |entry|
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
ids_urls = Hash[*repos.split("\n").grep(regex).map do |entry|
|
80
|
+
entry.split(':', 2).last.strip
|
81
|
+
end]
|
82
|
+
|
83
|
+
# The EL7 yum repolist output includes extra info in the output,
|
84
|
+
# as example
|
85
|
+
# rhel-7-server-rpms/7Server/x86_64
|
86
|
+
# rhel-server-rhscl-7-rpms/7Server/x86_64
|
87
|
+
# This trims anything after first '/' to get correct repo label
|
88
|
+
trimmed_hash = {}
|
89
|
+
ids_urls.each do |id, url|
|
90
|
+
trimmed_id = id.split('/').first
|
91
|
+
trimmed_hash[trimmed_id] = url
|
92
|
+
end
|
93
|
+
trimmed_hash
|
83
94
|
end
|
84
95
|
end
|
85
96
|
end
|
data/lib/foreman_maintain.rb
CHANGED
@@ -26,6 +26,7 @@ module ForemanMaintain
|
|
26
26
|
require 'foreman_maintain/concerns/pulp_common'
|
27
27
|
require 'foreman_maintain/concerns/firewall/iptables_maintenance_mode'
|
28
28
|
require 'foreman_maintain/concerns/firewall/nftables_maintenance_mode'
|
29
|
+
require 'foreman_maintain/concerns/firewall/maintenance_mode'
|
29
30
|
require 'foreman_maintain/top_level_modules'
|
30
31
|
require 'foreman_maintain/yaml_storage'
|
31
32
|
require 'foreman_maintain/config'
|
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.1.
|
4
|
+
version: 1.1.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: 2022-
|
11
|
+
date: 2022-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- definitions/procedures/foreman_tasks/ui_investigate.rb
|
267
267
|
- definitions/procedures/hammer_setup.rb
|
268
268
|
- definitions/procedures/installer/run.rb
|
269
|
+
- definitions/procedures/installer/run_for_6_11.rb
|
269
270
|
- definitions/procedures/installer/upgrade.rb
|
270
271
|
- definitions/procedures/installer/upgrade_rake_task.rb
|
271
272
|
- definitions/procedures/knowledge_base_article.rb
|
@@ -392,6 +393,7 @@ files:
|
|
392
393
|
- lib/foreman_maintain/concerns/downstream.rb
|
393
394
|
- lib/foreman_maintain/concerns/finders.rb
|
394
395
|
- lib/foreman_maintain/concerns/firewall/iptables_maintenance_mode.rb
|
396
|
+
- lib/foreman_maintain/concerns/firewall/maintenance_mode.rb
|
395
397
|
- lib/foreman_maintain/concerns/firewall/nftables_maintenance_mode.rb
|
396
398
|
- lib/foreman_maintain/concerns/hammer.rb
|
397
399
|
- lib/foreman_maintain/concerns/logger.rb
|
@@ -413,6 +415,7 @@ files:
|
|
413
415
|
- lib/foreman_maintain/executable.rb
|
414
416
|
- lib/foreman_maintain/feature.rb
|
415
417
|
- lib/foreman_maintain/package_manager.rb
|
418
|
+
- lib/foreman_maintain/package_manager/apt.rb
|
416
419
|
- lib/foreman_maintain/package_manager/base.rb
|
417
420
|
- lib/foreman_maintain/package_manager/dnf.rb
|
418
421
|
- lib/foreman_maintain/package_manager/yum.rb
|