foreman_maintain 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/checks/backup/directory_ready.rb +3 -1
- data/definitions/features/foreman_server.rb +1 -5
- data/definitions/features/pulpcore.rb +2 -28
- data/definitions/procedures/packages/update.rb +5 -1
- data/definitions/procedures/pulpcore/migrate.rb +2 -3
- data/definitions/procedures/pulpcore/trim_rpm_changelogs.rb +2 -3
- data/definitions/procedures/service/restart.rb +1 -2
- data/definitions/scenarios/backup.rb +3 -4
- data/definitions/scenarios/upgrade_to_capsule_6_14.rb +3 -2
- data/definitions/scenarios/upgrade_to_capsule_6_14_z.rb +3 -2
- data/definitions/scenarios/upgrade_to_katello_nightly.rb +3 -0
- data/definitions/scenarios/upgrade_to_satellite_6_14.rb +3 -2
- data/definitions/scenarios/upgrade_to_satellite_6_14_z.rb +3 -2
- data/extras/foreman_protector/dnf/foreman-protector.py +4 -4
- data/lib/foreman_maintain/concerns/pulp_common.rb +4 -0
- data/lib/foreman_maintain/config.rb +1 -1
- data/lib/foreman_maintain/package_manager/yum.rb +1 -1
- data/lib/foreman_maintain/package_manager.rb +7 -7
- data/lib/foreman_maintain/utils/service/systemd.rb +4 -0
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a074a4ff24a5bb600f21eea3957d5140984b7a107a9d9f660a6619bc5078a9b2
|
4
|
+
data.tar.gz: 34e3377c6e482e89b0e1263592bc93559fd68366b7b8c02144839746b614007e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4529548ad99bf3dd8b074840ec2b8c717f3a3ce88a715135d1e66219b932a63f6482a34eb7e3440b7329936371cce18268373c250540d61ba8046e63847e17b5
|
7
|
+
data.tar.gz: 16d307e273f41e8cd6f58812ec74f9c531ab857ce370b1455792232e6360544c231d665e23e11cf99d3e4263dd99ef7fdb0d63117aad87a9b8982deb0138d5d2
|
@@ -6,11 +6,13 @@ module Checks::Backup
|
|
6
6
|
manual_detection
|
7
7
|
param :backup_dir, 'Directory where to backup to', :required => true
|
8
8
|
param :preserve_dir, 'Directory where to backup to', :flag => true, :default => false
|
9
|
+
param :postgres_access, 'Whether the postgres user needs access', :flag => true,
|
10
|
+
:default => false
|
9
11
|
end
|
10
12
|
|
11
13
|
def run
|
12
14
|
assert(File.directory?(@backup_dir), "Backup directory (#{@backup_dir}) does not exist.")
|
13
|
-
if feature(:instance).postgresql_local?
|
15
|
+
if feature(:instance).postgresql_local? && @postgres_access
|
14
16
|
result = system("runuser - postgres -c 'test -w #{@backup_dir}'")
|
15
17
|
assert(result, "Postgres user needs write access to the backup directory \n" \
|
16
18
|
"Please allow the postgres user write access to #{@backup_dir}" \
|
@@ -10,11 +10,7 @@ module ForemanMaintain
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def services
|
13
|
-
|
14
|
-
[system_service('foreman', 30, :socket => 'foreman')]
|
15
|
-
else
|
16
|
-
[system_service('httpd', 30)]
|
17
|
-
end
|
13
|
+
[system_service('foreman', 30, :socket => 'foreman')]
|
18
14
|
end
|
19
15
|
|
20
16
|
def plugins
|
@@ -5,17 +5,13 @@ class Features::Pulpcore < ForemanMaintain::Feature
|
|
5
5
|
|
6
6
|
metadata do
|
7
7
|
label :pulpcore
|
8
|
-
|
9
|
-
confine do
|
10
|
-
ForemanMaintain::Utils::Service::Systemd.new('pulpcore-api', 0).enabled?
|
11
|
-
end
|
12
8
|
end
|
13
9
|
|
14
10
|
def services
|
15
11
|
redis_services = feature(:redis) ? feature(:redis).services : []
|
16
12
|
|
17
13
|
self.class.pulpcore_common_services + configured_workers +
|
18
|
-
redis_services
|
14
|
+
redis_services
|
19
15
|
end
|
20
16
|
|
21
17
|
def configured_workers
|
@@ -27,15 +23,6 @@ class Features::Pulpcore < ForemanMaintain::Feature
|
|
27
23
|
end
|
28
24
|
end
|
29
25
|
|
30
|
-
def self.pulpcore_migration_services
|
31
|
-
pulpcore_common_services + [
|
32
|
-
ForemanMaintain::Utils.system_service('pulpcore-worker@1', 20),
|
33
|
-
ForemanMaintain::Utils.system_service('pulpcore-worker@2', 20),
|
34
|
-
ForemanMaintain::Utils.system_service('pulpcore-worker@3', 20),
|
35
|
-
ForemanMaintain::Utils.system_service('pulpcore-worker@4', 20),
|
36
|
-
]
|
37
|
-
end
|
38
|
-
|
39
26
|
def config_files
|
40
27
|
[
|
41
28
|
'/etc/pulp/settings.py',
|
@@ -44,22 +31,9 @@ class Features::Pulpcore < ForemanMaintain::Feature
|
|
44
31
|
end
|
45
32
|
|
46
33
|
def self.pulpcore_common_services
|
47
|
-
|
34
|
+
[
|
48
35
|
ForemanMaintain::Utils.system_service('pulpcore-api', 10, :socket => 'pulpcore-api'),
|
49
36
|
ForemanMaintain::Utils.system_service('pulpcore-content', 10, :socket => 'pulpcore-content'),
|
50
37
|
]
|
51
|
-
common_services + pulpcore_resource_manager_service
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.pulpcore_resource_manager_service
|
55
|
-
# The pulpcore_resource_manager is only required on 3.14+
|
56
|
-
# if the old tasking system is being used
|
57
|
-
# The foreman-installer does not create unit file for this service,
|
58
|
-
# if the new tasking system is being used
|
59
|
-
if feature(:service).unit_file_available?('pulpcore-resource-manager.service')
|
60
|
-
return [ForemanMaintain::Utils.system_service('pulpcore-resource-manager', 10)]
|
61
|
-
end
|
62
|
-
|
63
|
-
[]
|
64
38
|
end
|
65
39
|
end
|
@@ -27,7 +27,11 @@ module Procedures::Packages
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def description
|
30
|
-
|
30
|
+
if @yum_options.include?('--downloadonly')
|
31
|
+
"Download package(s) #{@packages.join(', ')}"
|
32
|
+
else
|
33
|
+
"Update package(s) #{@packages.join(', ')}"
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Procedures::Pulpcore
|
2
2
|
class Migrate < ForemanMaintain::Procedure
|
3
3
|
include ForemanMaintain::Concerns::SystemService
|
4
|
+
include ForemanMaintain::Concerns::PulpCommon
|
4
5
|
|
5
6
|
metadata do
|
6
7
|
description 'Migrate pulpcore db'
|
@@ -16,9 +17,7 @@ module Procedures::Pulpcore
|
|
16
17
|
feature(:service).handle_services(spinner, 'stop', :only => pulp_services)
|
17
18
|
|
18
19
|
spinner.update('Migrating pulpcore database')
|
19
|
-
execute!('
|
20
|
-
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings '\
|
21
|
-
'pulpcore-manager migrate --noinput')
|
20
|
+
execute!(pulpcore_manager('migrate --noinput'))
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Procedures::Pulpcore
|
2
2
|
class TrimRpmChangelogs < ForemanMaintain::Procedure
|
3
3
|
include ForemanMaintain::Concerns::SystemService
|
4
|
+
include ForemanMaintain::Concerns::PulpCommon
|
4
5
|
|
5
6
|
metadata do
|
6
7
|
description 'Trim RPM changelogs in the pulpcore db'
|
@@ -14,9 +15,7 @@ module Procedures::Pulpcore
|
|
14
15
|
feature(:service).handle_services(spinner, 'start', :only => necessary_services)
|
15
16
|
|
16
17
|
spinner.update('Trimming RPM changelogs')
|
17
|
-
execute!('
|
18
|
-
'DJANGO_SETTINGS_MODULE=pulpcore.app.settings '\
|
19
|
-
'pulpcore-manager rpm-trim-changelogs')
|
18
|
+
execute!(pulpcore_manager('rpm-trim-changelogs'))
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
@@ -13,8 +13,7 @@ module Procedures::Service
|
|
13
13
|
PING_RETRY_INTERVAL = 30
|
14
14
|
|
15
15
|
def run
|
16
|
-
run_service_action('
|
17
|
-
run_service_action('start', common_options)
|
16
|
+
run_service_action('restart', common_options)
|
18
17
|
server_ping_retry if @wait_for_server_response
|
19
18
|
end
|
20
19
|
|
@@ -103,10 +103,9 @@ module ForemanMaintain::Scenarios
|
|
103
103
|
private
|
104
104
|
|
105
105
|
def prepare_directory
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
)
|
106
|
+
add_step_with_context(Procedures::Backup::PrepareDirectory)
|
107
|
+
add_step_with_context(Checks::Backup::DirectoryReady,
|
108
|
+
:postgres_access => online_backup? || include_db_dumps?)
|
110
109
|
end
|
111
110
|
|
112
111
|
def logical_volume_confirmation
|
@@ -40,7 +40,6 @@ module Scenarios::Capsule_6_14
|
|
40
40
|
|
41
41
|
def compose
|
42
42
|
add_steps(find_procedures(:pre_migrations))
|
43
|
-
add_step(Procedures::Service::Stop.new)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -58,7 +57,9 @@ module Scenarios::Capsule_6_14
|
|
58
57
|
add_step(Procedures::Repositories::Setup.new(:version => '6.14'))
|
59
58
|
modules_to_enable = ["satellite-capsule:#{el_short_name}"]
|
60
59
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
61
|
-
add_step(Procedures::Packages::
|
60
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
61
|
+
:yum_options => ['--downloadonly']))
|
62
|
+
add_step(Procedures::Service::Stop.new)
|
62
63
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
63
64
|
add_step_with_context(Procedures::Installer::Upgrade)
|
64
65
|
end
|
@@ -40,7 +40,6 @@ module Scenarios::Capsule_6_14_z
|
|
40
40
|
|
41
41
|
def compose
|
42
42
|
add_steps(find_procedures(:pre_migrations))
|
43
|
-
add_step(Procedures::Service::Stop.new)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -58,7 +57,9 @@ module Scenarios::Capsule_6_14_z
|
|
58
57
|
add_step(Procedures::Repositories::Setup.new(:version => '6.14'))
|
59
58
|
modules_to_enable = ["satellite-capsule:#{el_short_name}"]
|
60
59
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
61
|
-
add_step(Procedures::Packages::
|
60
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
61
|
+
:yum_options => ['--downloadonly']))
|
62
|
+
add_step(Procedures::Service::Stop.new)
|
62
63
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
63
64
|
add_step_with_context(Procedures::Installer::Upgrade)
|
64
65
|
end
|
@@ -54,6 +54,9 @@ module Scenarios::Katello_Nightly
|
|
54
54
|
add_step(Procedures::Repositories::Setup.new(:version => 'nightly'))
|
55
55
|
modules_to_enable = ["katello:#{el_short_name}", "pulpcore:#{el_short_name}"]
|
56
56
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
57
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
58
|
+
:yum_options => ['--downloadonly']))
|
59
|
+
add_step(Procedures::Service::Stop.new)
|
57
60
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
58
61
|
add_step_with_context(Procedures::Installer::Upgrade)
|
59
62
|
end
|
@@ -40,7 +40,6 @@ module Scenarios::Satellite_6_14
|
|
40
40
|
|
41
41
|
def compose
|
42
42
|
add_steps(find_procedures(:pre_migrations))
|
43
|
-
add_step(Procedures::Service::Stop.new)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -59,7 +58,9 @@ module Scenarios::Satellite_6_14
|
|
59
58
|
add_step(Procedures::Repositories::Setup.new(:version => '6.14'))
|
60
59
|
modules_to_enable = ["satellite:#{el_short_name}"]
|
61
60
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
62
|
-
add_step(Procedures::Packages::
|
61
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
62
|
+
:yum_options => ['--downloadonly']))
|
63
|
+
add_step(Procedures::Service::Stop.new)
|
63
64
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
64
65
|
add_step_with_context(Procedures::Installer::Upgrade)
|
65
66
|
add_step(Procedures::Installer::UpgradeRakeTask)
|
@@ -40,7 +40,6 @@ module Scenarios::Satellite_6_14_z
|
|
40
40
|
|
41
41
|
def compose
|
42
42
|
add_steps(find_procedures(:pre_migrations))
|
43
|
-
add_step(Procedures::Service::Stop.new)
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -58,7 +57,9 @@ module Scenarios::Satellite_6_14_z
|
|
58
57
|
add_step(Procedures::Repositories::Setup.new(:version => '6.14'))
|
59
58
|
modules_to_enable = ["satellite:#{el_short_name}"]
|
60
59
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
61
|
-
add_step(Procedures::Packages::
|
60
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
61
|
+
:yum_options => ['--downloadonly']))
|
62
|
+
add_step(Procedures::Service::Stop.new)
|
62
63
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
63
64
|
add_step_with_context(Procedures::Installer::Upgrade)
|
64
65
|
add_step(Procedures::Installer::UpgradeRakeTask)
|
@@ -4,14 +4,12 @@ from dnfpluginscore import _, logger
|
|
4
4
|
|
5
5
|
import configparser
|
6
6
|
|
7
|
+
PROTECT_COMMANDS = ('install', 'downgrade', 'reinstall', 'distro-sync', 'swap', 'upgrade', 'upgrade-minimal')
|
8
|
+
|
7
9
|
class ForemanProtector(dnf.Plugin):
|
8
10
|
name = 'foreman-protector'
|
9
11
|
config_name = 'foreman-protector'
|
10
12
|
|
11
|
-
def __init__(self,base,cli):
|
12
|
-
self.base = base
|
13
|
-
self.cli = cli
|
14
|
-
|
15
13
|
def _get_whitelist_file_url(self):
|
16
14
|
try:
|
17
15
|
parser = self.read_config(self.base.conf)
|
@@ -53,6 +51,8 @@ class ForemanProtector(dnf.Plugin):
|
|
53
51
|
return final_query
|
54
52
|
|
55
53
|
def sack(self):
|
54
|
+
if self.cli is not None and self.cli.command._basecmd not in PROTECT_COMMANDS:
|
55
|
+
return
|
56
56
|
whitelist_and_obsoletes = self._add_obsoletes()
|
57
57
|
all_available_packages = self.base.sack.query().available()
|
58
58
|
excluded_pkgs_query = all_available_packages.difference(whitelist_and_obsoletes)
|
@@ -10,6 +10,10 @@ module ForemanMaintain
|
|
10
10
|
# All below directories and their contents are regenerated on installer run
|
11
11
|
%w[assets exports imports sync_imports tmp]
|
12
12
|
end
|
13
|
+
|
14
|
+
def pulpcore_manager(command)
|
15
|
+
"PULP_SETTINGS=/etc/pulp/settings.py runuser -u pulp -- pulpcore-manager #{command}"
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -28,7 +28,7 @@ module ForemanMaintain
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def load_log_configs
|
31
|
-
@log_level = @options.fetch(:log_level, ::Logger::
|
31
|
+
@log_level = @options.fetch(:log_level, ::Logger::INFO)
|
32
32
|
@log_dir = find_dir_path(@options.fetch(:log_dir, 'log'))
|
33
33
|
@log_file_size = @options.fetch(:log_file_size, 10_000)
|
34
34
|
# Note - If timestamp added to filename then number of log files i.e second
|
@@ -68,7 +68,7 @@ module ForemanMaintain::PackageManager
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def check_update(packages: nil, with_status: false)
|
71
|
-
yum_action('check-update', packages, :assumeyes => true, :valid_exit_statuses => [100],
|
71
|
+
yum_action('check-update', packages, :assumeyes => true, :valid_exit_statuses => [0, 100],
|
72
72
|
:with_status => with_status)
|
73
73
|
end
|
74
74
|
|
@@ -5,12 +5,12 @@ require 'foreman_maintain/package_manager/apt'
|
|
5
5
|
|
6
6
|
module ForemanMaintain
|
7
7
|
def self.package_manager
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
if el?
|
9
|
+
ForemanMaintain::PackageManager::Dnf.new
|
10
|
+
elsif debian_or_ubuntu?
|
11
|
+
ForemanMaintain::PackageManager::Apt.new
|
12
|
+
else
|
13
|
+
raise 'No supported package manager was found'
|
14
|
+
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/foreman_maintain.rb
CHANGED
@@ -143,7 +143,7 @@ module ForemanMaintain
|
|
143
143
|
# convert size in KB to Bytes
|
144
144
|
log_fsize = config.log_file_size.to_i * 1024
|
145
145
|
@logger = Logger.new(config.log_filename, 10, log_fsize).tap do |logger|
|
146
|
-
logger.level = LOGGER_LEVEL_MAPPING[config.log_level] || Logger::
|
146
|
+
logger.level = LOGGER_LEVEL_MAPPING[config.log_level] || Logger::INFO
|
147
147
|
logger.datetime_format = '%Y-%m-%d %H:%M:%S%z '
|
148
148
|
end
|
149
149
|
pickup_log_messages
|
@@ -180,10 +180,11 @@ module ForemanMaintain
|
|
180
180
|
puts "Checking for new version of #{package_name}..."
|
181
181
|
|
182
182
|
enable_maintenance_module
|
183
|
+
package_manager = ForemanMaintain.package_manager
|
183
184
|
|
184
|
-
if
|
185
|
+
if package_manager.update_available?(main_package_name)
|
185
186
|
puts "\nUpdating #{package_name} package."
|
186
|
-
|
187
|
+
package_manager.update(main_package_name, :assumeyes => true)
|
187
188
|
puts "\nThe #{package_name} package successfully updated."\
|
188
189
|
"\nRe-run #{command} with required options!"
|
189
190
|
exit 75
|
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.3.
|
4
|
+
version: 1.3.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: 2023-
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|