foreman_maintain 1.0.12 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40bec791581fb8e2670586e331afd5e89ba1ca436b38d95e848837fc8ce1fdd3
4
- data.tar.gz: 54f35bb8139e221173ca57786c93e36559957116577907fa936d0ff3f4256858
3
+ metadata.gz: 38a7ae9f24c88731e052acb62c13b25d29074a07ad852daa258bed6322c1d22d
4
+ data.tar.gz: e0420aa7dc1935c61ef479aed3a43069281797ca41f131048902c727676c6634
5
5
  SHA512:
6
- metadata.gz: 2e00f5941e44f62e5fa09d47924fa231af050cf32ae555a775bdb247753c0b38d1a2b3c554e86d3699287f1a4367a461f780be6fca5c897031feffbf07de9f53
7
- data.tar.gz: 80447d1b43a06edcdd7d9846637c4f484f8bd454e9bdda303355223f64671fa276e37e1c0c8bf50aff1c6213ed30d23028c850b31e1e9f3463b1660994109902
6
+ metadata.gz: e0b38e2d2819e152a508874b060b22f161aa4b56523d9b6869b714f9186920fa7d61fd10b09840158c94e4b55a7c18a718307e9a02f4320426f54baa9bdfdd9f
7
+ data.tar.gz: d53fb1934cdc2cbbc2cad92e43a4132ff0f8ea8eec1435bd930be575d3e2284a48278809b7576bdf24b8d7df36ac39fe2dcb223813dc9f8c3b57632e08e030e5
@@ -12,7 +12,7 @@ class Features::Capsule < ForemanMaintain::Feature
12
12
  end
13
13
 
14
14
  def current_version
15
- @current_version ||= rpm_version(package_name)
15
+ @current_version ||= package_version(package_name)
16
16
  end
17
17
 
18
18
  def package_name
@@ -64,9 +64,7 @@ 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',
68
- '/opt/puppetlabs/puppet/cache/foreman_cache_data',
69
- '/opt/puppetlabs/puppet/cache/pulpcore_cache_data'
67
+ '/usr/local/bin/validate_postgresql_connection.sh'
70
68
  ]
71
69
  end
72
70
 
@@ -102,7 +100,13 @@ class Features::Installer < ForemanMaintain::Feature
102
100
  end
103
101
 
104
102
  def installer_arguments
105
- installer_args = ' --disable-system-checks'
103
+ installer_args = ''
104
+
105
+ if feature(:foreman_proxy) &&
106
+ feature(:foreman_proxy).with_content?
107
+ installer_args += ' --disable-system-checks'
108
+ end
109
+
106
110
  unless check_min_version('foreman', '2.1') || check_min_version('foreman-proxy', '2.1')
107
111
  installer_args += ' --upgrade' if can_upgrade?
108
112
  end
@@ -12,7 +12,7 @@ class Features::Katello < ForemanMaintain::Feature
12
12
  end
13
13
 
14
14
  def current_version
15
- @current_version ||= rpm_version('katello')
15
+ @current_version ||= package_version('katello')
16
16
  end
17
17
 
18
18
  def services
@@ -25,14 +25,12 @@ class Features::Nftables < ForemanMaintain::Feature
25
25
  execute!("nft add chain #{family} #{table} #{chain} #{chain_options}")
26
26
  end
27
27
 
28
- def add_rules(options = {})
28
+ def add_rule(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
- rules = options.fetch(:rules) # needs validation
33
- rules.each do |rule|
34
- execute!("nft add rule #{family} #{table} #{chain} #{rule}")
35
- end
32
+ rule = options.fetch(:rule) # needs validation
33
+ execute!("nft add rule #{family} #{table} #{chain} #{rule}")
36
34
  end
37
35
 
38
36
  def table_exist?(name = table_name)
@@ -11,6 +11,8 @@ 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',
14
16
  '/opt/puppetlabs/puppet/ssl/',
15
17
  '/var/lib/puppet/ssl',
16
18
  '/var/lib/puppet',
@@ -10,7 +10,7 @@ class Features::Satellite < ForemanMaintain::Feature
10
10
  end
11
11
 
12
12
  def current_version
13
- @current_version ||= rpm_version(package_name) || version_from_source
13
+ @current_version ||= package_version(package_name) || version_from_source
14
14
  end
15
15
 
16
16
  def package_name
@@ -4,7 +4,6 @@ module Procedures::Content
4
4
  description 'Prepare content for Pulp 3'
5
5
  for_feature :pulpcore
6
6
  param :quiet, 'Keep the output on a single line', :flag => true, :default => false
7
- do_not_whitelist
8
7
  end
9
8
 
10
9
  def run
@@ -9,7 +9,6 @@ module Procedures::Content
9
9
  end
10
10
 
11
11
  param :skip_deb, 'Do not run debian options in installer.'
12
- do_not_whitelist
13
12
  end
14
13
 
15
14
  def run
@@ -6,7 +6,7 @@ module Procedures::Foreman
6
6
  end
7
7
 
8
8
  def run
9
- execute!('FOREMAN_APIPIE_LANGS=en foreman-rake apipie:cache')
9
+ execute!('foreman-rake apipie:cache')
10
10
  end
11
11
  end
12
12
  end
@@ -24,7 +24,15 @@ module Procedures::Pulp
24
24
  '/var/lib/pulp/uploads',
25
25
  '/var/lib/mongodb/',
26
26
  '/var/cache/pulp'
27
- ]
27
+ ].select { |dir| File.directory?(dir) }
28
+ end
29
+
30
+ def pulp_data_dirs_mountpoints
31
+ pulp_data_dirs.select { |d| Pathname(d).mountpoint? }
32
+ end
33
+
34
+ def deletable_pulp_dirs
35
+ @deletable_pulp_dirs ||= pulp_data_dirs - pulp_data_dirs_mountpoints
28
36
  end
29
37
 
30
38
  # rubocop:disable Metrics/MethodLength
@@ -53,11 +61,12 @@ module Procedures::Pulp
53
61
  @installed_pulp_packages
54
62
  end
55
63
 
56
- def data_dir_removal_cmds
57
- pulp_data_dirs.select { |dir| File.directory?(dir) }.map { |dir| "rm -rf #{dir}" }
64
+ def data_dir_removal_cmds(pulp_dirs)
65
+ pulp_dirs.map { |dir| "rm -rf #{dir}" }
58
66
  end
59
67
 
60
- def ask_to_proceed(rm_cmds)
68
+ def ask_to_proceed
69
+ rm_cmds = data_dir_removal_cmds(pulp_data_dirs)
61
70
  question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
62
71
  question += "\n# rpm -e #{pulp_packages.join(' ')}" if pulp_packages.any?
63
72
  question += "\n# yum remove rh-mongodb34-*"
@@ -70,11 +79,9 @@ module Procedures::Pulp
70
79
  end
71
80
 
72
81
  def run
73
- rm_cmds = data_dir_removal_cmds
74
-
75
82
  assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
76
83
 
77
- ask_to_proceed(rm_cmds) unless assumeyes_val
84
+ ask_to_proceed unless assumeyes_val
78
85
 
79
86
  remove_pulp if pulp_packages.any?
80
87
 
@@ -86,7 +93,7 @@ module Procedures::Pulp
86
93
 
87
94
  drop_migrations
88
95
 
89
- delete_pulp_data(rm_cmds) if rm_cmds.any?
96
+ delete_pulp_data
90
97
 
91
98
  restart_pulpcore_services
92
99
  end
@@ -163,12 +170,41 @@ module Procedures::Pulp
163
170
  end
164
171
  # rubocop:enable Metrics/BlockLength
165
172
 
166
- def delete_pulp_data(rm_cmds)
167
- with_spinner('Deleting pulp2 data directories') do |spinner|
168
- rm_cmds.each do |cmd|
169
- execute!(cmd)
173
+ def delete_pulp_data
174
+ non_mountpoints = data_dir_removal_cmds(deletable_pulp_dirs)
175
+ mountpoints = pulp_data_dirs_mountpoints
176
+ with_spinner('') do |spinner|
177
+ if non_mountpoints.any?
178
+ spinner.update('Deleting pulp2 data directories.')
179
+ non_mountpoints.each do |cmd|
180
+ execute!(cmd)
181
+ end
182
+ msg_for_del_non_mountpoints(mountpoints, spinner)
183
+ end
184
+ if mountpoints.any?
185
+ msg_for_del_mountpoints(mountpoints, spinner)
170
186
  end
171
- spinner.update('Done deleting pulp2 data directories')
187
+ end
188
+ end
189
+
190
+ def msg_for_del_non_mountpoints(mountpoints, spinner)
191
+ if mountpoints.empty?
192
+ spinner.update('Done deleting all pulp2 data directories.')
193
+ else
194
+ spinner.update("Deleted: #{deletable_pulp_dirs.join("\n")}")
195
+ end
196
+ end
197
+
198
+ def msg_for_del_mountpoints(mountpoints, spinner)
199
+ _, cmd_name = ForemanMaintain.pkg_and_cmd_name
200
+ if mountpoints.count > 1
201
+ spinner.update("The directories #{mountpoints.join(',')} are individual mountpoints.")
202
+ puts "\nThe #{cmd_name} won't delete these directories.\n"\
203
+ 'You need to remove content and these directories on your own.'
204
+ else
205
+ spinner.update("The directory #{mountpoints.join(',')} is individual mountpoint.")
206
+ puts "\nThe #{cmd_name} won't delete the directory.\n"\
207
+ 'You need to remove content and the directory on your own.'
172
208
  end
173
209
  end
174
210
 
@@ -15,9 +15,6 @@ 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
21
18
  end
22
19
  end
23
20
  end
@@ -1,6 +1,5 @@
1
1
  module ForemanMaintain::Scenarios
2
2
  class SelfUpgradeBase < ForemanMaintain::Scenario
3
- include ForemanMaintain::Concerns::Downstream
4
3
  def enabled_system_repos_id
5
4
  repository_manager.enabled_repos.keys
6
5
  end
@@ -68,10 +67,7 @@ module ForemanMaintain::Scenarios
68
67
 
69
68
  def repos_ids_to_reenable
70
69
  repos_ids_to_reenable = stored_enabled_repos_ids - all_maintenance_repos
71
- if use_rhsm?
72
- repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
73
- end
74
- repos_ids_to_reenable
70
+ repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
75
71
  end
76
72
 
77
73
  def use_rhsm?
@@ -83,10 +79,6 @@ module ForemanMaintain::Scenarios
83
79
 
84
80
  true
85
81
  end
86
-
87
- def req_repos_to_update_pkgs
88
- main_rh_repos + [maintenance_repo_id(target_version)]
89
- end
90
82
  end
91
83
 
92
84
  class SelfUpgrade < SelfUpgradeBase
@@ -102,10 +94,9 @@ module ForemanMaintain::Scenarios
102
94
  pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
103
95
  add_step(Procedures::Repositories::BackupEnabledRepos.new)
104
96
  disable_repos
105
- add_step(Procedures::Repositories::Enable.new(repos: req_repos_to_update_pkgs,
97
+ add_step(Procedures::Repositories::Enable.new(repos: [maintenance_repo_id(target_version)],
106
98
  use_rhsm: use_rhsm?))
107
99
  add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true))
108
- disable_repos('*')
109
100
  enable_repos(repos_ids_to_reenable)
110
101
  end
111
102
  end
@@ -122,7 +113,6 @@ module ForemanMaintain::Scenarios
122
113
 
123
114
  def compose
124
115
  if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
125
- disable_repos('*')
126
116
  enable_repos(repos_ids_to_reenable)
127
117
  end
128
118
  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::RunFor6_11)
64
+ add_step_with_context(Procedures::Installer::Upgrade)
65
65
  add_step(Procedures::Installer::UpgradeRakeTask)
66
66
  end
67
67
  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
- add_rules(rules: nftables_rules)
13
+ add_rule(rule: nftables_rule)
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 nftables_rules
26
- ['iifname "lo" accept', 'tcp dport 443 reject']
25
+ def nftables_rule
26
+ 'tcp dport https reject'
27
27
  end
28
28
 
29
29
  def status_for_maintenance_mode
@@ -100,10 +100,6 @@ 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
-
107
103
  def self.eval_dsl(metadata, &block)
108
104
  new(metadata).tap do |dsl|
109
105
  dsl.instance_eval(&block)
@@ -115,7 +115,8 @@ module ForemanMaintain
115
115
 
116
116
  def package_version(name)
117
117
  # space for extension to support non-rpm distributions
118
- rpm_version(name)
118
+ pkg = package_manager.find_installed_package(name, '%{VERSION}')
119
+ version(pkg) unless pkg.nil?
119
120
  end
120
121
 
121
122
  def parse_csv(data)
@@ -132,13 +133,6 @@ module ForemanMaintain
132
133
  nil
133
134
  end
134
135
 
135
- def rpm_version(name)
136
- rpm_version = execute(%(rpm -q '#{name}' --queryformat="%{VERSION}"))
137
- if $CHILD_STATUS.success?
138
- version(rpm_version)
139
- end
140
- end
141
-
142
136
  def shellescape(string)
143
137
  Shellwords.escape(string)
144
138
  end
@@ -36,8 +36,12 @@ module ForemanMaintain::PackageManager
36
36
  sys.execute?(%(rpm -q #{packages_list}))
37
37
  end
38
38
 
39
- def find_installed_package(name)
40
- status, result = sys.execute_with_status(%(rpm -q '#{name}'))
39
+ def find_installed_package(name, queryformat = '')
40
+ rpm_cmd = "rpm -q '#{name}'"
41
+ unless queryformat.empty?
42
+ rpm_cmd += " --qf '#{queryformat}'"
43
+ end
44
+ status, result = sys.execute_with_status(rpm_cmd)
41
45
  if status == 0
42
46
  result
43
47
  end
@@ -78,12 +82,12 @@ module ForemanMaintain::PackageManager
78
82
  sys.execute(find_cmd).split("\n")
79
83
  end
80
84
 
81
- def list_installed_packages(queryfm = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
82
- # The queryfm should only include valid tag(s) as per `rpm --querytag` list.
85
+ def list_installed_packages(queryformat = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
86
+ # The queryformat should only include valid tag(s) as per `rpm --querytags` list.
83
87
  # If any special formatting is required with querytag then it should be provided with tag i.e,
84
- # querytag = "--%{VENDOR}"
85
- # The queryfm string must end with '\n'
86
- sys.execute!("rpm -qa --qf '#{queryfm}'").split("\n")
88
+ # "--%{VENDOR}"
89
+ # The queryformat string must end with '\n'
90
+ sys.execute!("rpm -qa --qf '#{queryformat}'").split("\n")
87
91
  end
88
92
 
89
93
  private
@@ -317,11 +317,7 @@ 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
- 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
320
+ steps_to_whitelist = steps_with_error + steps_with_skipped
325
321
  unless steps_with_error.empty?
326
322
  message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
327
323
  The following steps ended up in failing state:
@@ -329,25 +325,11 @@ module ForemanMaintain
329
325
  %s
330
326
  MESSAGE
331
327
  whitelist_labels = steps_to_whitelist.map(&:label_dashed).join(',')
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
328
+ recommend << format(<<-MESSAGE.strip_heredoc, whitelist_labels)
329
+ Resolve the failed steps and rerun
330
+ the command. In case the failures are false positives,
331
+ use --whitelist="%s"
332
+ MESSAGE
351
333
  end
352
334
 
353
335
  steps_with_warning = scenario.steps_with_warning(:whitelisted => false)
@@ -8,21 +8,16 @@ module ForemanMaintain::Utils
8
8
  @instance_parent_unit = options.fetch(:instance_parent_unit, nil)
9
9
  end
10
10
 
11
- def command(action, options = {})
12
- do_wait = options.fetch(:wait, true) # wait for service to start
11
+ def command(action)
13
12
  all = @options.fetch(:all, false)
14
13
  skip_enablement = @options.fetch(:skip_enablement, false)
15
14
  if skip_enablement && %w[enable disable].include?(action)
16
15
  return skip_enablement_message(action, @name)
17
16
  end
18
17
 
19
- if do_wait && File.exist?('/usr/sbin/service-wait')
20
- "service-wait #{@name} #{action}"
21
- else
22
- cmd = "systemctl #{action} #{@name}"
23
- cmd += ' --all' if all
24
- cmd
25
- end
18
+ cmd = "systemctl #{action} #{@name}"
19
+ cmd += ' --all' if all
20
+ cmd
26
21
  end
27
22
 
28
23
  def status
@@ -38,11 +33,11 @@ module ForemanMaintain::Utils
38
33
  end
39
34
 
40
35
  def enable
41
- execute('enable', :wait => false)
36
+ execute('enable')
42
37
  end
43
38
 
44
39
  def disable
45
- execute('disable', :wait => false)
40
+ execute('disable')
46
41
  end
47
42
 
48
43
  def running?
@@ -66,8 +61,8 @@ module ForemanMaintain::Utils
66
61
 
67
62
  private
68
63
 
69
- def execute(action, options = {})
70
- @sys.execute_with_status(command(action, options))
64
+ def execute(action)
65
+ @sys.execute_with_status(command(action))
71
66
  end
72
67
 
73
68
  def service_enabled_status
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.0.12'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  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: 1.0.12
4
+ version: 1.1.1
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-06-08 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -266,7 +266,6 @@ 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
270
269
  - definitions/procedures/installer/upgrade.rb
271
270
  - definitions/procedures/installer/upgrade_rake_task.rb
272
271
  - definitions/procedures/knowledge_base_article.rb
@@ -1,52 +0,0 @@
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