foreman_maintain 0.8.31 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/definitions/checks/check_for_newer_packages.rb +3 -5
  3. data/definitions/checks/disk/performance.rb +8 -19
  4. data/definitions/checks/repositories/validate.rb +1 -2
  5. data/definitions/checks/restore/validate_interfaces.rb +24 -0
  6. data/definitions/features/foreman_tasks.rb +7 -25
  7. data/definitions/features/system_repos.rb +0 -8
  8. data/definitions/procedures/backup/metadata.rb +11 -0
  9. data/definitions/procedures/content/prepare.rb +1 -2
  10. data/definitions/procedures/content/switchover.rb +0 -1
  11. data/definitions/procedures/installer/upgrade_rake_task.rb +1 -3
  12. data/definitions/procedures/packages/update.rb +1 -3
  13. data/definitions/procedures/pulp/remove.rb +13 -61
  14. data/definitions/procedures/repositories/setup.rb +0 -4
  15. data/definitions/procedures/restore/configs.rb +5 -1
  16. data/definitions/scenarios/restore.rb +3 -4
  17. data/definitions/scenarios/upgrade_to_satellite_6_10.rb +8 -1
  18. data/lib/foreman_maintain/cli.rb +0 -2
  19. data/lib/foreman_maintain/concerns/metadata.rb +0 -4
  20. data/lib/foreman_maintain/concerns/os_facts.rb +70 -0
  21. data/lib/foreman_maintain/concerns/system_helpers.rb +7 -32
  22. data/lib/foreman_maintain/package_manager/yum.rb +4 -8
  23. data/lib/foreman_maintain/reporter/cli_reporter.rb +6 -24
  24. data/lib/foreman_maintain/utils/backup.rb +36 -11
  25. data/lib/foreman_maintain/utils/command_runner.rb +1 -2
  26. data/lib/foreman_maintain/utils.rb +0 -1
  27. data/lib/foreman_maintain/version.rb +1 -1
  28. data/lib/foreman_maintain.rb +1 -0
  29. metadata +22 -13
  30. data/definitions/checks/pulpcore/group_ownership_check.rb +0 -18
  31. data/definitions/procedures/repositories/backup_enabled_repos.rb +0 -16
  32. data/definitions/procedures/repositories/enable.rb +0 -13
  33. data/definitions/procedures/restore/candlepin_reset_migrations.rb +0 -14
  34. data/definitions/scenarios/self_upgrade.rb +0 -73
  35. data/lib/foreman_maintain/cli/self_upgrade_command.rb +0 -18
  36. data/lib/foreman_maintain/utils/facter.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a60ab5a7e89c406aa5a1821ec0786f4a523e8ff099624c5f7e08fa1ea0c01e6
4
- data.tar.gz: bda6f1436f8719c7c4888b07b494110101c06a3696f7d3cbf177f516d538e7db
3
+ metadata.gz: e995fb504729078ae910121820a8f286d1256b4319d07d25f27a17768ba515af
4
+ data.tar.gz: 8fb3b6231928b49a6c6cd8375a14394b31839452ead4c0a7e3dbc198f405912d
5
5
  SHA512:
6
- metadata.gz: 1101a4af2af8e7d70bee47ac87cfbbf2f7c6eed2d47f0f61abd11995fc075c9314854520de7df3e8a2bce7447ea1557290c932aa82ff14ff2de08c11c65a8a66
7
- data.tar.gz: 98256752a9d3b1e796ac7159eaea5751dffa1d7e54ada6a4b19c4aaca98896b1008c12985005c003db7d7b8d31731e29f88c72cdedb36b2df5865edf5da87ff6
6
+ metadata.gz: 12ff59c3185962df60825149e3f34892c6bc42071fb39b35aa701b891dd34eb71843784c161e64d0218e669e66a2f85715991f76a319f48f6fb4dbeba55ddf2f
7
+ data.tar.gz: 747024ed62640c6c49406f573557253e6ea96037921633ca94489c20f34f32a1a233c4f6a9bb67bdac45aa9dd8af9bb727733f7531c8d0c5303f56ce59a8ce60
@@ -33,11 +33,9 @@ class Checks::CheckForNewerPackages < ForemanMaintain::Check
33
33
  end
34
34
 
35
35
  unless packages_with_updates.empty?
36
- command = ForemanMaintain.pkg_and_cmd_name[1]
37
- fail! 'Required updates for some packages detected.'\
38
- "\nPlease update to the latest #{@manual_confirmation_version}.z release "\
39
- 'before proceeding, using:'\
40
- "\n# #{command} upgrade run --target-version #{@manual_confirmation_version}.z"
36
+ failure_message = 'An update is available for package(s): '\
37
+ "#{packages_with_updates.join(',')}. Please update before proceeding!"
38
+ fail! failure_message
41
39
  end
42
40
  end
43
41
 
@@ -39,8 +39,8 @@ module Checks
39
39
  end
40
40
  end
41
41
 
42
- def data_dirs
43
- @data_dirs ||= %i[pulpcore_database mongo foreman_database].inject({}) do |dirs, f|
42
+ def default_dirs
43
+ @default_dirs ||= %i[pulp2 pulpcore_database mongo foreman_database].inject({}) do |dirs, f|
44
44
  if feature(f) && File.directory?(feature(f).data_dir)
45
45
  dirs[feature(f).label_dashed] = feature(f).data_dir
46
46
  end
@@ -48,32 +48,20 @@ module Checks
48
48
  end
49
49
  end
50
50
 
51
- def pulp_dir
52
- @pulp_dir ||= begin
53
- pulp_feature = feature(:pulp2) || feature(:pulpcore_database)
54
- { pulp_feature.label_dashed => pulp_feature.pulp_data_dir }
55
- end
56
- end
57
-
58
51
  def description
59
- 'Check recommended disk speed for '\
60
- "#{[data_dirs.keys | pulp_dir.keys].join(', ')} directories."
61
- end
62
-
63
- def all_dirs
64
- data_dirs.values | pulp_dir.values
52
+ "Check recommended disk speed for #{default_dirs.keys.join(', ')} directories."
65
53
  end
66
54
 
67
55
  def check_only_single_device?
68
- all_dirs.each do |dir|
56
+ default_dirs.values do |dir|
69
57
  ForemanMaintain::Utils::Disk::Device.new(dir).name
70
58
  end.uniq.length <= 1
71
59
  end
72
60
 
73
61
  def dirs_to_check
74
- return all_dirs.first(1) if check_only_single_device?
62
+ return default_dirs.values.first(1) if check_only_single_device?
75
63
 
76
- all_dirs
64
+ default_dirs.values
77
65
  end
78
66
 
79
67
  private
@@ -86,10 +74,11 @@ module Checks
86
74
  def compute_disk_speed(spinner)
87
75
  success = true
88
76
  io_obj = ForemanMaintain::Utils::Disk::NilDevice.new
77
+
89
78
  dirs_to_check.each do |dir|
90
79
  io_obj = ForemanMaintain::Utils::Disk::Device.new(dir)
91
80
 
92
- spinner.update("[Speed check In-Progress] device:#{io_obj.name}")
81
+ spinner.update("[Speed check In-Progress] device: #{io_obj.name}")
93
82
  stats << io_obj
94
83
 
95
84
  next if io_obj.read_speed >= EXPECTED_IO
@@ -3,8 +3,7 @@ module Checks::Repositories
3
3
  metadata do
4
4
  description 'Validate availability of repositories'
5
5
  preparation_steps do
6
- [Checks::Repositories::CheckNonRhRepository.new,
7
- Procedures::Packages::Install.new(:packages => [ForemanMaintain::Utils::Facter.package])]
6
+ Checks::Repositories::CheckNonRhRepository.new
8
7
  end
9
8
 
10
9
  confine do
@@ -0,0 +1,24 @@
1
+ require 'foreman_maintain/utils/backup'
2
+
3
+ module Checks::Restore
4
+ class ValidateInterfaces < ForemanMaintain::Check
5
+ metadata do
6
+ description 'Validate network interfaces match the backup'
7
+
8
+ param :backup_dir,
9
+ 'Path to backup directory',
10
+ :required => true
11
+ manual_detection
12
+ end
13
+
14
+ def run
15
+ backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
16
+ invalid_interfaces = backup.validate_interfaces
17
+ msg = 'The following features are enabled in the backup, '\
18
+ "\nbut the system does not have the interfaces used by these features: "
19
+ msg << invalid_interfaces.map { |k, v| "#{k} (#{v['configured']})" }.join(', ')
20
+ msg << '.'
21
+ assert(backup.validate_interfaces.empty?, msg)
22
+ end
23
+ end
24
+ end
@@ -17,17 +17,6 @@ class Features::ForemanTasks < ForemanMaintain::Feature
17
17
  Actions::Candlepin::ListenOnCandlepinEvents
18
18
  Actions::Katello::EventQueue::Monitor
19
19
  Actions::Insights::EmailPoller
20
- ForemanInventoryUpload::Async::GenerateReportJob
21
- ForemanInventoryUpload::Async::QueueForUploadJob
22
- ForemanInventoryUpload::Async::UploadReportJob
23
- InsightsCloud::Async::InsightsClientStatusAging
24
- InsightsCloud::Async::InsightsFullSync
25
- InsightsCloud::Async::InsightsResolutionsSync
26
- InsightsCloud::Async::InsightsRulesSync
27
- InventorySync::Async::InventoryFullSync
28
- InventorySync::Async::InventoryHostsSync
29
- InventorySync::Async::InventoryScheduledSync
30
- InventorySync::Async::InventorySelfHostSync
31
20
  ].freeze
32
21
 
33
22
  metadata do
@@ -82,22 +71,15 @@ class Features::ForemanTasks < ForemanMaintain::Feature
82
71
  def delete(state)
83
72
  tasks_condition = condition(state)
84
73
 
85
- sql = <<-SQL
86
- DELETE FROM dynflow_steps USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid::varchar) AND #{tasks_condition};
87
- DELETE FROM dynflow_actions USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid::varchar) AND #{tasks_condition};
88
- DELETE FROM dynflow_execution_plans USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid::varchar) AND #{tasks_condition};
89
- DELETE FROM foreman_tasks_tasks WHERE #{tasks_condition};
90
- -- Delete locks and links which may now be orphaned
91
- DELETE FROM foreman_tasks_locks as ftl where ftl.task_id NOT IN (SELECT id FROM foreman_tasks_tasks);
74
+ feature(:foreman_database).psql(<<-SQL)
75
+ BEGIN;
76
+ DELETE FROM dynflow_steps USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid::varchar) AND #{tasks_condition};
77
+ DELETE FROM dynflow_actions USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid::varchar) AND #{tasks_condition};
78
+ DELETE FROM dynflow_execution_plans USING foreman_tasks_tasks WHERE (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid::varchar) AND #{tasks_condition};
79
+ DELETE FROM foreman_tasks_tasks WHERE #{tasks_condition};
80
+ COMMIT;
92
81
  SQL
93
82
 
94
- if check_min_version(foreman_plugin_name('foreman-tasks'), '4.0.0')
95
- sql += 'DELETE FROM foreman_tasks_links as ftl ' \
96
- 'where ftl.task_id NOT IN (SELECT id FROM foreman_tasks_tasks);'
97
- end
98
-
99
- feature(:foreman_database).psql("BEGIN; #{sql}; COMMIT;")
100
-
101
83
  count(state)
102
84
  end
103
85
 
@@ -21,10 +21,6 @@ class Features::SystemRepos < ForemanMaintain::Feature
21
21
  Hash[*repos.delete!(' ').split("\n")]
22
22
  end
23
23
 
24
- def enabled_repos_ids
25
- trim_repoids(enabled_repos_hash.keys)
26
- end
27
-
28
24
  def upstream_repos_ids
29
25
  trim_repoids(upstream_repos.keys)
30
26
  end
@@ -33,10 +29,6 @@ class Features::SystemRepos < ForemanMaintain::Feature
33
29
  execute!("yum-config-manager --disable #{repo_ids.join(',')}")
34
30
  end
35
31
 
36
- def enable_repos(repo_ids)
37
- execute!("yum-config-manager --enable #{repo_ids.join(',')}")
38
- end
39
-
40
32
  private
41
33
 
42
34
  def trim_repoids(repos)
@@ -9,6 +9,8 @@ module Procedures::Backup
9
9
  param :online_backup, 'Select for online backup', :flag => true, :default => false
10
10
  end
11
11
 
12
+ PROXY_CONFIG_ENTRIES = %w[dns dns_interface dhcp dhcp_interface].freeze
13
+
12
14
  def run
13
15
  with_spinner('Collecting metadata') do |spinner|
14
16
  metadata = {}
@@ -18,6 +20,8 @@ module Procedures::Backup
18
20
  metadata['rpms'] = rpms(spinner)
19
21
  metadata['incremental'] = @incremental_dir || false
20
22
  metadata['online'] = @online_backup
23
+ metadata['hostname'] = hostname
24
+ metadata['proxy_config'] = proxy_config(spinner)
21
25
  save_metadata(metadata, spinner)
22
26
  end
23
27
  end
@@ -54,5 +58,12 @@ module Procedures::Backup
54
58
  feature(:foreman_proxy).features
55
59
  end
56
60
  end
61
+
62
+ def proxy_config(spinner)
63
+ spinner.update('Collecting proxy configuration')
64
+ feature(:installer).answers['foreman_proxy'].select do |key, _|
65
+ PROXY_CONFIG_ENTRIES.include?(key)
66
+ end
67
+ end
57
68
  end
58
69
  end
@@ -4,14 +4,13 @@ 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
11
10
  sleep(20) # in satellite 6.9 the services are still coming up
12
11
  # use interactive to get realtime output
13
12
  env_vars = @quiet ? '' : 'preserve_output=true '
14
- execute!("#{env_vars}foreman-rake katello:pulp3_migration", :interactive => true)
13
+ puts execute!("#{env_vars}foreman-rake katello:pulp3_migration", :interactive => true)
15
14
  end
16
15
  end
17
16
  end
@@ -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
@@ -5,9 +5,7 @@ module Procedures::Installer
5
5
  end
6
6
 
7
7
  def run
8
- # only run this in the Satellite scenario, as in others
9
- # the installer runs this rake task for us already
10
- execute!('foreman-rake upgrade:run') if feature(:satellite)
8
+ execute!('foreman-rake upgrade:run')
11
9
  end
12
10
  end
13
11
  end
@@ -6,14 +6,12 @@ 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 => []
10
9
  end
11
10
 
12
11
  def run
13
12
  assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
14
13
  package_manager.clean_cache(:assumeyes => assumeyes_val)
15
- opts = { :assumeyes => assumeyes_val, :yum_options => @yum_options }
16
- packages_action(:update, @packages, opts)
14
+ packages_action(:update, @packages, :assumeyes => assumeyes_val)
17
15
  rescue ForemanMaintain::Error::ExecutionError => e
18
16
  if @warn_on_errors
19
17
  set_status(:warning, e.message)
@@ -23,15 +23,7 @@ module Procedures::Pulp
23
23
  '/var/lib/pulp/uploads',
24
24
  '/var/lib/mongodb/',
25
25
  '/var/cache/pulp'
26
- ].select { |dir| File.directory?(dir) }
27
- end
28
-
29
- def pulp_data_dirs_mountpoints
30
- pulp_data_dirs.select { |d| Pathname(d).mountpoint? }
31
- end
32
-
33
- def deletable_pulp_dirs
34
- @deletable_pulp_dirs ||= pulp_data_dirs - pulp_data_dirs_mountpoints
26
+ ]
35
27
  end
36
28
 
37
29
  # rubocop:disable Metrics/MethodLength
@@ -60,12 +52,11 @@ module Procedures::Pulp
60
52
  @installed_pulp_packages
61
53
  end
62
54
 
63
- def data_dir_removal_cmds(pulp_dirs)
64
- pulp_dirs.map { |dir| "rm -rf #{dir}" }
55
+ def data_dir_removal_cmds
56
+ pulp_data_dirs.select { |dir| File.directory?(dir) }.map { |dir| "rm -rf #{dir}" }
65
57
  end
66
58
 
67
- def ask_to_proceed
68
- rm_cmds = data_dir_removal_cmds(pulp_data_dirs)
59
+ def ask_to_proceed(rm_cmds)
69
60
  question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
70
61
  question += "\n# rpm -e #{pulp_packages.join(' ')}" if pulp_packages.any?
71
62
  question += "\n# yum remove rh-mongodb34-*"
@@ -78,9 +69,11 @@ module Procedures::Pulp
78
69
  end
79
70
 
80
71
  def run
72
+ rm_cmds = data_dir_removal_cmds
73
+
81
74
  assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
82
75
 
83
- ask_to_proceed unless assumeyes_val
76
+ ask_to_proceed(rm_cmds) unless assumeyes_val
84
77
 
85
78
  remove_pulp if pulp_packages.any?
86
79
 
@@ -92,9 +85,7 @@ module Procedures::Pulp
92
85
 
93
86
  drop_migrations
94
87
 
95
- delete_pulp_data
96
-
97
- restart_pulpcore_services
88
+ delete_pulp_data(rm_cmds) if rm_cmds.any?
98
89
  end
99
90
 
100
91
  def remove_pulp
@@ -169,51 +160,12 @@ module Procedures::Pulp
169
160
  end
170
161
  # rubocop:enable Metrics/BlockLength
171
162
 
172
- def delete_pulp_data
173
- non_mountpoints = data_dir_removal_cmds(deletable_pulp_dirs)
174
- mountpoints = pulp_data_dirs_mountpoints
175
- with_spinner('') do |spinner|
176
- if non_mountpoints.any?
177
- spinner.update('Deleting pulp2 data directories.')
178
- non_mountpoints.each do |cmd|
179
- execute!(cmd)
180
- end
181
- msg_for_del_non_mountpoints(mountpoints, spinner)
182
- end
183
- if mountpoints.any?
184
- msg_for_del_mountpoints(mountpoints, spinner)
163
+ def delete_pulp_data(rm_cmds)
164
+ with_spinner('Deleting pulp2 data directories') do |spinner|
165
+ rm_cmds.each do |cmd|
166
+ execute!(cmd)
185
167
  end
186
- end
187
- end
188
-
189
- def msg_for_del_non_mountpoints(mountpoints, spinner)
190
- if mountpoints.empty?
191
- spinner.update('Done deleting all pulp2 data directories.')
192
- else
193
- spinner.update("Deleted: #{deletable_pulp_dirs.join("\n")}")
194
- end
195
- end
196
-
197
- def msg_for_del_mountpoints(mountpoints, spinner)
198
- _, cmd_name = ForemanMaintain.pkg_and_cmd_name
199
- if mountpoints.count > 1
200
- spinner.update("The directories #{mountpoints.join(',')} are individual mountpoints.")
201
- puts "\nThe #{cmd_name} won't delete these directories.\n"\
202
- 'You need to remove content and these directories on your own.'
203
- else
204
- spinner.update("The directory #{mountpoints.join(',')} is individual mountpoint.")
205
- puts "\nThe #{cmd_name} won't delete the directory.\n"\
206
- 'You need to remove content and the directory on your own.'
207
- end
208
- end
209
-
210
- def restart_pulpcore_services
211
- with_spinner('Restarting pulpcore services') do |spinner|
212
- pulp_services = feature(:pulpcore).services
213
-
214
- feature(:service).handle_services(spinner, 'stop', :only => pulp_services)
215
- feature(:service).handle_services(spinner, 'start', :only => pulp_services)
216
- spinner.update('Done restarting pulpcore services')
168
+ spinner.update('Done deleting pulp2 data directories')
217
169
  end
218
170
  end
219
171
  end
@@ -2,10 +2,6 @@ module Procedures::Repositories
2
2
  class Setup < ForemanMaintain::Procedure
3
3
  metadata do
4
4
  description 'Setup repositories'
5
- preparation_steps do
6
- Procedures::Packages::Install.new(:packages => [ForemanMaintain::Utils::Facter.package])
7
- end
8
-
9
5
  confine do
10
6
  feature(:instance).downstream || feature(:upstream)
11
7
  end
@@ -56,7 +56,11 @@ module Procedures::Restore
56
56
  def reset_qpid_jrnls
57
57
  # on restore without pulp data qpid fails to start
58
58
  # https://access.redhat.com/solutions/4645231
59
- execute('rm -rf /var/lib/qpidd/.qpidd/qls/dat2/__db.00*')
59
+ ['/var/lib/qpidd/.qpidd/', '/var/lib/qpidd/'].each do |qpidd_path|
60
+ if Dir.exist?("#{qpidd_path}/qls/dat2/")
61
+ execute("rm -rf #{qpidd_path}/qls/dat2/__db.00*")
62
+ end
63
+ end
60
64
  end
61
65
  end
62
66
  end
@@ -18,6 +18,7 @@ module ForemanMaintain::Scenarios
18
18
  add_steps_with_context(Checks::Restore::ValidateBackup,
19
19
  Procedures::Restore::Confirmation,
20
20
  Checks::Restore::ValidateHostname,
21
+ Checks::Restore::ValidateInterfaces,
21
22
  Procedures::Selinux::SetFileSecurity,
22
23
  Procedures::Restore::Configs)
23
24
  add_step_with_context(Procedures::Crond::Stop) if feature(:cron)
@@ -37,14 +38,11 @@ module ForemanMaintain::Scenarios
37
38
  end
38
39
  restore_mongo_dump(backup)
39
40
  add_steps_with_context(Procedures::Pulp::Migrate,
40
- Procedures::Pulpcore::Migrate,
41
- Procedures::Restore::CandlepinResetMigrations)
41
+ Procedures::Pulpcore::Migrate)
42
42
 
43
43
  add_steps_with_context(Procedures::Restore::RegenerateQueues) if backup.online_backup?
44
44
  add_steps_with_context(Procedures::Service::Start,
45
45
  Procedures::Service::DaemonReload)
46
- add_step(Procedures::Installer::Upgrade.new(:assumeyes => true))
47
- add_step_with_context(Procedures::Installer::UpgradeRakeTask)
48
46
  add_step_with_context(Procedures::Crond::Start) if feature(:cron)
49
47
  end
50
48
  # rubocop:enable Metrics/MethodLength,Metrics/AbcSize
@@ -90,6 +88,7 @@ module ForemanMaintain::Scenarios
90
88
  context.map(:backup_dir,
91
89
  Checks::Restore::ValidateBackup => :backup_dir,
92
90
  Checks::Restore::ValidateHostname => :backup_dir,
91
+ Checks::Restore::ValidateInterfaces => :backup_dir,
93
92
  Procedures::Restore::Configs => :backup_dir,
94
93
  Procedures::Restore::DropDatabases => :backup_dir,
95
94
  Procedures::Restore::PgGlobalObjects => :backup_dir,
@@ -25,7 +25,6 @@ module Scenarios::Satellite_6_10
25
25
  end
26
26
 
27
27
  def compose
28
- add_step(Checks::Pulpcore::GroupOwnershipCheck)
29
28
  add_step(Checks::Puppet::WarnAboutPuppetRemoval)
30
29
  add_step(Checks::CheckForNewerPackages.new(:packages => [foreman_plugin_name('katello'),
31
30
  'python3-pulp-2to3-migration'],
@@ -62,6 +61,13 @@ module Scenarios::Satellite_6_10
62
61
  context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
63
62
  end
64
63
 
64
+ def check_var_lib_pulp
65
+ group_id = File.stat('/var/lib/pulp/').gid
66
+ if Etc.getgrgid(group_id).name != 'pulp'
67
+ raise "Please run 'foreman-maintain prep-6.10-upgrade' prior to upgrading."
68
+ end
69
+ end
70
+
65
71
  def pulp3_switchover_steps
66
72
  add_step(Procedures::Service::Enable.
67
73
  new(:only => Features::Pulpcore.pulpcore_migration_services))
@@ -73,6 +79,7 @@ module Scenarios::Satellite_6_10
73
79
  end
74
80
 
75
81
  def compose
82
+ check_var_lib_pulp
76
83
  unless check_min_version(foreman_plugin_name('katello'), '4.0')
77
84
  pulp3_switchover_steps
78
85
  end
@@ -11,7 +11,6 @@ require 'foreman_maintain/cli/restore_command'
11
11
  require 'foreman_maintain/cli/maintenance_mode_command'
12
12
  require 'foreman_maintain/cli/packages_command'
13
13
  require 'foreman_maintain/cli/content_command'
14
- require 'foreman_maintain/cli/self_upgrade_command'
15
14
 
16
15
  module ForemanMaintain
17
16
  module Cli
@@ -26,7 +25,6 @@ module ForemanMaintain
26
25
  subcommand 'packages', 'Lock/Unlock package protection, install, update', PackagesCommand
27
26
  subcommand 'advanced', 'Advanced tools for server maintenance', AdvancedCommand
28
27
  subcommand 'content', 'Content related commands', ContentCommand
29
- subcommand 'self-upgrade', 'Perform major version self upgrade', SelfUpgradeCommand
30
28
  subcommand 'maintenance-mode', 'Control maintenance-mode for application',
31
29
  MaintenanceModeCommand
32
30
  if ForemanMaintain.detector.feature(:satellite) &&
@@ -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)
@@ -0,0 +1,70 @@
1
+ module ForemanMaintain
2
+ module Concerns
3
+ module OsFacts
4
+ OS_RELEASE_FILE = '/etc/os-release'.freeze
5
+ FALLBACK_OS_RELEASE_FILE = '/usr/lib/os-release'.freeze
6
+
7
+ def os_release_file
8
+ if File.file?(OS_RELEASE_FILE)
9
+ return OS_RELEASE_FILE
10
+ elsif File.file?(FALLBACK_OS_RELEASE_FILE)
11
+ return FALLBACK_OS_RELEASE_FILE
12
+ else
13
+ puts "The #{OS_RELEASE_FILE} and #{FALLBACK_OS_RELEASE_FILE} files are missing! "\
14
+ "Can't continue the execution without Operating System's facts!"
15
+ exit 1
16
+ end
17
+ end
18
+
19
+ def facts
20
+ unless defined?(@facts)
21
+ @facts = {}
22
+ regex = /^(["'])(.*)(\1)$/
23
+ File.open(os_release_file) do |file|
24
+ file.readlines.each do |line|
25
+ line.strip! # drop any whitespace, including newlines from start and end of the line
26
+ next if line.start_with?('#') # ignore comments
27
+ # split at most into 2 items, if the value ever contains an =
28
+ key, value = line.split('=', 2)
29
+ next unless key && value
30
+ @facts[key] = value.gsub(regex, '\2').delete('\\')
31
+ end
32
+ end
33
+ end
34
+ @facts
35
+ end
36
+
37
+ def os_version_id
38
+ facts.fetch('VERSION_ID')
39
+ end
40
+
41
+ def os_id
42
+ facts.fetch('ID')
43
+ end
44
+
45
+ def os_id_like_list
46
+ facts.fetch('ID_LIKE', '').split
47
+ end
48
+
49
+ def el?
50
+ File.exist?('/etc/redhat-release')
51
+ end
52
+
53
+ def debian?
54
+ File.exist?('/etc/debian_version')
55
+ end
56
+
57
+ def el7?
58
+ el_major_version == 7
59
+ end
60
+
61
+ def el8?
62
+ el_major_version == 8
63
+ end
64
+
65
+ def el_major_version
66
+ return os_version_id.to_i if el?
67
+ end
68
+ end
69
+ end
70
+ end
@@ -8,6 +8,7 @@ module ForemanMaintain
8
8
  module SystemHelpers
9
9
  include Logger
10
10
  include Concerns::Finders
11
+ include ForemanMaintain::Concerns::OsFacts
11
12
 
12
13
  def self.included(klass)
13
14
  klass.extend(self)
@@ -99,13 +100,12 @@ module ForemanMaintain
99
100
  end
100
101
 
101
102
  def packages_action(action, packages, options = {})
102
- options.validate_options!(:assumeyes, :yum_options)
103
+ options.validate_options!(:assumeyes)
103
104
  case action
104
105
  when :install
105
106
  package_manager.install(packages, :assumeyes => options[:assumeyes])
106
107
  when :update
107
- package_manager.update(packages, :assumeyes => options[:assumeyes],
108
- :yum_options => options[:yum_options])
108
+ package_manager.update(packages, :assumeyes => options[:assumeyes])
109
109
  when :remove
110
110
  package_manager.remove(packages, :assumeyes => options[:assumeyes])
111
111
  else
@@ -185,38 +185,13 @@ module ForemanMaintain
185
185
  ForemanMaintain.package_manager
186
186
  end
187
187
 
188
- def os_facts
189
- facter = ForemanMaintain::Utils::Facter.path
190
- @os_facts ||= JSON.parse(execute("#{facter} -j os"))
191
- end
192
-
193
- def el?
194
- os_facts['os']['family'] == 'RedHat'
195
- end
196
-
197
- def debian?
198
- os_facts['os']['family'] == 'Debian'
199
- end
200
-
201
- def el7?
202
- os_facts['os']['release']['major'] == '7' && el?
203
- end
204
-
205
- def el8?
206
- os_facts['os']['release']['major'] == '8' && el?
207
- end
208
-
209
- def el_major_version
210
- return os_facts['os']['release']['major'] if el?
211
- end
212
-
213
188
  def ruby_prefix(scl = true)
214
- if el7? && scl
189
+ if debian?
190
+ 'ruby-'
191
+ elsif el7? && scl
215
192
  'tfm-rubygem-'
216
- elsif el7? || el8?
193
+ else
217
194
  'rubygem-'
218
- elsif debian?
219
- 'ruby-'
220
195
  end
221
196
  end
222
197
 
@@ -53,8 +53,8 @@ module ForemanMaintain::PackageManager
53
53
  yum_action('remove', packages, :assumeyes => assumeyes)
54
54
  end
55
55
 
56
- def update(packages = [], assumeyes: false, yum_options: [])
57
- yum_action('update', packages, :assumeyes => assumeyes, :yum_options => yum_options)
56
+ def update(packages = [], assumeyes: false)
57
+ yum_action('update', packages, :assumeyes => assumeyes)
58
58
  end
59
59
 
60
60
  def clean_cache(assumeyes: false)
@@ -114,12 +114,8 @@ module ForemanMaintain::PackageManager
114
114
  File.open(protector_config_file, 'w') { |file| file.puts config }
115
115
  end
116
116
 
117
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
118
- def yum_action(action, packages, options)
119
- with_status = options.fetch(:with_status, false)
120
- assumeyes = options.fetch(:assumeyes, false)
121
- valid_exit_statuses = options.fetch(:valid_exit_statuses, [0])
122
- yum_options = options.fetch(:yum_options, [])
117
+ def yum_action(action, packages, with_status: false, assumeyes: false, valid_exit_statuses: [0])
118
+ yum_options = []
123
119
  packages = [packages].flatten(1)
124
120
  yum_options << '-y' if assumeyes
125
121
  yum_options << '--disableplugin=foreman-protector'
@@ -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)
@@ -267,21 +267,46 @@ module ForemanMaintain
267
267
 
268
268
  def validate_hostname?
269
269
  # make sure that the system hostname is the same as the backup
270
- config_tarball = file_map[:config_files][:path]
271
- tar_cmd = "tar zxf #{config_tarball} etc/httpd/conf/httpd.conf --to-stdout --occurrence=1"
272
- status, httpd_config = execute_with_status(tar_cmd)
273
-
274
- # Incremental backups sometimes don't include httpd.conf. Since a "base" backup
275
- # is restored before an incremental, we can assume that the hostname is checked
276
- # during the base backup restore
277
- if status == 0
278
- match = httpd_config.match(/\s*ServerName\s+"*([^ "]+)"*\s*$/)
279
- match ? match[1] == hostname : false
270
+ hostname_from_metadata = metadata.fetch('hostname', nil)
271
+ if hostname_from_metadata
272
+ hostname_from_metadata == hostname
280
273
  else
281
- true
274
+ config_tarball = file_map[:config_files][:path]
275
+ tar_cmd = "tar zxf #{config_tarball} etc/httpd/conf/httpd.conf --to-stdout --occurrence=1"
276
+ status, httpd_config = execute_with_status(tar_cmd)
277
+
278
+ # Incremental backups sometimes don't include httpd.conf. Since a "base" backup
279
+ # is restored before an incremental, we can assume that the hostname is checked
280
+ # during the base backup restore
281
+ if status == 0
282
+ match = httpd_config.match(/\s*ServerName\s+"*([^ "]+)"*\s*$/)
283
+ match ? match[1] == hostname : false
284
+ else
285
+ true
286
+ end
282
287
  end
283
288
  end
284
289
 
290
+ def validate_interfaces
291
+ # I wanted to do `Socket.getifaddrs.map(&:name).uniq`,
292
+ # but this has to work with Ruby 2.0, and Socket.getifaddrs is 2.1+
293
+ errors = {}
294
+ system_interfaces = Dir.children('/sys/class/net')
295
+
296
+ proxy_config = metadata.fetch('proxy_config', {})
297
+
298
+ %w[dns dhcp].each do |feature|
299
+ next unless proxy_config.fetch(feature, false)
300
+
301
+ wanted_interface = proxy_config.fetch("#{feature}_interface", 'lo')
302
+ unless system_interfaces.include?(wanted_interface)
303
+ errors[feature] = { 'configured' => wanted_interface, 'available' => system_interfaces }
304
+ end
305
+ end
306
+
307
+ return errors
308
+ end
309
+
285
310
  def metadata
286
311
  if file_map[:metadata][:present]
287
312
  YAML.load_file(file_map[:metadata][:path])
@@ -66,8 +66,7 @@ module ForemanMaintain
66
66
  log_file = Tempfile.open('captured-output')
67
67
  exit_file = Tempfile.open('captured-exit-code')
68
68
  Kernel.system(
69
- "stdbuf -oL -eL bash -c '#{full_command}; echo $? > #{exit_file.path}'"\
70
- "| tee -i #{log_file.path}"
69
+ "bash -c '#{full_command}; echo $? > #{exit_file.path}' | tee -i #{log_file.path}"
71
70
  )
72
71
  File.open(log_file.path) { |f| @output = f.read }
73
72
  File.open(exit_file.path) do |f|
@@ -7,4 +7,3 @@ require 'foreman_maintain/utils/curl_response'
7
7
  require 'foreman_maintain/utils/mongo_core'
8
8
  require 'foreman_maintain/utils/service'
9
9
  require 'foreman_maintain/utils/system_helpers'
10
- require 'foreman_maintain/utils/facter'
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.8.31'.freeze
2
+ VERSION = '0.9.1'.freeze
3
3
  end
@@ -15,6 +15,7 @@ module ForemanMaintain
15
15
  require 'foreman_maintain/concerns/finders'
16
16
  require 'foreman_maintain/concerns/metadata'
17
17
  require 'foreman_maintain/concerns/scenario_metadata'
18
+ require 'foreman_maintain/concerns/os_facts'
18
19
  require 'foreman_maintain/concerns/system_helpers'
19
20
  require 'foreman_maintain/concerns/system_service'
20
21
  require 'foreman_maintain/concerns/hammer'
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.8.31
4
+ version: 0.9.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-07 00:00:00.000000000 Z
11
+ date: 2021-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -84,16 +84,30 @@ dependencies:
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "<"
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
88
102
  - !ruby/object:Gem::Version
89
- version: 11.0.0
103
+ version: 0.50.0
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "<"
108
+ - - '='
95
109
  - !ruby/object:Gem::Version
96
- version: 11.0.0
110
+ version: 0.50.0
97
111
  description: Provides various features that helps keeping the Foreman/Satellite up
98
112
  and running.
99
113
  email: inecas@redhat.com
@@ -154,7 +168,6 @@ files:
154
168
  - definitions/checks/original_assets.rb
155
169
  - definitions/checks/package_manager/yum/validate_yum_config.rb
156
170
  - definitions/checks/pulpcore/db_up.rb
157
- - definitions/checks/pulpcore/group_ownership_check.rb
158
171
  - definitions/checks/puppet/provide_upgrade_guide.rb
159
172
  - definitions/checks/puppet/verify_no_empty_cacert_requests.rb
160
173
  - definitions/checks/puppet/warn_about_puppet_removal.rb
@@ -164,6 +177,7 @@ files:
164
177
  - definitions/checks/repositories/validate.rb
165
178
  - definitions/checks/restore/validate_backup.rb
166
179
  - definitions/checks/restore/validate_hostname.rb
180
+ - definitions/checks/restore/validate_interfaces.rb
167
181
  - definitions/checks/root_user.rb
168
182
  - definitions/checks/server_ping.rb
169
183
  - definitions/checks/services_up.rb
@@ -274,12 +288,9 @@ files:
274
288
  - definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb
275
289
  - definitions/procedures/refresh_features.rb
276
290
  - definitions/procedures/remote_execution/remove_existing_settingsd.rb
277
- - definitions/procedures/repositories/backup_enabled_repos.rb
278
291
  - definitions/procedures/repositories/disable.rb
279
- - definitions/procedures/repositories/enable.rb
280
292
  - definitions/procedures/repositories/setup.rb
281
293
  - definitions/procedures/restore/candlepin_dump.rb
282
- - definitions/procedures/restore/candlepin_reset_migrations.rb
283
294
  - definitions/procedures/restore/configs.rb
284
295
  - definitions/procedures/restore/confirmation.rb
285
296
  - definitions/procedures/restore/drop_databases.rb
@@ -310,7 +321,6 @@ files:
310
321
  - definitions/scenarios/packages.rb
311
322
  - definitions/scenarios/prep_6_10_upgrade.rb
312
323
  - definitions/scenarios/restore.rb
313
- - definitions/scenarios/self_upgrade.rb
314
324
  - definitions/scenarios/services.rb
315
325
  - definitions/scenarios/upgrade_to_capsule_6_10.rb
316
326
  - definitions/scenarios/upgrade_to_capsule_6_10_z.rb
@@ -358,7 +368,6 @@ files:
358
368
  - lib/foreman_maintain/cli/maintenance_mode_command.rb
359
369
  - lib/foreman_maintain/cli/packages_command.rb
360
370
  - lib/foreman_maintain/cli/restore_command.rb
361
- - lib/foreman_maintain/cli/self_upgrade_command.rb
362
371
  - lib/foreman_maintain/cli/service_command.rb
363
372
  - lib/foreman_maintain/cli/transform_clamp_options.rb
364
373
  - lib/foreman_maintain/cli/upgrade_command.rb
@@ -369,6 +378,7 @@ files:
369
378
  - lib/foreman_maintain/concerns/hammer.rb
370
379
  - lib/foreman_maintain/concerns/logger.rb
371
380
  - lib/foreman_maintain/concerns/metadata.rb
381
+ - lib/foreman_maintain/concerns/os_facts.rb
372
382
  - lib/foreman_maintain/concerns/primary_checks.rb
373
383
  - lib/foreman_maintain/concerns/pulp_common.rb
374
384
  - lib/foreman_maintain/concerns/reporter.rb
@@ -408,7 +418,6 @@ files:
408
418
  - lib/foreman_maintain/utils/disk/io_device.rb
409
419
  - lib/foreman_maintain/utils/disk/nil_device.rb
410
420
  - lib/foreman_maintain/utils/disk/stats.rb
411
- - lib/foreman_maintain/utils/facter.rb
412
421
  - lib/foreman_maintain/utils/hash_tools.rb
413
422
  - lib/foreman_maintain/utils/mongo_core.rb
414
423
  - lib/foreman_maintain/utils/response.rb
@@ -1,18 +0,0 @@
1
- module Checks
2
- module Pulpcore
3
- class GroupOwnershipCheck < ForemanMaintain::Check
4
- metadata do
5
- description 'Check the group owner of /var/lib/pulp directory'
6
- label :group_ownership_check_of_pulp_content
7
- manual_detection
8
- end
9
-
10
- def run
11
- group_id = File.stat('/var/lib/pulp/').gid
12
- if Etc.getgrgid(group_id).name != 'pulp'
13
- fail! "Please run 'foreman-maintain prep-6.10-upgrade' prior to upgrading."
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,16 +0,0 @@
1
- module Procedures::Repositories
2
- class BackupEnabledRepos < ForemanMaintain::Procedure
3
- metadata do
4
- label :backup_enabled_repos
5
- description 'Stores enabled repositories in yaml file'
6
- end
7
-
8
- def run
9
- enabled_repos_ids = feature(:system_repos).enabled_repos_ids
10
- unless enabled_repos_ids.empty?
11
- backup_dir = File.expand_path(ForemanMaintain.config.backup_dir)
12
- File.write(File.join(backup_dir, 'enabled_repos.yml'), enabled_repos_ids.to_yaml)
13
- end
14
- end
15
- end
16
- end
@@ -1,13 +0,0 @@
1
- module Procedures::Repositories
2
- class Enable < ForemanMaintain::Procedure
3
- metadata do
4
- param :repos, 'List of repositories to enable'
5
- description 'Enable repositories'
6
- end
7
- def run
8
- with_spinner('Enabling repositories') do
9
- feature(:system_repos).enable_repos(@repos)
10
- end
11
- end
12
- end
13
- end
@@ -1,14 +0,0 @@
1
- module Procedures::Restore
2
- class CandlepinResetMigrations < ForemanMaintain::Procedure
3
- metadata do
4
- description 'Ensure Candlepin runs all migrations after restoring the database'
5
- confine do
6
- feature(:candlepin_database)
7
- end
8
- end
9
-
10
- def run
11
- FileUtils.rm_f('/var/lib/candlepin/.puppet-candlepin-rpm-version')
12
- end
13
- end
14
- end
@@ -1,73 +0,0 @@
1
- module ForemanMaintain::Scenarios
2
- class SelfUpgradeBase < ForemanMaintain::Scenario
3
- include ForemanMaintain::Concerns::Downstream
4
- def target_version
5
- current_full_version = feature(:instance).downstream.current_version
6
- @target_version ||= current_full_version.bump
7
- end
8
-
9
- def current_version
10
- feature(:instance).downstream.current_minor_version
11
- end
12
-
13
- def maintenance_repo_label
14
- @maintenance_repo_label ||= context.get(:maintenance_repo_label)
15
- end
16
-
17
- def maintenance_repo_id(version)
18
- if maintenance_repo_label
19
- return maintenance_repo_label
20
- elsif (repo = ENV['MAINTENANCE_REPO_LABEL'])
21
- return repo unless repo.empty?
22
- end
23
-
24
- maintenance_repo(version)
25
- end
26
-
27
- def maintenance_repo(version)
28
- if el7?
29
- "rhel-#{el_major_version}-server-satellite-maintenance-#{version}-rpms"
30
- else
31
- "satellite-maintenance-#{version}-for-rhel-#{el_major_version}-x86_64-rpms"
32
- end
33
- end
34
-
35
- def use_rhsm?
36
- return false if maintenance_repo_label
37
-
38
- if (repo = ENV['MAINTENANCE_REPO_LABEL'])
39
- return false unless repo.empty?
40
- end
41
-
42
- true
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
52
- end
53
-
54
- class SelfUpgrade < SelfUpgradeBase
55
- metadata do
56
- label :self_upgrade_foreman_maintain
57
- description "Enables the specified version's maintenance repository and,"\
58
- "\nupdates the satellite-maintain packages"
59
- manual_detection
60
- end
61
-
62
- def compose
63
- if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
64
- pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
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))
70
- end
71
- end
72
- end
73
- end
@@ -1,18 +0,0 @@
1
- module ForemanMaintain
2
- module Cli
3
- class SelfUpgradeCommand < Base
4
- option ['--maintenance-repo-label'], 'REPOSITORY_LABEL',\
5
- 'Repository label from which packages should be updated.'\
6
- 'This can be used when standard CDN repositories are unavailable.'
7
- def execute
8
- run_scenario(upgrade_scenario)
9
- end
10
-
11
- def upgrade_scenario
12
- Scenarios::SelfUpgrade.new(
13
- maintenance_repo_label: maintenance_repo_label
14
- )
15
- end
16
- end
17
- end
18
- end
@@ -1,17 +0,0 @@
1
- module ForemanMaintain::Utils
2
- module Facter
3
- include ForemanMaintain::Concerns::SystemHelpers
4
-
5
- FACTER_FILES = %w[/usr/bin/facter /opt/puppetlabs/bin/facter].freeze
6
-
7
- def self.package
8
- puppet_version = version(execute!('/opt/puppetlabs/bin/puppet --version'))
9
-
10
- puppet_version.major >= 4 ? 'puppet-agent' : 'facter'
11
- end
12
-
13
- def self.path
14
- FACTER_FILES.find { |path| File.exist?(path) }
15
- end
16
- end
17
- end