foreman_maintain 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -4
  3. data/bin/foreman-maintain +1 -1
  4. data/bin/foreman-maintain-complete +5 -5
  5. data/definitions/checks/candlepin/db_up.rb +1 -1
  6. data/definitions/checks/candlepin/validate_db.rb +2 -9
  7. data/definitions/checks/check_for_newer_packages.rb +5 -5
  8. data/definitions/checks/check_hotfix_installed.rb +3 -7
  9. data/definitions/checks/disk/available_space_postgresql12.rb +3 -2
  10. data/definitions/checks/disk/performance.rb +3 -3
  11. data/definitions/checks/foreman/check_corrupted_roles.rb +2 -4
  12. data/definitions/checks/foreman/check_duplicate_permission.rb +1 -1
  13. data/definitions/checks/foreman/check_duplicate_roles.rb +1 -1
  14. data/definitions/checks/foreman/check_tuning_requirements.rb +1 -1
  15. data/definitions/checks/foreman/db_up.rb +1 -1
  16. data/definitions/checks/foreman/facts_names.rb +4 -4
  17. data/definitions/checks/foreman_openscap/invalid_report_associations.rb +4 -4
  18. data/definitions/checks/foreman_proxy/check_tftp_storage.rb +4 -4
  19. data/definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb +1 -2
  20. data/definitions/checks/foreman_tasks/invalid/check_old.rb +2 -2
  21. data/definitions/checks/foreman_tasks/invalid/check_pending_state.rb +2 -2
  22. data/definitions/checks/foreman_tasks/invalid/check_planning_state.rb +2 -2
  23. data/definitions/checks/foreman_tasks/not_paused.rb +2 -2
  24. data/definitions/checks/foreman_tasks/not_running.rb +6 -6
  25. data/definitions/checks/original_assets.rb +3 -3
  26. data/definitions/checks/package_manager/yum/validate_yum_config.rb +1 -1
  27. data/definitions/checks/pulpcore/db_up.rb +1 -1
  28. data/definitions/checks/repositories/check_upstream_repository.rb +2 -2
  29. data/definitions/checks/repositories/validate.rb +2 -2
  30. data/definitions/checks/restore/validate_backup.rb +2 -2
  31. data/definitions/checks/restore/validate_hostname.rb +2 -2
  32. data/definitions/checks/restore/validate_interfaces.rb +2 -2
  33. data/definitions/checks/restore/validate_postgresql_dump_permissions.rb +31 -0
  34. data/definitions/checks/services_up.rb +2 -2
  35. data/definitions/features/apache.rb +1 -1
  36. data/definitions/features/candlepin.rb +1 -1
  37. data/definitions/features/candlepin_database.rb +2 -4
  38. data/definitions/features/cron.rb +3 -5
  39. data/definitions/features/dynflow_sidekiq.rb +2 -2
  40. data/definitions/features/foreman_cockpit.rb +1 -1
  41. data/definitions/features/foreman_database.rb +1 -1
  42. data/definitions/features/foreman_proxy.rb +1 -1
  43. data/definitions/features/foreman_server.rb +2 -2
  44. data/definitions/features/foreman_tasks.rb +9 -12
  45. data/definitions/features/gofer.rb +1 -1
  46. data/definitions/features/hammer.rb +4 -4
  47. data/definitions/features/installer.rb +4 -5
  48. data/definitions/features/instance.rb +12 -14
  49. data/definitions/features/katello.rb +8 -12
  50. data/definitions/features/pulpcore.rb +5 -3
  51. data/definitions/features/pulpcore_database.rb +3 -1
  52. data/definitions/features/puppet_server.rb +1 -1
  53. data/definitions/features/redis.rb +2 -18
  54. data/definitions/features/salt_server.rb +1 -1
  55. data/definitions/features/service.rb +4 -48
  56. data/definitions/features/sync_plans.rb +2 -2
  57. data/definitions/features/tar.rb +4 -3
  58. data/definitions/procedures/backup/compress_data.rb +0 -1
  59. data/definitions/procedures/backup/config_files.rb +6 -5
  60. data/definitions/procedures/backup/prepare_directory.rb +0 -2
  61. data/definitions/procedures/backup/pulp.rb +3 -3
  62. data/definitions/procedures/backup/snapshot/clean_mount.rb +1 -1
  63. data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +1 -2
  64. data/definitions/procedures/backup/snapshot/mount_pulp.rb +2 -2
  65. data/definitions/procedures/foreman/fix_corrupted_roles.rb +3 -3
  66. data/definitions/procedures/foreman_tasks/delete.rb +3 -3
  67. data/definitions/procedures/hammer_setup.rb +1 -1
  68. data/definitions/procedures/knowledge_base_article.rb +3 -4
  69. data/definitions/procedures/packages/enable_modules.rb +1 -1
  70. data/definitions/procedures/packages/install.rb +1 -1
  71. data/definitions/procedures/packages/uninstall.rb +1 -1
  72. data/definitions/procedures/packages/update.rb +1 -1
  73. data/definitions/procedures/remote_execution/remove_existing_settingsd.rb +2 -2
  74. data/definitions/procedures/repositories/enable.rb +1 -1
  75. data/definitions/procedures/repositories/setup.rb +2 -2
  76. data/definitions/procedures/restore/candlepin_dump.rb +2 -2
  77. data/definitions/procedures/restore/configs.rb +3 -10
  78. data/definitions/procedures/restore/drop_databases.rb +2 -2
  79. data/definitions/procedures/restore/extract_files.rb +4 -17
  80. data/definitions/procedures/restore/foreman_dump.rb +2 -2
  81. data/definitions/procedures/restore/installer_reset.rb +1 -2
  82. data/definitions/procedures/restore/postgres_owner.rb +2 -2
  83. data/definitions/procedures/restore/pulpcore_dump.rb +2 -2
  84. data/definitions/procedures/selinux/set_file_security.rb +2 -2
  85. data/definitions/procedures/service/restart.rb +1 -1
  86. data/definitions/scenarios/backup.rb +44 -61
  87. data/definitions/scenarios/packages.rb +9 -9
  88. data/definitions/scenarios/restore.rb +24 -40
  89. data/definitions/scenarios/self_upgrade.rb +7 -11
  90. data/definitions/scenarios/services.rb +17 -17
  91. data/extras/foreman_protector/foreman-protector.whitelist +0 -6
  92. data/lib/foreman_maintain/cli/advanced/prebuild_bash_completion.rb +1 -1
  93. data/lib/foreman_maintain/cli/advanced_command.rb +2 -2
  94. data/lib/foreman_maintain/cli/backup_command.rb +17 -17
  95. data/lib/foreman_maintain/cli/base.rb +13 -13
  96. data/lib/foreman_maintain/cli/maintenance_mode_command.rb +1 -1
  97. data/lib/foreman_maintain/cli/plugin_command.rb +1 -1
  98. data/lib/foreman_maintain/cli/restore_command.rb +4 -4
  99. data/lib/foreman_maintain/cli/self_upgrade_command.rb +2 -2
  100. data/lib/foreman_maintain/cli/service_command.rb +2 -2
  101. data/lib/foreman_maintain/cli/transform_clamp_options.rb +1 -1
  102. data/lib/foreman_maintain/cli/upgrade_command.rb +7 -7
  103. data/lib/foreman_maintain/cli.rb +1 -11
  104. data/lib/foreman_maintain/concerns/base_database.rb +8 -17
  105. data/lib/foreman_maintain/concerns/downstream.rb +6 -64
  106. data/lib/foreman_maintain/concerns/firewall/iptables_maintenance_mode.rb +1 -1
  107. data/lib/foreman_maintain/concerns/foreman_and_katello_version_map.rb +1 -1
  108. data/lib/foreman_maintain/concerns/os_facts.rb +0 -8
  109. data/lib/foreman_maintain/concerns/primary_checks.rb +6 -5
  110. data/lib/foreman_maintain/concerns/pulp_common.rb +1 -8
  111. data/lib/foreman_maintain/concerns/system_helpers.rb +3 -6
  112. data/lib/foreman_maintain/concerns/upstream.rb +3 -3
  113. data/lib/foreman_maintain/config.rb +6 -6
  114. data/lib/foreman_maintain/core_ext.rb +2 -2
  115. data/lib/foreman_maintain/executable.rb +7 -9
  116. data/lib/foreman_maintain/package_manager/apt.rb +2 -2
  117. data/lib/foreman_maintain/package_manager/base.rb +0 -2
  118. data/lib/foreman_maintain/package_manager/dnf.rb +2 -2
  119. data/lib/foreman_maintain/package_manager/yum.rb +2 -3
  120. data/lib/foreman_maintain/package_manager.rb +1 -3
  121. data/lib/foreman_maintain/param.rb +2 -2
  122. data/lib/foreman_maintain/reporter/cli_reporter.rb +6 -7
  123. data/lib/foreman_maintain/reporter.rb +15 -10
  124. data/lib/foreman_maintain/repository_manager/el.rb +2 -10
  125. data/lib/foreman_maintain/repository_manager.rb +2 -1
  126. data/lib/foreman_maintain/runner.rb +5 -5
  127. data/lib/foreman_maintain/scenario.rb +4 -2
  128. data/lib/foreman_maintain/upgrade_runner.rb +0 -2
  129. data/lib/foreman_maintain/utils/backup.rb +27 -111
  130. data/lib/foreman_maintain/utils/bash.rb +18 -19
  131. data/lib/foreman_maintain/utils/command_runner.rb +5 -9
  132. data/lib/foreman_maintain/utils/hash_tools.rb +5 -5
  133. data/lib/foreman_maintain/utils/response.rb +1 -0
  134. data/lib/foreman_maintain/utils/service/remote_db.rb +1 -0
  135. data/lib/foreman_maintain/utils/service/systemd.rb +3 -5
  136. data/lib/foreman_maintain/utils/service.rb +1 -1
  137. data/lib/foreman_maintain/utils.rb +0 -1
  138. data/lib/foreman_maintain/version.rb +1 -1
  139. data/lib/foreman_maintain/yaml_storage.rb +1 -0
  140. data/lib/foreman_maintain.rb +3 -3
  141. metadata +29 -78
  142. data/definitions/checks/foreman/check_https_proxies.rb +0 -34
  143. data/definitions/checks/mongo/db_up.rb +0 -33
  144. data/definitions/checks/mongo/tools_installed.rb +0 -31
  145. data/definitions/checks/pulpcore/group_ownership_check.rb +0 -18
  146. data/definitions/checks/puppet/provide_upgrade_guide.rb +0 -35
  147. data/definitions/checks/puppet/warn_about_puppet_removal.rb +0 -35
  148. data/definitions/checks/remote_execution/verify_settings_file_already_exists.rb +0 -42
  149. data/definitions/features/mongo.rb +0 -217
  150. data/definitions/features/pulp2.rb +0 -35
  151. data/definitions/procedures/backup/offline/mongo.rb +0 -56
  152. data/definitions/procedures/backup/online/mongo.rb +0 -21
  153. data/definitions/procedures/backup/snapshot/mount_mongo.rb +0 -43
  154. data/definitions/procedures/candlepin/delete_orphaned_records_from_env_content.rb +0 -40
  155. data/definitions/procedures/content/fix_pulpcore_artifact_permissions.rb +0 -31
  156. data/definitions/procedures/content/migration_reset.rb +0 -12
  157. data/definitions/procedures/content/migration_stats.rb +0 -12
  158. data/definitions/procedures/content/prepare.rb +0 -17
  159. data/definitions/procedures/content/prepare_abort.rb +0 -12
  160. data/definitions/procedures/content/switchover.rb +0 -41
  161. data/definitions/procedures/prep_6_10_upgrade.rb +0 -29
  162. data/definitions/procedures/pulp/cleanup_old_metadata_files.rb +0 -75
  163. data/definitions/procedures/pulp/migrate.rb +0 -23
  164. data/definitions/procedures/pulp/print_remove_instructions.rb +0 -16
  165. data/definitions/procedures/pulp/remove.rb +0 -222
  166. data/definitions/procedures/restore/ensure_mongo_engine_matches.rb +0 -35
  167. data/definitions/procedures/restore/mongo_dump.rb +0 -41
  168. data/definitions/procedures/restore/regenerate_queues.rb +0 -69
  169. data/definitions/scenarios/content.rb +0 -158
  170. data/definitions/scenarios/prep_6_10_upgrade.rb +0 -13
  171. data/definitions/scenarios/upgrade_to_capsule_6_10.rb +0 -89
  172. data/definitions/scenarios/upgrade_to_capsule_6_10_z.rb +0 -88
  173. data/definitions/scenarios/upgrade_to_capsule_6_11.rb +0 -91
  174. data/definitions/scenarios/upgrade_to_capsule_6_11_z.rb +0 -90
  175. data/definitions/scenarios/upgrade_to_capsule_6_12.rb +0 -92
  176. data/definitions/scenarios/upgrade_to_capsule_6_12_z.rb +0 -92
  177. data/definitions/scenarios/upgrade_to_capsule_6_13.rb +0 -92
  178. data/definitions/scenarios/upgrade_to_capsule_6_13_z.rb +0 -92
  179. data/definitions/scenarios/upgrade_to_capsule_6_8.rb +0 -88
  180. data/definitions/scenarios/upgrade_to_capsule_6_8_z.rb +0 -88
  181. data/definitions/scenarios/upgrade_to_capsule_6_9.rb +0 -88
  182. data/definitions/scenarios/upgrade_to_capsule_6_9_z.rb +0 -88
  183. data/definitions/scenarios/upgrade_to_satellite_6_10.rb +0 -113
  184. data/definitions/scenarios/upgrade_to_satellite_6_10_z.rb +0 -89
  185. data/definitions/scenarios/upgrade_to_satellite_6_11.rb +0 -96
  186. data/definitions/scenarios/upgrade_to_satellite_6_11_z.rb +0 -91
  187. data/definitions/scenarios/upgrade_to_satellite_6_12.rb +0 -95
  188. data/definitions/scenarios/upgrade_to_satellite_6_12_z.rb +0 -94
  189. data/definitions/scenarios/upgrade_to_satellite_6_13.rb +0 -95
  190. data/definitions/scenarios/upgrade_to_satellite_6_13_z.rb +0 -94
  191. data/definitions/scenarios/upgrade_to_satellite_6_2.rb +0 -88
  192. data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +0 -88
  193. data/definitions/scenarios/upgrade_to_satellite_6_3.rb +0 -89
  194. data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +0 -88
  195. data/definitions/scenarios/upgrade_to_satellite_6_4.rb +0 -89
  196. data/definitions/scenarios/upgrade_to_satellite_6_4_z.rb +0 -88
  197. data/definitions/scenarios/upgrade_to_satellite_6_5.rb +0 -88
  198. data/definitions/scenarios/upgrade_to_satellite_6_5_z.rb +0 -88
  199. data/definitions/scenarios/upgrade_to_satellite_6_6.rb +0 -90
  200. data/definitions/scenarios/upgrade_to_satellite_6_6_z.rb +0 -90
  201. data/definitions/scenarios/upgrade_to_satellite_6_7.rb +0 -88
  202. data/definitions/scenarios/upgrade_to_satellite_6_7_z.rb +0 -88
  203. data/definitions/scenarios/upgrade_to_satellite_6_8.rb +0 -91
  204. data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +0 -89
  205. data/definitions/scenarios/upgrade_to_satellite_6_9.rb +0 -91
  206. data/definitions/scenarios/upgrade_to_satellite_6_9_z.rb +0 -89
  207. data/lib/foreman_maintain/cli/content_command.rb +0 -69
  208. data/lib/foreman_maintain/utils/mongo_core.rb +0 -86
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4d4f7fe5a4a2f6a3a992a94e7fe674a00866dac9fa0f2f59fe30b5296c0a3a4
4
- data.tar.gz: 56b9be2ae99686aefa13e2de26b9c72bcd4a3eb82697ef2ec7b099252a2ce352
3
+ metadata.gz: 2f9e8ef6df753833b37ddddb8923706bfe5f53671e3cf21dd3706227f759d292
4
+ data.tar.gz: 43d73546fe50ec575de65b7c27b4b05df136ee1ed8076921a3b6548b310dca39
5
5
  SHA512:
6
- metadata.gz: 9dc4c82dcc0fef0ee09cc838af7afd1065c5171ea5b3400a33c58e6aece35e0964b359e8a57a9f058cb4ee82741edafc5d6da14e9d8e566a13455c44a524f9a6
7
- data.tar.gz: 4dae3e89d6bdc190fa10dde17fce93147f6c6f31ba636bb87d919cf78dbfc253dd10096e45e78f606230709bac50963a7e6c4b006203dc6386331f8209c1b425
6
+ metadata.gz: 2f4d2397cd58b6223f823c599c33695f1d814e24d782f0ee60ef97db953b741e7ad1502ec01f5cf8e24beb472360c16b0434e98461e444a42d3121f49e997a50
7
+ data.tar.gz: b09a486b783897e76cc6c70de5ce569bc5889c26a798beb01ab861a9d8baae8884e5160517875a91ad0c71e13fb773e66c97dd05c4c00be2a70fe1753aebe62f
data/README.md CHANGED
@@ -50,10 +50,6 @@ Subcommands:
50
50
  stop Stop maintenance-mode
51
51
  status Get maintenance-mode status
52
52
  is-enabled Get maintenance-mode status code
53
-
54
- content Content related commands
55
- prepare Prepare content for Pulp 3
56
- switchover Switch support for certain content from Pulp 2 to Pulp 3
57
53
  ```
58
54
 
59
55
  ### Upgrades
data/bin/foreman-maintain CHANGED
@@ -3,7 +3,7 @@
3
3
  # Ensure we use UTF-8 by defualt, even when run with LC_ALL=C
4
4
  Encoding.default_internal = Encoding.default_external = Encoding::UTF_8
5
5
 
6
- $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
6
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
7
7
 
8
8
  require 'foreman_maintain'
9
9
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'English'
3
- project_root = File.expand_path('../..', __FILE__)
3
+ project_root = File.expand_path('..', __dir__)
4
4
  $LOAD_PATH.unshift(File.join(project_root, 'lib'))
5
5
  CONFIG_FILE = '/etc/foreman-maintain/foreman_maintain.yml'.freeze
6
6
  system('which foreman_maintain > /dev/null 2>&1')
@@ -10,14 +10,14 @@ FOREMAN_MAINTAIN = found ? 'foreman-maintain' : File.join(project_root, 'bin/for
10
10
  require 'yaml'
11
11
  require 'foreman_maintain/utils/bash'
12
12
 
13
- # rubocop:disable Lint/RescueWithoutErrorClass, Lint/HandleExceptions
13
+ # rubocop:disable Lint/SuppressedException
14
14
  def cache_file(config_file)
15
15
  config = YAML.load(File.open(config_file))
16
16
  config.fetch(:completion_cache_file,
17
- "#{ENV['HOME'] || '/root'}/.cache/foreman_maintain_completion.yml")
18
- rescue
17
+ "#{ENV['HOME'] || '/root'}/.cache/foreman_maintain_completion.yml")
18
+ rescue StandardError
19
19
  end
20
- # rubocop:enable Lint/RescueWithoutErrorClass, Lint/HandleExceptions
20
+ # rubocop:enable Lint/SuppressedException
21
21
 
22
22
  config_file = if File.exist?(CONFIG_FILE)
23
23
  CONFIG_FILE
@@ -15,7 +15,7 @@ module Checks
15
15
  end
16
16
  assert(status, 'Candlepin DB is not responding. ' \
17
17
  'It needs to be up and running to perform the following steps',
18
- :next_steps => start_pgsql)
18
+ :next_steps => start_pgsql)
19
19
  else
20
20
  feature(:candlepin_database).raise_psql_missing_error
21
21
  end
@@ -5,20 +5,13 @@ module Checks::Candlepin
5
5
  tags :pre_upgrade
6
6
 
7
7
  confine do
8
- feature(:candlepin_database) && feature(:candlepin_database).validate_available_in_cpdb?
8
+ feature(:candlepin_database)&.validate_available_in_cpdb?
9
9
  end
10
10
  end
11
11
 
12
12
  def run
13
13
  result, result_msg = feature(:candlepin_database).execute_cpdb_validate_cmd
14
- next_steps = []
15
- if feature(:satellite) && feature(:satellite).current_minor_version == '6.2'
16
- next_steps.concat(
17
- [Procedures::Candlepin::DeleteOrphanedRecordsFromEnvContent.new,
18
- Procedures::KnowledgeBaseArticle.new(:doc => 'fix_cpdb_validate_failure')]
19
- )
20
- end
21
- assert(result == 0, result_msg, :next_steps => next_steps)
14
+ assert(result == 0, result_msg)
22
15
  end
23
16
  end
24
17
  end
@@ -4,11 +4,11 @@ class Checks::CheckForNewerPackages < ForemanMaintain::Check
4
4
  description 'Check for newer packages and optionally ask for confirmation if not found.'
5
5
 
6
6
  param :packages,
7
- 'package names to validate',
8
- :required => true
7
+ 'package names to validate',
8
+ :required => true
9
9
  param :manual_confirmation_version,
10
- 'Version of satellite (6.9) to ask the user if they are on the latest minor release of.',
11
- :required => false
10
+ 'Version of satellite to ask the user if they are on the latest minor release of.',
11
+ :required => false
12
12
  manual_detection
13
13
  end
14
14
 
@@ -24,7 +24,7 @@ class Checks::CheckForNewerPackages < ForemanMaintain::Check
24
24
 
25
25
  def check_for_package_update
26
26
  exit_status, output = ForemanMaintain.package_manager.check_update(packages: @packages,
27
- with_status: true)
27
+ with_status: true)
28
28
  packages_with_updates = []
29
29
  if exit_status == 100
30
30
  packages_with_updates = compare_pkg_versions(output).select do |_, result|
@@ -22,8 +22,8 @@ class Checks::CheckHotfixInstalled < ForemanMaintain::Check
22
22
  installed_pkg_list = installed_packages
23
23
  files_modifications = installed_pkg_list.flat_map { |pkg| modified_files(pkg) }
24
24
  assert(hotfix_rpmlist.empty? && files_modifications.empty?,
25
- warning_message(hotfix_rpmlist, files_modifications),
26
- :warn => true)
25
+ warning_message(hotfix_rpmlist, files_modifications),
26
+ :warn => true)
27
27
  end
28
28
  end
29
29
  end
@@ -49,17 +49,13 @@ class Checks::CheckHotfixInstalled < ForemanMaintain::Check
49
49
  io.each do |line|
50
50
  repo, pkg = line.chomp.split
51
51
  next if repo.nil? || pkg.nil?
52
- packages << pkg if /satellite|rhscl/ =~ repo.downcase
52
+ packages << pkg if /satellite/.match?(repo.downcase)
53
53
  end
54
54
  end
55
55
  packages
56
56
  end
57
57
 
58
58
  def query_format
59
- if el7?
60
- return '%{ui_from_repo} %{name}-%{evr}.%{arch}'
61
- end
62
-
63
59
  '%{from_repo} %{name}-%{evr}.%{arch}'
64
60
  end
65
61
 
@@ -16,9 +16,10 @@ module Checks
16
16
  end
17
17
 
18
18
  def pgsql_dir(version)
19
- if version == 9
19
+ case version
20
+ when 9
20
21
  '/var/lib/pgsql/'
21
- elsif version == 12
22
+ when 12
22
23
  '/var/opt/rh/rh-postgresql12/'
23
24
  end
24
25
  end
@@ -31,7 +31,7 @@ module Checks
31
31
  puts stats.stdout
32
32
 
33
33
  current_downstream_feature = feature(:instance).downstream
34
- if current_downstream_feature && current_downstream_feature.at_least_version?('6.3')
34
+ if current_downstream_feature&.at_least_version?('6.3')
35
35
  assert(success, io_obj.slow_disk_error_msg + warning_message, :warn => true)
36
36
  else
37
37
  assert(success, io_obj.slow_disk_error_msg)
@@ -40,7 +40,7 @@ module Checks
40
40
  end
41
41
 
42
42
  def data_dirs
43
- @data_dirs ||= %i[pulpcore_database mongo foreman_database].inject({}) do |dirs, f|
43
+ @data_dirs ||= %i[pulpcore_database 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
@@ -50,7 +50,7 @@ module Checks
50
50
 
51
51
  def pulp_dir
52
52
  @pulp_dir ||= begin
53
- pulp_feature = feature(:pulp2) || feature(:pulpcore_database)
53
+ pulp_feature = feature(:pulpcore)
54
54
  { pulp_feature.label_dashed => pulp_feature.pulp_data_dir }
55
55
  end
56
56
  end
@@ -14,8 +14,8 @@ module Checks
14
14
  def run
15
15
  items = find_filter_permissions
16
16
  assert(items.empty?,
17
- error_message(items),
18
- :next_steps => Procedures::Foreman::FixCorruptedRoles.new)
17
+ error_message(items),
18
+ :next_steps => Procedures::Foreman::FixCorruptedRoles.new)
19
19
  end
20
20
 
21
21
  def error_message(items)
@@ -29,7 +29,6 @@ module Checks
29
29
  feature(:foreman_database).query(self.class.inconsistent_filter_perms)
30
30
  end
31
31
 
32
- # rubocop:disable Metrics/MethodLength
33
32
  def self.inconsistent_filter_perms
34
33
  subquery = <<-SQL
35
34
  SELECT filters.id AS filter_id,
@@ -65,7 +64,6 @@ module Checks
65
64
  OR (first.resource_type != second.resource_type))
66
65
  SQL
67
66
  end
68
- # rubocop:enable Metrics/MethodLength
69
67
  end
70
68
  end
71
69
  end
@@ -14,7 +14,7 @@ module Checks
14
14
  duplicate_permissions.empty?,
15
15
  'Duplicate permissions in your database',
16
16
  :next_steps => [
17
- Procedures::Foreman::RemoveDuplicatePermissions.new
17
+ Procedures::Foreman::RemoveDuplicatePermissions.new,
18
18
  ]
19
19
  )
20
20
  end
@@ -21,7 +21,7 @@ module Checks
21
21
  Procedures::Foreman::RemoveDuplicateObsoleteRoles.new,
22
22
  Procedures::KnowledgeBaseArticle.new(
23
23
  :doc => 'fix_db_migrate_failure_on_duplicate_roles'
24
- )
24
+ ),
25
25
  ]
26
26
  )
27
27
  end
@@ -65,7 +65,7 @@ module Checks
65
65
  'medium' => { cpu_cores: 8, memory: 32 },
66
66
  'large' => { cpu_cores: 16, memory: 64 },
67
67
  'extra-large' => { cpu_cores: 32, memory: 128 },
68
- 'extra-extra-large' => { cpu_cores: 48, memory: 256 }
68
+ 'extra-extra-large' => { cpu_cores: 48, memory: 256 },
69
69
  }
70
70
  end
71
71
 
@@ -15,7 +15,7 @@ module Checks
15
15
  end
16
16
  assert(status, 'Foreman DB is not responding. ' \
17
17
  'It needs to be up and running to perform the following steps',
18
- :next_steps => start_pgsql)
18
+ :next_steps => start_pgsql)
19
19
  else
20
20
  feature(:foreman_database).raise_psql_missing_error
21
21
  end
@@ -21,10 +21,10 @@ module Checks
21
21
  host_id = result['host_id']
22
22
  count = result['count'].to_i
23
23
  assert(count < max,
24
- "Host (ID #{host_id}) has #{count} fact values which is more than #{max}.\n" \
25
- 'This can cause slow fact processing.',
26
- :warn => true,
27
- :next_steps => [Procedures::KnowledgeBaseArticle.new(:doc => 'many_fact_values')])
24
+ "Host (ID #{host_id}) has #{count} fact values which is more than #{max}.\n" \
25
+ 'This can cause slow fact processing.',
26
+ :warn => true,
27
+ :next_steps => [Procedures::KnowledgeBaseArticle.new(:doc => 'many_fact_values')])
28
28
  end
29
29
  end
30
30
  end
@@ -11,10 +11,10 @@ module Checks
11
11
  def run
12
12
  ids_to_remove = to_remove
13
13
  assert(ids_to_remove.empty?,
14
- "There are #{ids_to_remove.count} reports with issues that will be removed",
15
- :next_steps => Procedures::ForemanOpenscap::InvalidReportAssociations.new(
16
- :ids_to_remove => ids_to_remove
17
- ))
14
+ "There are #{ids_to_remove.count} reports with issues that will be removed",
15
+ :next_steps => Procedures::ForemanOpenscap::InvalidReportAssociations.new(
16
+ :ids_to_remove => ids_to_remove
17
+ ))
18
18
  end
19
19
 
20
20
  def to_remove
@@ -14,8 +14,8 @@ module Checks::ForemanProxy
14
14
  if non_zero_token_duration? && Dir.exist?(tftp_boot_directory)
15
15
  files = old_files_from_tftp_boot
16
16
  assert(files.empty?,
17
- 'There are old initrd and vmlinuz files present in tftp',
18
- :next_steps => Procedures::Files::Remove.new(:files => files))
17
+ 'There are old initrd and vmlinuz files present in tftp',
18
+ :next_steps => Procedures::Files::Remove.new(:files => files))
19
19
  else
20
20
  skip "TFTP #{tftp_boot_directory} directory doesn't exist."
21
21
  end
@@ -23,8 +23,8 @@ module Checks::ForemanProxy
23
23
 
24
24
  def old_files_from_tftp_boot
25
25
  Dir.glob("#{tftp_boot_directory}*-{vmlinuz,initrd.img}").map do |file|
26
- unless File.directory?(file)
27
- file if File.mtime(file) + (token_duration * 60) < Time.now
26
+ if !File.directory?(file) && (File.mtime(file) + (token_duration * 60) < Time.now)
27
+ file
28
28
  end
29
29
  end.compact
30
30
  end
@@ -4,8 +4,7 @@ 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) &&
8
- feature(:foreman_proxy).features.include?('dhcp') &&
7
+ feature(:foreman_proxy)&.features&.include?('dhcp') &&
9
8
  feature(:foreman_proxy).dhcp_isc_provider?
10
9
  end
11
10
  end
@@ -14,8 +14,8 @@ module Checks::ForemanTasks
14
14
  # Check and delete 'all tasks beyond 30 days(paused and stopped)'
15
15
  count_old_tasks = feature(:foreman_tasks).count(:old)
16
16
  assert(count_old_tasks <= 0,
17
- "Found #{count_old_tasks} paused or stopped task(s) older than 30 days",
18
- :next_steps => Procedures::ForemanTasks::Delete.new(:state => :old))
17
+ "Found #{count_old_tasks} paused or stopped task(s) older than 30 days",
18
+ :next_steps => Procedures::ForemanTasks::Delete.new(:state => :old))
19
19
  end
20
20
  end
21
21
  end
@@ -13,8 +13,8 @@ module Checks::ForemanTasks
13
13
  # Check and delete 'all tasks in pending state'
14
14
  count_tasks_in_pending_state = feature(:foreman_tasks).count(:pending)
15
15
  assert(count_tasks_in_pending_state <= 0,
16
- "Found #{count_tasks_in_pending_state} pending task(s) which are safe to delete",
17
- :next_steps => Procedures::ForemanTasks::Delete.new(:state => :pending))
16
+ "Found #{count_tasks_in_pending_state} pending task(s) which are safe to delete",
17
+ :next_steps => Procedures::ForemanTasks::Delete.new(:state => :pending))
18
18
  end
19
19
  end
20
20
  end
@@ -13,8 +13,8 @@ module Checks::ForemanTasks
13
13
  # Check and delete 'all tasks in planning state'
14
14
  tasks_in_planning_count = feature(:foreman_tasks).count(:planning)
15
15
  assert(tasks_in_planning_count <= 0,
16
- "Found #{tasks_in_planning_count} task(s) in planning state",
17
- :next_steps => Procedures::ForemanTasks::Delete.new(:state => :planning))
16
+ "Found #{tasks_in_planning_count} task(s) in planning state",
17
+ :next_steps => Procedures::ForemanTasks::Delete.new(:state => :planning))
18
18
  end
19
19
  end
20
20
  end
@@ -11,8 +11,8 @@ module Checks::ForemanTasks
11
11
  def run
12
12
  paused_tasks_count = feature(:foreman_tasks).paused_tasks_count()
13
13
  assert(paused_tasks_count == 0,
14
- "There are currently #{paused_tasks_count} paused tasks in the system",
15
- :next_steps => next_procedures)
14
+ "There are currently #{paused_tasks_count} paused tasks in the system",
15
+ :next_steps => next_procedures)
16
16
  end
17
17
 
18
18
  def next_procedures
@@ -11,12 +11,12 @@ module Checks::ForemanTasks
11
11
  def run
12
12
  task_count = feature(:foreman_tasks).running_tasks_count
13
13
  assert(task_count == 0,
14
- failure_message(task_count),
15
- :next_steps =>
16
- [Procedures::ForemanTasks::FetchTasksStatus.new(:state => 'running'),
17
- Procedures::ForemanTasks::UiInvestigate.new(
18
- 'search_query' => search_query_for_running_tasks
19
- )])
14
+ failure_message(task_count),
15
+ :next_steps =>
16
+ [Procedures::ForemanTasks::FetchTasksStatus.new(:state => 'running'),
17
+ Procedures::ForemanTasks::UiInvestigate.new(
18
+ 'search_query' => search_query_for_running_tasks
19
+ )])
20
20
  end
21
21
 
22
22
  private
@@ -16,8 +16,8 @@ class Checks::OriginalAssets < ForemanMaintain::Check
16
16
  end
17
17
  remove_files = Procedures::Files::Remove.new(:files => custom_assets, :assumeyes => true)
18
18
  assert(custom_assets.empty?,
19
- "Some assets not owned by #{product_name} were detected on the system.\n" \
20
- 'Possible conflicting versions can affect operation of the Web UI.',
21
- :next_steps => remove_files)
19
+ "Some assets not owned by #{product_name} were detected on the system.\n" \
20
+ 'Possible conflicting versions can affect operation of the Web UI.',
21
+ :next_steps => remove_files)
22
22
  end
23
23
  end
@@ -41,7 +41,7 @@ module Checks::PackageManager
41
41
 
42
42
  def yum_config_options
43
43
  @yum_config_options ||= {
44
- 'exclude' => '^exclude\s*=\s*\S+.*$'
44
+ 'exclude' => '^exclude\s*=\s*\S+.*$',
45
45
  }
46
46
  end
47
47
  end
@@ -14,7 +14,7 @@ module Checks
14
14
  end
15
15
  assert(status, 'Pulpcore DB is not responding. ' \
16
16
  'It needs to be up and running to perform the following steps',
17
- :next_steps => next_steps)
17
+ :next_steps => next_steps)
18
18
  end
19
19
 
20
20
  def next_steps
@@ -18,8 +18,8 @@ class Checks::CheckUpstreamRepository < ForemanMaintain::Check
18
18
  with_spinner('Checking for presence of upstream repositories') do
19
19
  enabled_repo_ids = repoids_and_urls.keys
20
20
  assert(enabled_repo_ids.empty?,
21
- "System has upstream #{enabled_repo_ids.join(',')} repositories enabled",
22
- :next_steps => Procedures::Repositories::Disable.new(:repos => enabled_repo_ids))
21
+ "System has upstream #{enabled_repo_ids.join(',')} repositories enabled",
22
+ :next_steps => Procedures::Repositories::Disable.new(:repos => enabled_repo_ids))
23
23
  end
24
24
  end
25
25
  end
@@ -11,8 +11,8 @@ module Checks::Repositories
11
11
  end
12
12
 
13
13
  param :version,
14
- 'Version for which repositories needs to be validated',
15
- :required => true
14
+ 'Version for which repositories needs to be validated',
15
+ :required => true
16
16
 
17
17
  manual_detection
18
18
  end
@@ -6,8 +6,8 @@ module Checks::Restore
6
6
  description 'Validate backup has appropriate files'
7
7
 
8
8
  param :backup_dir,
9
- 'Path to backup directory',
10
- :required => true
9
+ 'Path to backup directory',
10
+ :required => true
11
11
  manual_detection
12
12
  end
13
13
 
@@ -6,8 +6,8 @@ module Checks::Restore
6
6
  description 'Validate hostname is the same as backup'
7
7
 
8
8
  param :backup_dir,
9
- 'Path to backup directory',
10
- :required => true
9
+ 'Path to backup directory',
10
+ :required => true
11
11
  manual_detection
12
12
  end
13
13
 
@@ -6,8 +6,8 @@ module Checks::Restore
6
6
  description 'Validate network interfaces match the backup'
7
7
 
8
8
  param :backup_dir,
9
- 'Path to backup directory',
10
- :required => true
9
+ 'Path to backup directory',
10
+ :required => true
11
11
  manual_detection
12
12
  end
13
13
 
@@ -0,0 +1,31 @@
1
+ module Checks::Restore
2
+ class ValidatePostgresqlDumpPermissions < ForemanMaintain::Check
3
+ metadata do
4
+ description 'Validate permissions for PostgreSQL dumps'
5
+
6
+ param :backup_dir,
7
+ 'Path to backup directory',
8
+ :required => true
9
+ manual_detection
10
+ end
11
+
12
+ def run
13
+ backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
14
+ if feature(:instance).postgresql_local? && backup.online_backup?
15
+ errors = []
16
+ [:candlepin_dump, :foreman_dump, :pulpcore_dump].each do |dump|
17
+ next unless backup.file_map[dump][:present]
18
+
19
+ unless system("runuser - postgres -c 'test -r #{backup.file_map[dump][:path]}'")
20
+ errors << backup.file_map[dump][:path]
21
+ end
22
+ end
23
+
24
+ msg = "The 'postgres' user needs read access to the following files:\n"
25
+ msg << errors.join("\n")
26
+ assert(errors.empty?, msg)
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -14,7 +14,7 @@ class Checks::ServicesUp < ForemanMaintain::Check
14
14
  :wait_for_server_response => true
15
15
  )
16
16
  assert(failed_services.empty?,
17
- 'Following services are not running: ' + failed_services.map(&:to_s).join(', '),
18
- :next_steps => restart_procedure)
17
+ 'Following services are not running: ' + failed_services.map(&:to_s).join(', '),
18
+ :next_steps => restart_procedure)
19
19
  end
20
20
  end
@@ -9,7 +9,7 @@ class Features::Apache < ForemanMaintain::Feature
9
9
 
10
10
  def services
11
11
  [
12
- system_service(self.class.package_name, 30)
12
+ system_service(self.class.package_name, 30),
13
13
  ]
14
14
  end
15
15
 
@@ -13,7 +13,7 @@ class Features::Candlepin < ForemanMaintain::Feature
13
13
 
14
14
  def services
15
15
  [
16
- system_service('tomcat', 20)
16
+ system_service('tomcat', 20),
17
17
  ]
18
18
  end
19
19
  end
@@ -14,7 +14,7 @@ class Features::CandlepinDatabase < ForemanMaintain::Feature
14
14
  def services
15
15
  [
16
16
  system_service('postgresql', 10, :component => 'candlepin',
17
- :db_feature => feature(:candlepin_database))
17
+ :db_feature => feature(:candlepin_database)),
18
18
  ]
19
19
  end
20
20
 
@@ -53,7 +53,6 @@ class Features::CandlepinDatabase < ForemanMaintain::Feature
53
53
 
54
54
  private
55
55
 
56
- # rubocop:disable Metrics/MethodLength
57
56
  def load_configuration
58
57
  raw_config = File.read(CANDLEPIN_DB_CONFIG)
59
58
  full_config = Hash[raw_config.scan(/(^[^#\n][^=]*)=(.*)/)]
@@ -69,10 +68,9 @@ class Features::CandlepinDatabase < ForemanMaintain::Feature
69
68
  'ssl' => (fetch_extra_param(url, 'ssl') == 'true'),
70
69
  'sslfactory' => fetch_extra_param(url, 'sslfactory'),
71
70
  'driver_class' => full_config['jpa.config.hibernate.connection.driver_class'],
72
- 'url' => url
71
+ 'url' => url,
73
72
  }
74
73
  end
75
- # rubocop:enable Metrics/MethodLength
76
74
 
77
75
  def extend_with_db_options
78
76
  db_options = { '-d' => configuration['database'] }
@@ -2,9 +2,7 @@ class Features::Cron < ForemanMaintain::Feature
2
2
  metadata do
3
3
  label :cron
4
4
  confine do
5
- ForemanMaintain.config.manage_crond && !(
6
- feature(:instance).downstream && feature(:instance).downstream.less_than_version?('6.3')
7
- )
5
+ ForemanMaintain.config.manage_crond && feature(:instance).downstream
8
6
  end
9
7
  end
10
8
 
@@ -13,12 +11,12 @@ class Features::Cron < ForemanMaintain::Feature
13
11
  if cron_service.running?
14
12
  [
15
13
  'cron jobs: running',
16
- mode_on ? [Procedures::Service::Stop.new(:only => [cron_service])] : []
14
+ mode_on ? [Procedures::Service::Stop.new(:only => [cron_service])] : [],
17
15
  ]
18
16
  else
19
17
  [
20
18
  'cron jobs: not running',
21
- mode_on ? [] : [Procedures::Service::Start.new(:only => [cron_service])]
19
+ mode_on ? [] : [Procedures::Service::Start.new(:only => [cron_service])],
22
20
  ]
23
21
  end
24
22
  end
@@ -14,14 +14,14 @@ class Features::DynflowSidekiq < ForemanMaintain::Feature
14
14
  end
15
15
  [
16
16
  '/etc/foreman/dynflow',
17
- service_symlinks
17
+ service_symlinks,
18
18
  ].flatten
19
19
  end
20
20
 
21
21
  def services
22
22
  service_names.map do |service|
23
23
  system_service service, instance_priority(service),
24
- :instance_parent_unit => 'dynflow-sidekiq@'
24
+ :instance_parent_unit => 'dynflow-sidekiq@'
25
25
  end
26
26
  end
27
27
 
@@ -9,7 +9,7 @@ class Features::ForemanCockpit < ForemanMaintain::Feature
9
9
 
10
10
  def services
11
11
  [
12
- system_service('foreman-cockpit')
12
+ system_service('foreman-cockpit'),
13
13
  ]
14
14
  end
15
15
  end