foreman_maintain 0.6.8 → 0.6.9
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/README.md +46 -10
- data/bin/foreman-maintain-complete +3 -2
- data/definitions/checks/env_proxy.rb +1 -1
- data/definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb +7 -9
- data/definitions/features/foreman_proxy.rb +7 -5
- data/definitions/procedures/backup/prepare_directory.rb +8 -1
- data/definitions/procedures/content/prepare.rb +5 -0
- data/definitions/procedures/content/switchover.rb +5 -0
- data/definitions/procedures/packages/locking_status.rb +1 -1
- data/definitions/scenarios/content.rb +8 -2
- data/extras/foreman_protector/foreman-protector.py +1 -1
- data/lib/foreman_maintain.rb +7 -1
- data/lib/foreman_maintain/concerns/base_database.rb +1 -1
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7050dd905c1396f95686caabf7afaea60f963b8c68c2b0849eb4d06b7e5330f7
|
4
|
+
data.tar.gz: d683a46f74563cb3c22a4f0ab94ebf3354aa4685afd8b22a7ea68ec1fc6d70a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56ffb28e036596b3b7262ff27e5f7ab85ccd98ba3f261ef5049f0e4c404b743b96fe3086723a7a0d08005e27308b40888e209ca66125662d4dd72da8706a540c
|
7
|
+
data.tar.gz: f056a9c36223352dededfd338e462070f71780b679e2d661360733a85ef07045ac1fd7f803421f945d9f1cc0176d7351d8f0f951da558635b33a5dcc7e99a67c
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Foreman Maintenance [](https://travis-ci.org/theforeman/foreman_maintain) <a href="https://codeclimate.com/github/theforeman/foreman_maintain"><img src="https://codeclimate.com/github/theforeman/foreman_maintain/badges/gpa.svg" /></a>
|
2
2
|
|
3
|
-
`foreman_maintain` aims to provide various features that helps keep the
|
3
|
+
The `foreman_maintain` aims to provide various features that helps keep the
|
4
4
|
Foreman/Satellite up and running. It supports multiple versions and subparts
|
5
5
|
of the Foreman infrastructure, including server or smart proxy and is smart
|
6
6
|
enough to provide the right tools for the specific version.
|
@@ -19,8 +19,10 @@ Subcommands:
|
|
19
19
|
upgrade Upgrade related commands
|
20
20
|
list-versions List versions this system is upgradable to
|
21
21
|
check --target-version TARGET_VERSION Run pre-upgrade checks for upgrading to specified version
|
22
|
+
--disable-self-upgrade Disable automatic self upgrade (default: false)
|
22
23
|
run --target-version TARGET_VERSION Run the full upgrade
|
23
24
|
[--phase=phase TARGET_VERSION] Run just a specific phase of the upgrade
|
25
|
+
--disable-self-upgrade Disable automatic self upgrade (default: false)
|
24
26
|
|
25
27
|
advanced Advanced tools for server maintenance
|
26
28
|
procedure Run maintain procedures manually
|
@@ -59,8 +61,8 @@ Subcommands:
|
|
59
61
|
Foreman-maintain implements upgrade tooling that helps the administrator to go
|
60
62
|
through the upgrade process.
|
61
63
|
|
62
|
-
Foreman-maintain scans the system to know, what
|
63
|
-
|
64
|
+
Foreman-maintain scans the system to know, what versions are available
|
65
|
+
for upgrade on the particular system. To see what versions are available
|
64
66
|
for upgrade, run:
|
65
67
|
|
66
68
|
```
|
@@ -88,13 +90,13 @@ of the system:
|
|
88
90
|
|
89
91
|
* **pre-migrations** - these steps perform changes on the system before
|
90
92
|
the actual upgrade starts. An example is disabling access to the system from
|
91
|
-
external sources, a.k.a. maintenance mode or disabling sync plans during the run.
|
93
|
+
external sources, a.k.a. maintenance mode or disabling Katello sync plans during the run.
|
92
94
|
|
93
95
|
After this phase ends, the system is still running the old version, and it's possible
|
94
96
|
to revert the changes by running the post-migrations steps.
|
95
97
|
|
96
98
|
* **migrations** - this phase performs the actual migrations, starting with
|
97
|
-
configuring new repositories,
|
99
|
+
configuring new repositories, updating the packages and running the installer.
|
98
100
|
|
99
101
|
At the end of this phase, the system should be fully migrated to the new version.
|
100
102
|
However, the system is not fully operational yet, as the post-migrations steps
|
@@ -103,7 +105,7 @@ of the system:
|
|
103
105
|
* **post-migrations** - these steps revert the changes made in pre-migrations phase,
|
104
106
|
turning the system into fully-operational again.
|
105
107
|
|
106
|
-
* **post-upgrade checks** -
|
108
|
+
* **post-upgrade checks** - these steps should perform sanity check of the system
|
107
109
|
to ensure the system is valid and ready to be used again.
|
108
110
|
|
109
111
|
|
@@ -114,6 +116,40 @@ the *pre-upgrade check* phase. In case the upgrade failed before **migrations**
|
|
114
116
|
phase made some modifying changes, the tool tries to rollback to the previous
|
115
117
|
state of the system.
|
116
118
|
|
119
|
+
#### Self-upgrade for rubygem-foreman_maintain package
|
120
|
+
|
121
|
+
**Note:** This feature is available from `rubygem-foreman_maintain` version 0.6.4 and newer.
|
122
|
+
|
123
|
+
When a user runs any `foreman-maintain upgrade` sub commands (e.g. `foreman-maintain upgrade check` or `foreman-maintain upgrade run`) then,
|
124
|
+
|
125
|
+
* If update available for `rubygem-foreman_maintain` package, the sub command tries to update this package. After successful package update, it returns the exit code 75 and requests user to re-run with the updated source code.
|
126
|
+
|
127
|
+
Here, exit code (value 75) is to indicate that it can not continue with further execution & needs re-run. e.g.,
|
128
|
+
|
129
|
+
~~~
|
130
|
+
# foreman-maintain upgrade check --target-version TARGET_VERSION
|
131
|
+
Checking for new version of foreman-maintain...
|
132
|
+
rubygem-foreman_maintain.noarch repository
|
133
|
+
|
134
|
+
Updating foreman-maintain package.
|
135
|
+
|
136
|
+
The foreman-maintain package successfully updated.
|
137
|
+
|
138
|
+
Re-run foreman-maintain with required options!
|
139
|
+
|
140
|
+
# echo $?
|
141
|
+
75
|
142
|
+
~~~
|
143
|
+
|
144
|
+
* If update is not available for `rubygem-foreman_maintain` package, then sub command simply executes the further steps without halt.
|
145
|
+
|
146
|
+
* If user wants to skip self-update mechanism then `--disable-self-upgrade` flag can be used with upgrade sub commands. e.g.,
|
147
|
+
|
148
|
+
~~~
|
149
|
+
# foreman-maintain upgrade check --target-version TARGET_VERSION --disable-self-upgrade
|
150
|
+
# foreman-maintain upgrade run --target-version TARGET_VERSION --disable-self-upgrade
|
151
|
+
~~~
|
152
|
+
|
117
153
|
#### Satellite notes
|
118
154
|
|
119
155
|
To use custom organization/activation key for configuring repositories during
|
@@ -132,7 +168,7 @@ export FOREMAN_MAINTAIN_USE_BETA='1'
|
|
132
168
|
|
133
169
|
## Implementation
|
134
170
|
|
135
|
-
`foreman_maintain` maps the CLI commands into definitions. This allows to keep the set
|
171
|
+
The `foreman_maintain` maps the CLI commands into definitions. This allows to keep the set
|
136
172
|
of the commands the user needs to know immutable from version-specific changes. The mapping
|
137
173
|
between the CLI commands and definitions is made by defining various metadata.
|
138
174
|
|
@@ -329,8 +365,8 @@ end
|
|
329
365
|
```
|
330
366
|
|
331
367
|
Before executing the command the feature checks if it has valid hammer configuration to run the command.
|
332
|
-
Foreman maintain always use the 'admin' account to run the commands. The password is taken
|
333
|
-
the
|
368
|
+
Foreman maintain always use the 'admin' account to run the commands. The password is taken from
|
369
|
+
the hammer config or installer answer files or asked from the user interactively (in this order).
|
334
370
|
The valid credentials are stored and reused next time if still valid.
|
335
371
|
|
336
372
|
Usually we want to do the user interaction at the beginning of our scenario.
|
@@ -449,7 +485,7 @@ Possible options for the `:completion` attribute are:
|
|
449
485
|
* `maintenance-mode is-enabled` returns `0 or 1` output depending upon the maintenance-mode status.
|
450
486
|
Here, 0=ON & 1=OFF.
|
451
487
|
|
452
|
-
If
|
488
|
+
If users would like to check whether maintenance-mode is ON/OFF on system in their external script then
|
453
489
|
they can use subcommand `foreman-maintain maintenance-mode is-enabled`.
|
454
490
|
|
455
491
|
## How to contribute?
|
@@ -13,7 +13,8 @@ require 'foreman_maintain/utils/bash'
|
|
13
13
|
# rubocop:disable Lint/RescueWithoutErrorClass, Lint/HandleExceptions
|
14
14
|
def cache_file(config_file)
|
15
15
|
config = YAML.load(File.open(config_file))
|
16
|
-
config
|
16
|
+
config.fetch(:completion_cache_file,
|
17
|
+
"#{ENV['HOME'] || '/root'}/.cache/foreman_maintain_completion.yml")
|
17
18
|
rescue
|
18
19
|
end
|
19
20
|
# rubocop:enable Lint/RescueWithoutErrorClass, Lint/HandleExceptions
|
@@ -23,7 +24,7 @@ config_file = if File.exist?(CONFIG_FILE)
|
|
23
24
|
else
|
24
25
|
File.join(project_root, 'config/foreman_maintain.yml')
|
25
26
|
end
|
26
|
-
completion_cache_file = cache_file(config_file)
|
27
|
+
completion_cache_file = cache_file(config_file)
|
27
28
|
completion_cache_file = File.expand_path(completion_cache_file)
|
28
29
|
|
29
30
|
# build the cache if it does not exist
|
@@ -8,6 +8,6 @@ class Checks::EnvProxy < ForemanMaintain::Check
|
|
8
8
|
def run
|
9
9
|
variables = %w[http_proxy https_proxy HTTP_PROXY HTTPS_PROXY]
|
10
10
|
has_proxy_set = true if variables.map { |variable| ENV[variable] }.compact.any?
|
11
|
-
assert(has_proxy_set, 'Global HTTP(S) proxy in environment (env) is set. Please unset first!')
|
11
|
+
assert(!has_proxy_set, 'Global HTTP(S) proxy in environment (env) is set. Please unset first!')
|
12
12
|
end
|
13
13
|
end
|
@@ -4,20 +4,18 @@ module Checks::ForemanProxy
|
|
4
4
|
description 'Check for verifying syntax for ISP DHCP configurations'
|
5
5
|
tags :default
|
6
6
|
confine do
|
7
|
-
feature(:foreman_proxy)
|
7
|
+
feature(:foreman_proxy) &&
|
8
|
+
feature(:foreman_proxy).features.include?('dhcp') &&
|
9
|
+
feature(:foreman_proxy).dhcp_isc_provider?
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
11
13
|
def run
|
12
|
-
if feature(:foreman_proxy).
|
13
|
-
|
14
|
-
|
15
|
-
assert(success, 'Please check and verify DHCP configurations.')
|
16
|
-
else
|
17
|
-
fail! "Couldn't find configuration file at #{feature(:foreman_proxy).dhcpd_config_file}"
|
18
|
-
end
|
14
|
+
if feature(:foreman_proxy).dhcpd_conf_exist?
|
15
|
+
success = feature(:foreman_proxy).valid_dhcp_configs?
|
16
|
+
assert(success, 'Please check and verify DHCP configurations.')
|
19
17
|
else
|
20
|
-
|
18
|
+
fail! "Couldn't find configuration file at #{feature(:foreman_proxy).dhcpd_config_file}"
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -101,7 +101,9 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def certs_tar
|
104
|
-
|
104
|
+
if content_module
|
105
|
+
feature(:installer).answers.fetch(content_module, {})[certs_param_name[:param_key]]
|
106
|
+
end
|
105
107
|
end
|
106
108
|
|
107
109
|
def settings_file
|
@@ -120,6 +122,10 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
120
122
|
@tftp_root_directory ||= lookup_tftp_root_directory
|
121
123
|
end
|
122
124
|
|
125
|
+
def dhcp_isc_provider?
|
126
|
+
configs_from_dhcp_yml[:use_provider] == 'dhcp_isc'
|
127
|
+
end
|
128
|
+
|
123
129
|
private
|
124
130
|
|
125
131
|
def backup_features(for_features)
|
@@ -227,10 +233,6 @@ class Features::ForemanProxy < ForemanMaintain::Feature
|
|
227
233
|
@configs_from_dhcp_yml ||= yaml_load(dhcp_yml_path)
|
228
234
|
end
|
229
235
|
|
230
|
-
def dhcp_isc_provider?
|
231
|
-
configs_from_dhcp_yml[:use_provider] == 'dhcp_isc'
|
232
|
-
end
|
233
|
-
|
234
236
|
def lookup_using_dhcp_yml
|
235
237
|
if configs_from_dhcp_yml.key?(:dhcp_config)
|
236
238
|
return configs_from_dhcp_yml[:dhcp_config]
|
@@ -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
|
@@ -3,6 +3,11 @@ module Procedures::Content
|
|
3
3
|
metadata do
|
4
4
|
description 'Switch support for certain content from Pulp 2 to Pulp 3'
|
5
5
|
for_feature :pulpcore
|
6
|
+
|
7
|
+
confine do
|
8
|
+
# FIXME: remove this condition on next downstream upgrade scenario
|
9
|
+
!feature(:instance).downstream
|
10
|
+
end
|
6
11
|
end
|
7
12
|
|
8
13
|
def run
|
@@ -18,7 +18,7 @@ module Procedures::Packages
|
|
18
18
|
else
|
19
19
|
puts ' Packages are not locked.'
|
20
20
|
puts " WARNING: When locking is disabled there is a risk of unwanted update\n" \
|
21
|
-
" of #{feature(:instance).product_name}
|
21
|
+
" of #{feature(:instance).product_name} and its components and possible " \
|
22
22
|
'data inconsistency'
|
23
23
|
end
|
24
24
|
end
|
@@ -8,7 +8,10 @@ module ForemanMaintain::Scenarios
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def compose
|
11
|
-
|
11
|
+
# FIXME: remove this condition on next downstream upgrade scenario
|
12
|
+
if Procedures::Content::Prepare.present?
|
13
|
+
add_step(Procedures::Content::Prepare)
|
14
|
+
end
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
@@ -20,7 +23,10 @@ module ForemanMaintain::Scenarios
|
|
20
23
|
end
|
21
24
|
|
22
25
|
def compose
|
23
|
-
|
26
|
+
# FIXME: remove this condition on next downstream upgrade scenario
|
27
|
+
if Procedures::Content::Switchover.present?
|
28
|
+
add_step(Procedures::Content::Switchover)
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
@@ -26,7 +26,7 @@ def _load_whitelist():
|
|
26
26
|
continue
|
27
27
|
_package_whitelist.add(line.rstrip().lower())
|
28
28
|
llfile.close()
|
29
|
-
except urlgrabber.grabber.URLGrabError
|
29
|
+
except urlgrabber.grabber.URLGrabError as e:
|
30
30
|
raise PluginYumExit('Unable to read Foreman protector"s configuration: %s' % e)
|
31
31
|
|
32
32
|
def _add_obsoletes(conduit):
|
data/lib/foreman_maintain.rb
CHANGED
@@ -53,6 +53,8 @@ module ForemanMaintain
|
|
53
53
|
}.freeze
|
54
54
|
|
55
55
|
def setup(options = {})
|
56
|
+
set_home_environment
|
57
|
+
|
56
58
|
# using a queue, we can log the messages which are generated before initializing logger
|
57
59
|
self.config = Config.new(options)
|
58
60
|
load_definitions
|
@@ -60,6 +62,10 @@ module ForemanMaintain
|
|
60
62
|
update_path
|
61
63
|
end
|
62
64
|
|
65
|
+
def set_home_environment
|
66
|
+
ENV['HOME'] ||= '/root'
|
67
|
+
end
|
68
|
+
|
63
69
|
# Appending PATH with expected paths needed for commands we run
|
64
70
|
def update_path
|
65
71
|
paths = ['/sbin']
|
@@ -162,7 +168,7 @@ module ForemanMaintain
|
|
162
168
|
ForemanMaintain.package_manager.update(main_package_name, :assumeyes => true)
|
163
169
|
puts "\nThe #{package_name} package successfully updated."\
|
164
170
|
"\nRe-run #{command} with required options!"
|
165
|
-
exit
|
171
|
+
exit 75
|
166
172
|
end
|
167
173
|
puts "Nothing to update, can't find new version of #{package_name}."
|
168
174
|
end
|
@@ -82,7 +82,7 @@ module ForemanMaintain
|
|
82
82
|
tar_options = {
|
83
83
|
:archive => backup_file,
|
84
84
|
:command => 'create',
|
85
|
-
:transform =>
|
85
|
+
:transform => "s,^,#{data_dir[1..-1]},S",
|
86
86
|
:files => '*'
|
87
87
|
}.merge(extra_tar_options)
|
88
88
|
feature(:tar).run(tar_options)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -401,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
401
401
|
- !ruby/object:Gem::Version
|
402
402
|
version: '0'
|
403
403
|
requirements: []
|
404
|
-
rubygems_version: 3.0.
|
404
|
+
rubygems_version: 3.0.3
|
405
405
|
signing_key:
|
406
406
|
specification_version: 4
|
407
407
|
summary: Foreman maintenance tool belt
|