foreman_maintain 0.5.0 → 0.5.5
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/checks/foreman/facts_names.rb +32 -0
- data/definitions/checks/original_assets.rb +1 -1
- data/definitions/checks/version_locking_enabled.rb +1 -1
- data/definitions/features/capsule.rb +2 -2
- data/definitions/features/foreman_tasks.rb +8 -3
- data/definitions/features/katello.rb +12 -1
- data/definitions/features/pulp.rb +1 -5
- data/definitions/features/puppet_server.rb +6 -2
- data/definitions/features/satellite.rb +1 -1
- data/definitions/features/tar.rb +5 -0
- data/definitions/procedures/backup/config_files.rb +3 -0
- data/definitions/procedures/backup/prepare_directory.rb +8 -1
- data/definitions/procedures/foreman/fix_corrupted_roles.rb +0 -1
- data/definitions/procedures/foreman_openscap/invalid_report_associations.rb +1 -1
- data/definitions/procedures/knowledge_base_article.rb +2 -1
- data/definitions/procedures/packages/enable_version_locking.rb +1 -1
- data/definitions/procedures/packages/installer_confirmation.rb +1 -1
- data/definitions/procedures/packages/lock_versions.rb +1 -2
- data/definitions/procedures/packages/locking_status.rb +1 -2
- data/definitions/procedures/packages/unlock_versions.rb +1 -2
- data/definitions/procedures/packages/update.rb +1 -1
- data/definitions/procedures/packages/update_all_confirmation.rb +24 -0
- data/definitions/procedures/restore/extract_files.rb +1 -0
- data/definitions/scenarios/backup.rb +2 -1
- data/definitions/scenarios/packages.rb +7 -3
- data/extras/foreman_protector/foreman-protector.py +1 -1
- data/extras/foreman_protector/foreman-protector.whitelist +1 -0
- data/lib/foreman_maintain.rb +1 -1
- data/lib/foreman_maintain/cli/packages_command.rb +2 -2
- data/lib/foreman_maintain/concerns/downstream.rb +1 -2
- data/lib/foreman_maintain/concerns/system_helpers.rb +8 -4
- data/lib/foreman_maintain/feature.rb +4 -0
- data/lib/foreman_maintain/package_manager.rb +13 -0
- data/lib/foreman_maintain/reporter/cli_reporter.rb +3 -3
- data/lib/foreman_maintain/utils/disk/io_device.rb +1 -1
- data/lib/foreman_maintain/utils/facter.rb +1 -1
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +9 -9
- data/definitions/features/package_manager.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88713e93aedca954a3162bfcb296a4e34702d3d5ffa4378b6f913081a5377e2c
|
4
|
+
data.tar.gz: 561a9cf651b6a8676efe9471eb2cde54e30cec37cf37f311f59ee7a886f44642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d0d4a7cbdad45bcfd35be8029fa7be9b458b72df62a9e83a72ffdd1e3b049fcff2ba72b2368531f2a40a40ac6578381fe57a91ef8abbcd7edd63908b9759071
|
7
|
+
data.tar.gz: 4635df0f060dd06372cb9ff77cbc6f0ac8756dbd4b7814f47e27444e4e1d480b648b5175391f4c337e1dd3934a5b077d5db4caa22b74b4c085ac66c9ba81dba9
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Checks
|
2
|
+
module Foreman
|
3
|
+
class FactsNames < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
label :foreman_fact_names
|
6
|
+
tags :default
|
7
|
+
confine do
|
8
|
+
feature(:foreman_database)
|
9
|
+
end
|
10
|
+
description 'Check number of fact names in database'
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
max = 10_000
|
15
|
+
sql = <<-SQL
|
16
|
+
select fact_values.host_id, count(fact_values.id) from fact_values
|
17
|
+
group by fact_values.host_id order by count desc limit 1
|
18
|
+
SQL
|
19
|
+
result = feature(:foreman_database).query(sql).first
|
20
|
+
if result
|
21
|
+
host_id = result['host_id']
|
22
|
+
count = result['count'].to_i
|
23
|
+
assert(count < max,
|
24
|
+
"Host (ID #{host_id}) has #{count} fact values which is more than #{max}.\n" \
|
25
|
+
'This can cause slow fact processing.',
|
26
|
+
:warn => true,
|
27
|
+
:next_steps => [Procedures::KnowledgeBaseArticle.new(:doc => 'many_fact_values')])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -10,7 +10,7 @@ class Checks::OriginalAssets < ForemanMaintain::Check
|
|
10
10
|
custom_assets = []
|
11
11
|
product_name = feature(:instance).product_name
|
12
12
|
with_spinner('Checking for presence of non-original assets...') do
|
13
|
-
custom_assets =
|
13
|
+
custom_assets = package_manager.files_not_owned_by_package(ASSETS_DIR)
|
14
14
|
logger.info("Non-original assets detected:\n" + custom_assets.join("\n"))
|
15
15
|
end
|
16
16
|
remove_files = Procedures::Files::Remove.new(:files => custom_assets, :assumeyes => true)
|
@@ -5,7 +5,7 @@ module Checks
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run
|
8
|
-
enabled =
|
8
|
+
enabled = package_manager.version_locking_enabled?
|
9
9
|
enable_locking = Procedures::Packages::EnableVersionLocking.new(:assumeyes => assumeyes?)
|
10
10
|
assert(enabled, 'Tools for package version locking are not available on this system',
|
11
11
|
:next_steps => enable_locking)
|
@@ -5,8 +5,8 @@ class Features::Capsule < ForemanMaintain::Feature
|
|
5
5
|
label :capsule
|
6
6
|
|
7
7
|
confine do
|
8
|
-
|
9
|
-
|
8
|
+
package_manager.installed?(['satellite-capsule']) ||
|
9
|
+
package_manager.installed?(['capsule-installer'])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -55,7 +55,7 @@ class Features::ForemanTasks < ForemanMaintain::Feature
|
|
55
55
|
sql = <<-SQL
|
56
56
|
SELECT count(*) AS count
|
57
57
|
FROM foreman_tasks_tasks
|
58
|
-
WHERE state IN ('paused')
|
58
|
+
WHERE state IN ('paused') AND result IN ('error')
|
59
59
|
SQL
|
60
60
|
unless ignored_tasks.empty?
|
61
61
|
sql << "AND label NOT IN (#{quotize(ignored_tasks)})"
|
@@ -162,8 +162,13 @@ class Features::ForemanTasks < ForemanMaintain::Feature
|
|
162
162
|
def export_csv(sql, file_name, state)
|
163
163
|
dir = prepare_for_backup(state)
|
164
164
|
filepath = "#{dir}/#{file_name}"
|
165
|
-
|
166
|
-
|
165
|
+
csv_output = feature(:foreman_database).query_csv(sql)
|
166
|
+
File.open(filepath, 'w') do |f|
|
167
|
+
f.write(csv_output)
|
168
|
+
f.close
|
169
|
+
end
|
170
|
+
execute("bzip2 #{filepath} -c -9 > #{filepath}.bz2")
|
171
|
+
FileUtils.rm_rf(filepath)
|
167
172
|
end
|
168
173
|
|
169
174
|
def old_tasks_condition(state = "'stopped', 'paused'")
|
@@ -32,7 +32,11 @@ class Features::Katello < ForemanMaintain::Feature
|
|
32
32
|
'/etc/sysconfig/tomcat*',
|
33
33
|
'/etc/tomcat*',
|
34
34
|
'/var/lib/candlepin',
|
35
|
-
'/usr/share/foreman/bundler.d/katello.rb'
|
35
|
+
'/usr/share/foreman/bundler.d/katello.rb',
|
36
|
+
'/etc/qpid',
|
37
|
+
'/etc/qpid-dispatch',
|
38
|
+
'/var/lib/qpidd',
|
39
|
+
'/etc/qpid-dispatch'
|
36
40
|
]
|
37
41
|
|
38
42
|
if installer_scenario_answers['certs']
|
@@ -48,6 +52,13 @@ class Features::Katello < ForemanMaintain::Feature
|
|
48
52
|
end
|
49
53
|
# rubocop:enable Metrics/MethodLength
|
50
54
|
|
55
|
+
def config_files_exclude_for_online
|
56
|
+
[
|
57
|
+
'/var/lib/qpidd',
|
58
|
+
'/var/lib/candlepin/activemq-artemis'
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
51
62
|
private
|
52
63
|
|
53
64
|
def installer_scenario_answers
|
@@ -30,12 +30,8 @@ class Features::Pulp < ForemanMaintain::Feature
|
|
30
30
|
[
|
31
31
|
'/etc/pki/pulp',
|
32
32
|
'/etc/pulp',
|
33
|
-
'/etc/qpid',
|
34
|
-
'/etc/qpid-dispatch',
|
35
33
|
'/etc/crane.conf',
|
36
|
-
'/etc/default/pulp_workers'
|
37
|
-
'/var/lib/qpidd',
|
38
|
-
'/etc/qpid-dispatch'
|
34
|
+
'/etc/default/pulp_workers'
|
39
35
|
]
|
40
36
|
end
|
41
37
|
end
|
@@ -29,7 +29,7 @@ class Features::PuppetServer < ForemanMaintain::Feature
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def puppet_version
|
32
|
-
version(execute!(
|
32
|
+
version(execute!("#{puppet_path} --version"))
|
33
33
|
end
|
34
34
|
|
35
35
|
def find_empty_cacert_request_files
|
@@ -56,6 +56,10 @@ class Features::PuppetServer < ForemanMaintain::Feature
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def puppet_ssldir_path
|
59
|
-
execute!(
|
59
|
+
execute!("#{puppet_path} config print ssldir")
|
60
|
+
end
|
61
|
+
|
62
|
+
def puppet_path
|
63
|
+
'/opt/puppetlabs/bin/puppet'
|
60
64
|
end
|
61
65
|
end
|
data/definitions/features/tar.rb
CHANGED
@@ -24,6 +24,7 @@ class Features::Tar < ForemanMaintain::Feature
|
|
24
24
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
25
25
|
def run(options = {})
|
26
26
|
volume_size = options.fetch(:volume_size, nil)
|
27
|
+
absolute_names = options.fetch(:absolute_names, nil)
|
27
28
|
validate_volume_size(volume_size) unless volume_size.nil?
|
28
29
|
|
29
30
|
tar_command = ['tar']
|
@@ -31,6 +32,10 @@ class Features::Tar < ForemanMaintain::Feature
|
|
31
32
|
tar_command << "--#{options.fetch(:command, 'create')}"
|
32
33
|
tar_command << "--file=#{options.fetch(:archive)}"
|
33
34
|
|
35
|
+
if absolute_names
|
36
|
+
tar_command << '--absolute-names'
|
37
|
+
end
|
38
|
+
|
34
39
|
if volume_size
|
35
40
|
split_tar_script = default_split_tar_script
|
36
41
|
tar_command << "--tape-length=#{volume_size}"
|
@@ -13,6 +13,8 @@ module Procedures::Backup
|
|
13
13
|
:array => true, :default => ['all']
|
14
14
|
param :ignore_changed_files, 'Should packing tar ignore changed files',
|
15
15
|
:flag => true, :default => false
|
16
|
+
param :online_backup, 'The config files are being prepared for an online backup',
|
17
|
+
:flag => true, :default => false
|
16
18
|
end
|
17
19
|
|
18
20
|
def run
|
@@ -39,6 +41,7 @@ module Procedures::Backup
|
|
39
41
|
|
40
42
|
configs += feature.config_files
|
41
43
|
exclude_configs += feature.config_files_to_exclude
|
44
|
+
exclude_configs += feature.config_files_exclude_for_online if @online_backup
|
42
45
|
end
|
43
46
|
|
44
47
|
if feature(:foreman_proxy)
|
@@ -8,6 +8,7 @@ module Procedures::Backup
|
|
8
8
|
param :incremental_dir, 'Changes since specified backup only'
|
9
9
|
end
|
10
10
|
|
11
|
+
# rubocop:disable Metrics/MethodLength
|
11
12
|
def run
|
12
13
|
puts "Creating backup folder #{@backup_dir}"
|
13
14
|
|
@@ -22,8 +23,14 @@ module Procedures::Backup
|
|
22
23
|
|
23
24
|
FileUtils.rm(Dir.glob(File.join(@backup_dir, '.*.snar'))) if @preserve_dir
|
24
25
|
if @incremental_dir
|
25
|
-
|
26
|
+
if (snar_files = Dir.glob(File.join(@incremental_dir, '.*.snar'))).empty?
|
27
|
+
raise "#{@incremental_dir}/*.snar files unavailable. "\
|
28
|
+
'Provide a valid previous backup directory'
|
29
|
+
else
|
30
|
+
FileUtils.cp(snar_files, @backup_dir)
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
34
|
+
# rubocop:enable Metrics/MethodLength
|
28
35
|
end
|
29
36
|
end
|
@@ -2,7 +2,6 @@ module Procedures::Foreman
|
|
2
2
|
class FixCorruptedRoles < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
4
|
for_feature :foreman_database
|
5
|
-
tags :pre_migration
|
6
5
|
desc = 'Create additional filters so that each filter has only permissions of one resource'
|
7
6
|
description desc
|
8
7
|
confine do
|
@@ -3,7 +3,7 @@ module Procedures::ForemanOpenscap
|
|
3
3
|
metadata do
|
4
4
|
param :ids_to_remove, 'Ids of reports to remove', :required => true
|
5
5
|
for_feature :foreman_openscap
|
6
|
-
tags :
|
6
|
+
tags :foreman_openscap, :openscap_report_associations
|
7
7
|
advanced_run false
|
8
8
|
description 'Delete reports with association issues'
|
9
9
|
end
|
@@ -25,7 +25,8 @@ class Procedures::KnowledgeBaseArticle < ForemanMaintain::Procedure
|
|
25
25
|
{
|
26
26
|
'fix_cpdb_validate_failure' => 'https://access.redhat.com/solutions/3362821',
|
27
27
|
'fix_db_migrate_failure_on_duplicate_roles' => 'https://access.redhat.com/solutions/3998941',
|
28
|
-
'upgrade_puppet_guide_for_sat63' => 'https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/upgrading_and_updating_red_hat_satellite/upgrading_puppet-1'
|
28
|
+
'upgrade_puppet_guide_for_sat63' => 'https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/upgrading_and_updating_red_hat_satellite/upgrading_puppet-1',
|
29
|
+
'many_fact_values' => 'https://access.redhat.com/solutions/4163891'
|
29
30
|
}
|
30
31
|
end
|
31
32
|
end
|
@@ -5,7 +5,7 @@ module Procedures::Packages
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run
|
8
|
-
question = "
|
8
|
+
question = "\nWARNING: This script runs #{feature(:installer).installer_command} " \
|
9
9
|
"after the yum execution \n" \
|
10
10
|
"to ensure the #{feature(:instance).product_name} " \
|
11
11
|
"is in a consistent state.\n" \
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module Procedures::Packages
|
2
2
|
class LockVersions < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
|
-
for_feature :package_manager
|
5
4
|
description 'Lock packages'
|
6
5
|
preparation_steps { [Checks::VersionLockingEnabled.new] }
|
7
6
|
end
|
8
7
|
|
9
8
|
def run
|
10
|
-
|
9
|
+
package_manager.lock_versions
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Procedures::Packages
|
2
2
|
class LockingStatus < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
|
-
for_feature :package_manager
|
5
4
|
description 'Check status of version locking of packages'
|
6
5
|
preparation_steps { [Checks::VersionLockingEnabled.new] }
|
7
6
|
end
|
@@ -14,7 +13,7 @@ module Procedures::Packages
|
|
14
13
|
private
|
15
14
|
|
16
15
|
def check_version_locked
|
17
|
-
if
|
16
|
+
if package_manager.versions_locked?
|
18
17
|
puts ' Packages are locked.'
|
19
18
|
else
|
20
19
|
puts ' Packages are not locked.'
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module Procedures::Packages
|
2
2
|
class UnlockVersions < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
|
-
for_feature :package_manager
|
5
4
|
description 'Unlock packages'
|
6
5
|
preparation_steps { [Checks::VersionLockingEnabled.new] }
|
7
6
|
end
|
8
7
|
|
9
8
|
def run
|
10
|
-
|
9
|
+
package_manager.unlock_versions
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -10,7 +10,7 @@ module Procedures::Packages
|
|
10
10
|
|
11
11
|
def run
|
12
12
|
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
13
|
-
|
13
|
+
package_manager.clean_cache
|
14
14
|
packages_action(:update, @packages, :assumeyes => assumeyes_val)
|
15
15
|
rescue ForemanMaintain::Error::ExecutionError => e
|
16
16
|
if @warn_on_errors
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Procedures::Packages
|
2
|
+
class UpdateAllConfirmation < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
param :packages, 'List of packages to update', :array => true
|
5
|
+
|
6
|
+
description 'Confirm update all is intentional'
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
if @packages.nil? || @packages.empty?
|
11
|
+
question = "\nWARNING: No specific packages to update were provided\n" \
|
12
|
+
"so we are going to update all available packages.\n" \
|
13
|
+
"It is recommended to update everything only as part of upgrade\n" \
|
14
|
+
"of the #{feature(:instance).product_name} to the next version. \n" \
|
15
|
+
"To Upgrade to next version use 'foreman-maintain upgrade'.\n\n" \
|
16
|
+
"NOTE: --assumeyes is not applicable for this check\n\n" \
|
17
|
+
"Do you want to proceed with update of everything regardless\n" \
|
18
|
+
'of the recommendations?'
|
19
|
+
answer = ask_decision(question, 'y(yes), q(quit)', ignore_assumeyes: true)
|
20
|
+
abort! unless answer == :yes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -186,7 +186,8 @@ module ForemanMaintain::Scenarios
|
|
186
186
|
# rubocop:enable Metrics/MethodLength
|
187
187
|
|
188
188
|
def add_online_backup_steps
|
189
|
-
add_step_with_context(Procedures::Backup::ConfigFiles, :ignore_changed_files => true
|
189
|
+
add_step_with_context(Procedures::Backup::ConfigFiles, :ignore_changed_files => true,
|
190
|
+
:online_backup => true)
|
190
191
|
add_step_with_context(Procedures::Backup::Pulp, :ensure_unchanged => true)
|
191
192
|
add_steps_with_context(
|
192
193
|
Procedures::Backup::Online::Mongo,
|
@@ -71,8 +71,11 @@ module ForemanMaintain::Scenarios
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def compose
|
74
|
-
|
75
|
-
|
74
|
+
add_steps_with_context(
|
75
|
+
Procedures::Packages::UpdateAllConfirmation,
|
76
|
+
Procedures::Packages::InstallerConfirmation,
|
77
|
+
Procedures::Packages::UnlockVersions
|
78
|
+
)
|
76
79
|
add_step_with_context(Procedures::Packages::Update, :force => true, :warn_on_errors => true)
|
77
80
|
add_step_with_context(Procedures::Installer::Run,
|
78
81
|
:arguments => '--upgrade --disable-system-checks')
|
@@ -81,7 +84,8 @@ module ForemanMaintain::Scenarios
|
|
81
84
|
|
82
85
|
def set_context_mapping
|
83
86
|
context.map(:packages,
|
84
|
-
Procedures::Packages::Update => :packages
|
87
|
+
Procedures::Packages::Update => :packages,
|
88
|
+
Procedures::Packages::UpdateAllConfirmation => :packages)
|
85
89
|
context.map(:assumeyes,
|
86
90
|
Procedures::Packages::Update => :assumeyes)
|
87
91
|
end
|
@@ -77,7 +77,7 @@ def exclude_hook(conduit):
|
|
77
77
|
else:
|
78
78
|
suffix = ''
|
79
79
|
conduit.info(1, '\n'
|
80
|
-
'WARNING: Excluding %d
|
80
|
+
'WARNING: Excluding %d package%s due to foreman-protector. \n'
|
81
81
|
'Use foreman-maintain packages install/update <package> \n'
|
82
82
|
'to safely install packages without restrictions.\n'
|
83
83
|
'Use foreman-maintain upgrade run for full upgrade.\n'
|
data/lib/foreman_maintain.rb
CHANGED
@@ -36,9 +36,9 @@ module ForemanMaintain
|
|
36
36
|
require 'foreman_maintain/runner'
|
37
37
|
require 'foreman_maintain/upgrade_runner'
|
38
38
|
require 'foreman_maintain/reporter'
|
39
|
+
require 'foreman_maintain/package_manager'
|
39
40
|
require 'foreman_maintain/utils'
|
40
41
|
require 'foreman_maintain/error'
|
41
|
-
require 'foreman_maintain/package_manager'
|
42
42
|
|
43
43
|
class << self
|
44
44
|
attr_accessor :config, :logger
|
@@ -38,7 +38,7 @@ module ForemanMaintain
|
|
38
38
|
|
39
39
|
subcommand 'update', 'Update packages in an unlocked session' do
|
40
40
|
interactive_option
|
41
|
-
parameter 'PACKAGES ...', 'packages to update', :attribute_name => :packages
|
41
|
+
parameter '[PACKAGES ...]', 'packages to update', :attribute_name => :packages
|
42
42
|
|
43
43
|
def execute
|
44
44
|
run_scenarios_and_exit(
|
@@ -53,7 +53,7 @@ module ForemanMaintain
|
|
53
53
|
subcommand 'is-locked', 'Check if update of packages is allowed' do
|
54
54
|
interactive_option
|
55
55
|
def execute
|
56
|
-
locked =
|
56
|
+
locked = ForemanMaintain.package_manager.versions_locked?
|
57
57
|
puts "Packages are#{locked ? '' : ' not'} locked"
|
58
58
|
exit_code = locked ? 0 : 1
|
59
59
|
exit exit_code
|
@@ -87,8 +87,7 @@ module ForemanMaintain
|
|
87
87
|
else
|
88
88
|
"rhel-#{rh_version_major}-server-#{package_name}-#{full_version}-rpms"
|
89
89
|
end
|
90
|
-
|
91
|
-
if current_minor_version == '6.3' && server_version.to_s != '6.4' && (
|
90
|
+
if current_minor_version == '6.3' && full_version.to_s != '6.4' && (
|
92
91
|
feature(:puppet_server) && feature(:puppet_server).puppet_version.major == 4)
|
93
92
|
# TODO: confirm repo for capsule. It might be same repo
|
94
93
|
repos << "rhel-#{rh_version_major}-server-satellite-tools-6.3-puppet4-rpms"
|
@@ -85,7 +85,7 @@ module ForemanMaintain
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def find_package(name)
|
88
|
-
|
88
|
+
package_manager.find_installed_package(name)
|
89
89
|
end
|
90
90
|
|
91
91
|
def hostname
|
@@ -100,11 +100,11 @@ module ForemanMaintain
|
|
100
100
|
options.validate_options!(:assumeyes)
|
101
101
|
case action
|
102
102
|
when :install
|
103
|
-
|
103
|
+
package_manager.install(packages, :assumeyes => options[:assumeyes])
|
104
104
|
when :update
|
105
|
-
|
105
|
+
package_manager.update(packages, :assumeyes => options[:assumeyes])
|
106
106
|
when :remove
|
107
|
-
|
107
|
+
package_manager.remove(packages, :assumeyes => options[:assumeyes])
|
108
108
|
else
|
109
109
|
raise ArgumentError, "Unexpected action #{action} expected #{expected_actions.inspect}"
|
110
110
|
end
|
@@ -178,6 +178,10 @@ module ForemanMaintain
|
|
178
178
|
result
|
179
179
|
end
|
180
180
|
|
181
|
+
def package_manager
|
182
|
+
ForemanMaintain.package_manager
|
183
|
+
end
|
184
|
+
|
181
185
|
private
|
182
186
|
|
183
187
|
def check_version(name)
|
@@ -1,3 +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
|
+
|
5
|
+
module ForemanMaintain
|
6
|
+
def self.package_manager
|
7
|
+
@package_manager ||= case (%w[dnf yum apt].find { |manager| !`command -v #{manager}`.empty? })
|
8
|
+
when 'dnf'
|
9
|
+
ForemanMaintain::PackageManager::Dnf.new
|
10
|
+
when 'yum'
|
11
|
+
ForemanMaintain::PackageManager::Yum.new
|
12
|
+
else
|
13
|
+
raise 'No supported package manager was found'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -184,9 +184,9 @@ module ForemanMaintain
|
|
184
184
|
ask_to_select('Select step to continue', steps, &:runtime_message)
|
185
185
|
end
|
186
186
|
|
187
|
-
def ask_decision(message, options = 'y(yes), n(no), q(quit)')
|
188
|
-
if assumeyes?
|
189
|
-
print("#{message} (assuming yes)")
|
187
|
+
def ask_decision(message, options = 'y(yes), n(no), q(quit)', ignore_assumeyes: false)
|
188
|
+
if !ignore_assumeyes && assumeyes?
|
189
|
+
print("#{message} (assuming yes)\n")
|
190
190
|
return :yes
|
191
191
|
end
|
192
192
|
until_valid_decision do
|
@@ -27,7 +27,7 @@ module ForemanMaintain
|
|
27
27
|
# In fio command, --direct option bypass the cache page
|
28
28
|
def fio
|
29
29
|
cmd = "fio --name=job1 --rw=read --size=1g --output-format=json\
|
30
|
-
--directory=#{dir} --direct=1"
|
30
|
+
--directory=#{dir} --direct=1 --unlink=1"
|
31
31
|
stdout = execute(cmd)
|
32
32
|
output = JSON.parse(stdout)
|
33
33
|
@fio ||= output['jobs'].first['read']['bw'].to_i
|
@@ -5,7 +5,7 @@ module ForemanMaintain::Utils
|
|
5
5
|
FACTER_FILES = %w[/usr/bin/facter /opt/puppetlabs/bin/facter].freeze
|
6
6
|
|
7
7
|
def self.package
|
8
|
-
puppet_version = version(execute!('puppet --version'))
|
8
|
+
puppet_version = version(execute!('/opt/puppetlabs/bin/puppet --version'))
|
9
9
|
|
10
10
|
puppet_version.major >= 4 ? 'puppet-agent' : 'facter'
|
11
11
|
end
|
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.5.
|
4
|
+
version: 0.5.5
|
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:
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.17'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- definitions/checks/foreman/check_corrupted_roles.rb
|
131
131
|
- definitions/checks/foreman/check_duplicate_roles.rb
|
132
132
|
- definitions/checks/foreman/db_up.rb
|
133
|
+
- definitions/checks/foreman/facts_names.rb
|
133
134
|
- definitions/checks/foreman/puppet_class_duplicates.rb
|
134
135
|
- definitions/checks/foreman_openscap/invalid_report_associations.rb
|
135
136
|
- definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb
|
@@ -173,7 +174,6 @@ files:
|
|
173
174
|
- definitions/features/iptables.rb
|
174
175
|
- definitions/features/katello.rb
|
175
176
|
- definitions/features/mongo.rb
|
176
|
-
- definitions/features/package_manager.rb
|
177
177
|
- definitions/features/pulp.rb
|
178
178
|
- definitions/features/puppet_server.rb
|
179
179
|
- definitions/features/satellite.rb
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- definitions/procedures/packages/locking_status.rb
|
234
234
|
- definitions/procedures/packages/unlock_versions.rb
|
235
235
|
- definitions/procedures/packages/update.rb
|
236
|
+
- definitions/procedures/packages/update_all_confirmation.rb
|
236
237
|
- definitions/procedures/passenger_recycler.rb
|
237
238
|
- definitions/procedures/pulp/migrate.rb
|
238
239
|
- definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb
|
@@ -377,8 +378,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
377
378
|
- !ruby/object:Gem::Version
|
378
379
|
version: '0'
|
379
380
|
requirements: []
|
380
|
-
|
381
|
-
rubygems_version: 2.7.10
|
381
|
+
rubygems_version: 3.0.3
|
382
382
|
signing_key:
|
383
383
|
specification_version: 4
|
384
384
|
summary: Foreman maintenance tool belt
|
@@ -1,33 +0,0 @@
|
|
1
|
-
class Features::PackageManager < ForemanMaintain::Feature
|
2
|
-
metadata do
|
3
|
-
label :package_manager
|
4
|
-
end
|
5
|
-
|
6
|
-
extend Forwardable
|
7
|
-
def_delegators :manager, :lock_versions, :unlock_versions,
|
8
|
-
:installed?, :find_installed_package, :install, :update,
|
9
|
-
:version_locking_enabled?, :install_version_locking,
|
10
|
-
:versions_locked?, :clean_cache, :remove, :files_not_owned_by_package
|
11
|
-
|
12
|
-
def self.type
|
13
|
-
@type ||= %w[dnf yum apt].find { |manager| command_present?(manager) }
|
14
|
-
end
|
15
|
-
|
16
|
-
def type
|
17
|
-
self.class.type
|
18
|
-
end
|
19
|
-
|
20
|
-
def manager
|
21
|
-
@manager ||= case type
|
22
|
-
when 'dnf'
|
23
|
-
ForemanMaintain::PackageManager::Dnf.new
|
24
|
-
when 'yum'
|
25
|
-
ForemanMaintain::PackageManager::Yum.new
|
26
|
-
else
|
27
|
-
raise 'No supported package manager was found'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# TODO: DEB grep ^Package: /var/lib/apt/lists/deb.theforeman.org_dists_*
|
32
|
-
# TODO DEB apt-mark hold/unhold <package>
|
33
|
-
end
|