foreman_maintain 1.3.0 → 1.3.2

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.
Files changed (217) 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/backup/directory_ready.rb +3 -1
  6. data/definitions/checks/candlepin/db_up.rb +1 -1
  7. data/definitions/checks/candlepin/validate_db.rb +2 -9
  8. data/definitions/checks/check_for_newer_packages.rb +5 -5
  9. data/definitions/checks/check_hotfix_installed.rb +3 -7
  10. data/definitions/checks/disk/available_space_postgresql12.rb +3 -2
  11. data/definitions/checks/disk/performance.rb +3 -3
  12. data/definitions/checks/foreman/check_corrupted_roles.rb +2 -4
  13. data/definitions/checks/foreman/check_duplicate_permission.rb +1 -1
  14. data/definitions/checks/foreman/check_duplicate_roles.rb +1 -1
  15. data/definitions/checks/foreman/check_tuning_requirements.rb +1 -1
  16. data/definitions/checks/foreman/db_up.rb +1 -1
  17. data/definitions/checks/foreman/facts_names.rb +4 -4
  18. data/definitions/checks/foreman_openscap/invalid_report_associations.rb +4 -4
  19. data/definitions/checks/foreman_proxy/check_tftp_storage.rb +4 -4
  20. data/definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb +1 -2
  21. data/definitions/checks/foreman_tasks/invalid/check_old.rb +2 -2
  22. data/definitions/checks/foreman_tasks/invalid/check_pending_state.rb +2 -2
  23. data/definitions/checks/foreman_tasks/invalid/check_planning_state.rb +2 -2
  24. data/definitions/checks/foreman_tasks/not_paused.rb +2 -2
  25. data/definitions/checks/foreman_tasks/not_running.rb +6 -6
  26. data/definitions/checks/original_assets.rb +3 -3
  27. data/definitions/checks/package_manager/yum/validate_yum_config.rb +1 -1
  28. data/definitions/checks/pulpcore/db_up.rb +1 -1
  29. data/definitions/checks/repositories/check_upstream_repository.rb +2 -2
  30. data/definitions/checks/repositories/validate.rb +2 -2
  31. data/definitions/checks/restore/validate_backup.rb +2 -2
  32. data/definitions/checks/restore/validate_hostname.rb +2 -2
  33. data/definitions/checks/restore/validate_interfaces.rb +2 -2
  34. data/definitions/checks/restore/validate_postgresql_dump_permissions.rb +31 -0
  35. data/definitions/checks/services_up.rb +2 -2
  36. data/definitions/features/apache.rb +1 -1
  37. data/definitions/features/candlepin.rb +1 -1
  38. data/definitions/features/candlepin_database.rb +2 -4
  39. data/definitions/features/cron.rb +3 -5
  40. data/definitions/features/dynflow_sidekiq.rb +2 -2
  41. data/definitions/features/foreman_cockpit.rb +1 -1
  42. data/definitions/features/foreman_database.rb +1 -1
  43. data/definitions/features/foreman_proxy.rb +1 -1
  44. data/definitions/features/foreman_server.rb +3 -7
  45. data/definitions/features/foreman_tasks.rb +9 -12
  46. data/definitions/features/gofer.rb +1 -1
  47. data/definitions/features/hammer.rb +4 -4
  48. data/definitions/features/installer.rb +4 -5
  49. data/definitions/features/instance.rb +12 -14
  50. data/definitions/features/katello.rb +8 -12
  51. data/definitions/features/pulpcore.rb +6 -30
  52. data/definitions/features/pulpcore_database.rb +3 -1
  53. data/definitions/features/puppet_server.rb +1 -1
  54. data/definitions/features/redis.rb +2 -18
  55. data/definitions/features/salt_server.rb +1 -1
  56. data/definitions/features/service.rb +4 -48
  57. data/definitions/features/sync_plans.rb +2 -2
  58. data/definitions/features/tar.rb +4 -3
  59. data/definitions/procedures/backup/compress_data.rb +0 -1
  60. data/definitions/procedures/backup/config_files.rb +6 -5
  61. data/definitions/procedures/backup/prepare_directory.rb +0 -2
  62. data/definitions/procedures/backup/pulp.rb +3 -3
  63. data/definitions/procedures/backup/snapshot/clean_mount.rb +1 -1
  64. data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +1 -2
  65. data/definitions/procedures/backup/snapshot/mount_pulp.rb +2 -2
  66. data/definitions/procedures/foreman/fix_corrupted_roles.rb +3 -3
  67. data/definitions/procedures/foreman_tasks/delete.rb +3 -3
  68. data/definitions/procedures/hammer_setup.rb +1 -1
  69. data/definitions/procedures/knowledge_base_article.rb +3 -4
  70. data/definitions/procedures/packages/enable_modules.rb +1 -1
  71. data/definitions/procedures/packages/install.rb +1 -1
  72. data/definitions/procedures/packages/uninstall.rb +1 -1
  73. data/definitions/procedures/packages/update.rb +6 -2
  74. data/definitions/procedures/pulpcore/migrate.rb +2 -3
  75. data/definitions/procedures/pulpcore/trim_rpm_changelogs.rb +2 -3
  76. data/definitions/procedures/remote_execution/remove_existing_settingsd.rb +2 -2
  77. data/definitions/procedures/repositories/enable.rb +1 -1
  78. data/definitions/procedures/repositories/setup.rb +2 -2
  79. data/definitions/procedures/restore/candlepin_dump.rb +2 -2
  80. data/definitions/procedures/restore/configs.rb +3 -10
  81. data/definitions/procedures/restore/drop_databases.rb +2 -2
  82. data/definitions/procedures/restore/extract_files.rb +4 -17
  83. data/definitions/procedures/restore/foreman_dump.rb +2 -2
  84. data/definitions/procedures/restore/installer_reset.rb +1 -2
  85. data/definitions/procedures/restore/postgres_owner.rb +2 -2
  86. data/definitions/procedures/restore/pulpcore_dump.rb +2 -2
  87. data/definitions/procedures/selinux/set_file_security.rb +2 -2
  88. data/definitions/procedures/service/restart.rb +2 -3
  89. data/definitions/scenarios/backup.rb +47 -65
  90. data/definitions/scenarios/packages.rb +9 -9
  91. data/definitions/scenarios/restore.rb +24 -40
  92. data/definitions/scenarios/self_upgrade.rb +7 -11
  93. data/definitions/scenarios/services.rb +17 -17
  94. data/definitions/scenarios/upgrade_to_capsule_6_14.rb +3 -2
  95. data/definitions/scenarios/upgrade_to_capsule_6_14_z.rb +3 -2
  96. data/definitions/scenarios/upgrade_to_katello_nightly.rb +3 -0
  97. data/definitions/scenarios/upgrade_to_satellite_6_14.rb +3 -2
  98. data/definitions/scenarios/upgrade_to_satellite_6_14_z.rb +3 -2
  99. data/extras/foreman_protector/dnf/foreman-protector.py +4 -4
  100. data/extras/foreman_protector/foreman-protector.whitelist +0 -6
  101. data/lib/foreman_maintain/cli/advanced/prebuild_bash_completion.rb +1 -1
  102. data/lib/foreman_maintain/cli/advanced_command.rb +2 -2
  103. data/lib/foreman_maintain/cli/backup_command.rb +17 -17
  104. data/lib/foreman_maintain/cli/base.rb +13 -13
  105. data/lib/foreman_maintain/cli/maintenance_mode_command.rb +1 -1
  106. data/lib/foreman_maintain/cli/plugin_command.rb +1 -1
  107. data/lib/foreman_maintain/cli/restore_command.rb +4 -4
  108. data/lib/foreman_maintain/cli/self_upgrade_command.rb +2 -2
  109. data/lib/foreman_maintain/cli/service_command.rb +2 -2
  110. data/lib/foreman_maintain/cli/transform_clamp_options.rb +1 -1
  111. data/lib/foreman_maintain/cli/upgrade_command.rb +7 -7
  112. data/lib/foreman_maintain/cli.rb +1 -11
  113. data/lib/foreman_maintain/concerns/base_database.rb +8 -17
  114. data/lib/foreman_maintain/concerns/downstream.rb +6 -64
  115. data/lib/foreman_maintain/concerns/firewall/iptables_maintenance_mode.rb +1 -1
  116. data/lib/foreman_maintain/concerns/foreman_and_katello_version_map.rb +1 -1
  117. data/lib/foreman_maintain/concerns/os_facts.rb +0 -8
  118. data/lib/foreman_maintain/concerns/primary_checks.rb +6 -5
  119. data/lib/foreman_maintain/concerns/pulp_common.rb +5 -8
  120. data/lib/foreman_maintain/concerns/system_helpers.rb +3 -6
  121. data/lib/foreman_maintain/concerns/upstream.rb +3 -3
  122. data/lib/foreman_maintain/config.rb +7 -7
  123. data/lib/foreman_maintain/core_ext.rb +2 -2
  124. data/lib/foreman_maintain/executable.rb +7 -9
  125. data/lib/foreman_maintain/package_manager/apt.rb +2 -2
  126. data/lib/foreman_maintain/package_manager/base.rb +0 -2
  127. data/lib/foreman_maintain/package_manager/dnf.rb +2 -2
  128. data/lib/foreman_maintain/package_manager/yum.rb +3 -4
  129. data/lib/foreman_maintain/package_manager.rb +7 -9
  130. data/lib/foreman_maintain/param.rb +2 -2
  131. data/lib/foreman_maintain/reporter/cli_reporter.rb +6 -7
  132. data/lib/foreman_maintain/reporter.rb +15 -10
  133. data/lib/foreman_maintain/repository_manager/el.rb +2 -10
  134. data/lib/foreman_maintain/repository_manager.rb +2 -1
  135. data/lib/foreman_maintain/runner.rb +5 -5
  136. data/lib/foreman_maintain/scenario.rb +4 -2
  137. data/lib/foreman_maintain/upgrade_runner.rb +0 -2
  138. data/lib/foreman_maintain/utils/backup.rb +27 -111
  139. data/lib/foreman_maintain/utils/bash.rb +18 -19
  140. data/lib/foreman_maintain/utils/command_runner.rb +5 -9
  141. data/lib/foreman_maintain/utils/hash_tools.rb +5 -5
  142. data/lib/foreman_maintain/utils/response.rb +1 -0
  143. data/lib/foreman_maintain/utils/service/remote_db.rb +1 -0
  144. data/lib/foreman_maintain/utils/service/systemd.rb +7 -5
  145. data/lib/foreman_maintain/utils/service.rb +1 -1
  146. data/lib/foreman_maintain/utils.rb +0 -1
  147. data/lib/foreman_maintain/version.rb +1 -1
  148. data/lib/foreman_maintain/yaml_storage.rb +1 -0
  149. data/lib/foreman_maintain.rb +7 -6
  150. metadata +29 -78
  151. data/definitions/checks/foreman/check_https_proxies.rb +0 -34
  152. data/definitions/checks/mongo/db_up.rb +0 -33
  153. data/definitions/checks/mongo/tools_installed.rb +0 -31
  154. data/definitions/checks/pulpcore/group_ownership_check.rb +0 -18
  155. data/definitions/checks/puppet/provide_upgrade_guide.rb +0 -35
  156. data/definitions/checks/puppet/warn_about_puppet_removal.rb +0 -35
  157. data/definitions/checks/remote_execution/verify_settings_file_already_exists.rb +0 -42
  158. data/definitions/features/mongo.rb +0 -217
  159. data/definitions/features/pulp2.rb +0 -35
  160. data/definitions/procedures/backup/offline/mongo.rb +0 -56
  161. data/definitions/procedures/backup/online/mongo.rb +0 -21
  162. data/definitions/procedures/backup/snapshot/mount_mongo.rb +0 -43
  163. data/definitions/procedures/candlepin/delete_orphaned_records_from_env_content.rb +0 -40
  164. data/definitions/procedures/content/fix_pulpcore_artifact_permissions.rb +0 -31
  165. data/definitions/procedures/content/migration_reset.rb +0 -12
  166. data/definitions/procedures/content/migration_stats.rb +0 -12
  167. data/definitions/procedures/content/prepare.rb +0 -17
  168. data/definitions/procedures/content/prepare_abort.rb +0 -12
  169. data/definitions/procedures/content/switchover.rb +0 -41
  170. data/definitions/procedures/prep_6_10_upgrade.rb +0 -29
  171. data/definitions/procedures/pulp/cleanup_old_metadata_files.rb +0 -75
  172. data/definitions/procedures/pulp/migrate.rb +0 -23
  173. data/definitions/procedures/pulp/print_remove_instructions.rb +0 -16
  174. data/definitions/procedures/pulp/remove.rb +0 -222
  175. data/definitions/procedures/restore/ensure_mongo_engine_matches.rb +0 -35
  176. data/definitions/procedures/restore/mongo_dump.rb +0 -41
  177. data/definitions/procedures/restore/regenerate_queues.rb +0 -69
  178. data/definitions/scenarios/content.rb +0 -158
  179. data/definitions/scenarios/prep_6_10_upgrade.rb +0 -13
  180. data/definitions/scenarios/upgrade_to_capsule_6_10.rb +0 -89
  181. data/definitions/scenarios/upgrade_to_capsule_6_10_z.rb +0 -88
  182. data/definitions/scenarios/upgrade_to_capsule_6_11.rb +0 -91
  183. data/definitions/scenarios/upgrade_to_capsule_6_11_z.rb +0 -90
  184. data/definitions/scenarios/upgrade_to_capsule_6_12.rb +0 -92
  185. data/definitions/scenarios/upgrade_to_capsule_6_12_z.rb +0 -92
  186. data/definitions/scenarios/upgrade_to_capsule_6_13.rb +0 -92
  187. data/definitions/scenarios/upgrade_to_capsule_6_13_z.rb +0 -92
  188. data/definitions/scenarios/upgrade_to_capsule_6_8.rb +0 -88
  189. data/definitions/scenarios/upgrade_to_capsule_6_8_z.rb +0 -88
  190. data/definitions/scenarios/upgrade_to_capsule_6_9.rb +0 -88
  191. data/definitions/scenarios/upgrade_to_capsule_6_9_z.rb +0 -88
  192. data/definitions/scenarios/upgrade_to_satellite_6_10.rb +0 -113
  193. data/definitions/scenarios/upgrade_to_satellite_6_10_z.rb +0 -89
  194. data/definitions/scenarios/upgrade_to_satellite_6_11.rb +0 -96
  195. data/definitions/scenarios/upgrade_to_satellite_6_11_z.rb +0 -91
  196. data/definitions/scenarios/upgrade_to_satellite_6_12.rb +0 -95
  197. data/definitions/scenarios/upgrade_to_satellite_6_12_z.rb +0 -94
  198. data/definitions/scenarios/upgrade_to_satellite_6_13.rb +0 -95
  199. data/definitions/scenarios/upgrade_to_satellite_6_13_z.rb +0 -94
  200. data/definitions/scenarios/upgrade_to_satellite_6_2.rb +0 -88
  201. data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +0 -88
  202. data/definitions/scenarios/upgrade_to_satellite_6_3.rb +0 -89
  203. data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +0 -88
  204. data/definitions/scenarios/upgrade_to_satellite_6_4.rb +0 -89
  205. data/definitions/scenarios/upgrade_to_satellite_6_4_z.rb +0 -88
  206. data/definitions/scenarios/upgrade_to_satellite_6_5.rb +0 -88
  207. data/definitions/scenarios/upgrade_to_satellite_6_5_z.rb +0 -88
  208. data/definitions/scenarios/upgrade_to_satellite_6_6.rb +0 -90
  209. data/definitions/scenarios/upgrade_to_satellite_6_6_z.rb +0 -90
  210. data/definitions/scenarios/upgrade_to_satellite_6_7.rb +0 -88
  211. data/definitions/scenarios/upgrade_to_satellite_6_7_z.rb +0 -88
  212. data/definitions/scenarios/upgrade_to_satellite_6_8.rb +0 -91
  213. data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +0 -89
  214. data/definitions/scenarios/upgrade_to_satellite_6_9.rb +0 -91
  215. data/definitions/scenarios/upgrade_to_satellite_6_9_z.rb +0 -89
  216. data/lib/foreman_maintain/cli/content_command.rb +0 -69
  217. data/lib/foreman_maintain/utils/mongo_core.rb +0 -86
@@ -1,29 +0,0 @@
1
- class Procedures::Prep610Upgrade < ForemanMaintain::Procedure
2
- metadata do
3
- description 'Preparations for the Satellite 6.10 upgrade'
4
-
5
- confine do
6
- feature(:satellite) &&
7
- feature(:satellite).current_minor_version == '6.9'
8
- end
9
- end
10
-
11
- def run
12
- puts time_warning
13
- with_spinner('Updating filesystem permissions for Pulp 3') do |spinner|
14
- spinner.update('# chmod -R g=rwX /var/lib/pulp/content')
15
- FileUtils.chmod_R 'g=rwX', '/var/lib/pulp/content'
16
- spinner.update("# find /var/lib/pulp/content -type d \! -perm -g+s -exec chmod g+s {} +")
17
- execute!('find /var/lib/pulp/content -type d \! -perm -g+s -exec chmod g+s {} +')
18
- spinner.update('# chgrp -R pulp /var/lib/pulp/content')
19
- FileUtils.chown_R nil, 'pulp', '/var/lib/pulp/content'
20
- end
21
- end
22
-
23
- private
24
-
25
- def time_warning
26
- "\e[33mprep-6.10-upgrade may take a while depending on the "\
27
- "size of /var/lib/pulp/content\e[0m"
28
- end
29
- end
@@ -1,75 +0,0 @@
1
- require 'find'
2
- require 'rexml/document'
3
-
4
- module Procedures::Pulp
5
- class CleanupOldMetadataFiles < ForemanMaintain::Procedure
6
- metadata do
7
- description 'Cleanup old and unneeded yum metadata files from /var/lib/pulp/'
8
- confine do
9
- check_max_version('katello-common', '4.0')
10
- end
11
- param :remove_files, 'If true, will actually delete files, otherwise will print them out.'
12
- end
13
-
14
- PULP_METADATA_DIR = '/var/lib/pulp/published/yum/master/yum_distributor/'.freeze
15
- REPOMD_FILE = 'repomd.xml'.freeze
16
-
17
- def run
18
- return unless File.directory?(PULP_METADATA_DIR)
19
- found = []
20
-
21
- puts 'Warning: This command may cause reduced performance related to content operations.'
22
- message = 'Locating repository metadata (this may take a while)'
23
- with_spinner(message) do |spinner|
24
- Find.find(PULP_METADATA_DIR) do |path|
25
- next if File.basename(path) != REPOMD_FILE
26
- found << path
27
- spinner.update("#{message}: Found #{found.count} repos.")
28
- end
29
- end
30
-
31
- found.each do |repo_md_path|
32
- handle(repo_md_path, @remove_files)
33
- end
34
- end
35
-
36
- def handle(repo_md_path, remove_files)
37
- base_path = File.dirname(repo_md_path)
38
- to_remove = list_existing_files(repo_md_path) - list_repomd_files(repo_md_path)
39
-
40
- if to_remove.empty?
41
- "Skipping #{base_path}, no files to remove."
42
- elsif remove_files
43
- puts '================================================================================'
44
- puts "Removing #{to_remove.count} files from #{base_path}"
45
- to_remove.each { |file| File.delete(File.join(base_path, file)) }
46
- else
47
- puts '================================================================================'
48
- puts "For #{base_path} would remove, but --remove-files was not specified:"
49
- to_remove.each { |file| puts " #{file}" }
50
- end
51
- end
52
-
53
- def list_repomd_files(repo_md_path)
54
- doc = REXML::Document.new(File.new(repo_md_path))
55
- filenames = []
56
- doc.root.elements.each do |data|
57
- locations = data.elements['location']
58
- next unless locations
59
-
60
- if locations.attributes
61
- filenames << locations.attributes['href']
62
- end
63
- end
64
- base_names(filenames.flatten)
65
- end
66
-
67
- def list_existing_files(repo_md_path)
68
- base_names(Dir[File.dirname(repo_md_path) + '/*']) - [REPOMD_FILE]
69
- end
70
-
71
- def base_names(file_list)
72
- file_list.map { |file| File.basename(file) }
73
- end
74
- end
75
- end
@@ -1,23 +0,0 @@
1
- module Procedures::Pulp
2
- class Migrate < ForemanMaintain::Procedure
3
- include ForemanMaintain::Concerns::SystemService
4
-
5
- metadata do
6
- description 'Migrate pulp db'
7
- for_feature :pulp2
8
- end
9
-
10
- def run
11
- with_spinner('Migrating pulp') do |spinner|
12
- necessary_services = feature(:mongo).services + [system_service('qpidd', 10)]
13
- pulp_services = %w[pulp_celerybeat pulp_workers pulp_resource_manager]
14
-
15
- feature(:service).handle_services(spinner, 'start', :only => necessary_services)
16
- feature(:service).handle_services(spinner, 'stop', :only => pulp_services)
17
-
18
- spinner.update('Migrating pulp database')
19
- execute!('su - apache -s /bin/bash -c pulp-manage-db')
20
- end
21
- end
22
- end
23
- end
@@ -1,16 +0,0 @@
1
- module Procedures::Pulp
2
- class PrintRemoveInstructions < ForemanMaintain::Procedure
3
- metadata do
4
- description 'Print pulp 2 removal instructions'
5
- end
6
-
7
- def run
8
- puts '======================================================'
9
- puts 'Migration of content from Pulp 2 to Pulp3 is complete'
10
- puts 'After verifying accessibility of content from clients,'
11
- puts 'it is strongly recommend to run "foreman-maintain content remove-pulp2"'
12
- puts 'This will remove Pulp 2, MongoDB, and all pulp2 content in /var/lib/pulp/content/'
13
- puts '======================================================'
14
- end
15
- end
16
- end
@@ -1,222 +0,0 @@
1
- module Procedures::Pulp
2
- class Remove < ForemanMaintain::Procedure
3
- metadata do
4
- description 'Remove pulp2'
5
- param :assumeyes, 'Do not ask for confirmation', :default => false
6
-
7
- confine do
8
- check_min_version('katello-common', '4.0')
9
- end
10
-
11
- param :assume_yes, 'Run the full removal without asking.'
12
- end
13
-
14
- def sys
15
- ForemanMaintain::Utils::SystemHelpers.new
16
- end
17
-
18
- def pulp_data_dirs
19
- [
20
- '/etc/pki/pulp/content',
21
- '/var/lib/pulp/published',
22
- '/var/lib/pulp/content',
23
- '/var/lib/pulp/importers',
24
- '/var/lib/pulp/uploads',
25
- '/var/lib/mongodb/',
26
- '/var/cache/pulp',
27
- '/var/spool/squid'
28
- ].select { |dir| File.directory?(dir) }
29
- end
30
-
31
- def pulp_data_dirs_mountpoints
32
- pulp_data_dirs.select { |d| Pathname(d).mountpoint? }
33
- end
34
-
35
- def deletable_pulp_dirs
36
- @deletable_pulp_dirs ||= pulp_data_dirs - pulp_data_dirs_mountpoints
37
- end
38
-
39
- # rubocop:disable Metrics/MethodLength
40
- def pulp_packages
41
- possible = %w[pulp-admin-client pulp-agent pulp-consumer-client pulp-deb-admin-extensions
42
- pulp-deb-plugins pulp-docker-admin-extensions pulp-docker-plugins
43
- pulp-nodes-admin-extensions pulp-nodes-child pulp-nodes-common
44
- pulp-nodes-consumer-extensions pulp-nodes-parent pulp-ostree-admin-extensions
45
- pulp-ostree-plugins pulp-puppet-admin-extensions
46
- pulp-puppet-consumer-extensions pulp-puppet-handlers pulp-puppet-plugins
47
- pulp-puppet-tools pulp-python-admin-extensions pulp-python-plugins
48
- pulp-rpm-admin-extensions pulp-rpm-consumer-extensions pulp-rpm-handlers
49
- pulp-rpm-plugins pulp-rpm-yumplugins pulp-selinux pulp-server python-bson
50
- python-crane python-isodate python-mongoengine python-nectar
51
- python-pulp-agent-lib python-pulp-bindings python-pulp-client-lib
52
- python-pulp-common python-pulp-deb-common python-pulp-devel
53
- python-pulp-docker-common python-pulp-integrity python-pulp-manifest
54
- python-pulp-oid_validation python-pulp-ostree-common python-pulp-puppet-common
55
- python-pulp-python-common python-pulp-repoauth python-pulp-rpm-common
56
- python-pulp-streamer python-pymongo python-pymongo-gridfs python2-amqp
57
- python2-billiard python2-celery python2-debpkgr python2-django python2-kombu
58
- python2-solv python2-vine pulp-katello pulp-maintenance
59
- python3-pulp-2to3-migration]
60
-
61
- @installed_pulp_packages ||= possible.select { |pkg| find_package(pkg) }
62
- @installed_pulp_packages
63
- end
64
-
65
- def data_dir_removal_cmds(pulp_dirs)
66
- pulp_dirs.map { |dir| "rm -rf #{dir}" }
67
- end
68
-
69
- def ask_to_proceed
70
- rm_cmds = data_dir_removal_cmds(pulp_data_dirs)
71
- question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
72
- question += "\n# rpm -e #{pulp_packages.join(' ')}" if pulp_packages.any?
73
- question += "\n# yum remove rh-mongodb34-*"
74
- question += "\n# yum remove squid mod_wsgi" \
75
- "\n\nAll pulp2 data will be removed.\n"
76
- question += rm_cmds.collect { |cmd| "\n# #{cmd}" }.join
77
- question += "\n\nDo you want to proceed?"
78
- answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
79
- abort! if answer != :yes
80
- end
81
-
82
- def run
83
- assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
84
-
85
- ask_to_proceed unless assumeyes_val
86
-
87
- remove_pulp if pulp_packages.any?
88
-
89
- remove_mongo
90
-
91
- remove_other_packages
92
-
93
- drop_migration_tables
94
-
95
- drop_migrations
96
-
97
- delete_pulp_data
98
-
99
- restart_pulpcore_services
100
- end
101
-
102
- def remove_pulp
103
- with_spinner('Removing pulp2 packages') do
104
- execute!("rpm -e #{pulp_packages.join(' ')}")
105
- end
106
- end
107
-
108
- def remove_mongo
109
- with_spinner('Removing mongo packages') do
110
- packages_action(:remove, ['rh-mongodb34-*'], :assumeyes => true)
111
- end
112
- end
113
-
114
- def remove_other_packages
115
- with_spinner('Removing additional packages') do
116
- packages_action(:remove, %w[squid mod_wsgi], :assumeyes => true)
117
- end
118
- end
119
-
120
- def drop_migration_tables
121
- with_spinner('Dropping migration tables') do
122
- feature(:pulpcore_database).psql(<<-SQL)
123
- BEGIN;
124
- DROP TABLE IF EXISTS pulp_2to3_migration_migrationplan,
125
- pulp_2to3_migration_pulp2blob,
126
- pulp_2to3_migration_pulp2content,
127
- pulp_2to3_migration_pulp2debcomponent,
128
- pulp_2to3_migration_pulp2debcomponentpackage,
129
- pulp_2to3_migration_pulp2debpackage,
130
- pulp_2to3_migration_pulp2debrelease,
131
- pulp_2to3_migration_pulp2debreleasearchitecture,
132
- pulp_2to3_migration_pulp2distribution,
133
- pulp_2to3_migration_pulp2distributor,
134
- pulp_2to3_migration_pulp2distributor_pulp2_repos,
135
- pulp_2to3_migration_pulp2erratum,
136
- pulp_2to3_migration_pulp2importer,
137
- pulp_2to3_migration_pulp2iso,
138
- pulp_2to3_migration_pulp2lazycatalog,
139
- pulp_2to3_migration_pulp2manifest,
140
- pulp_2to3_migration_pulp2manifestlist,
141
- pulp_2to3_migration_pulp2modulemd,
142
- pulp_2to3_migration_pulp2modulemddefaults,
143
- pulp_2to3_migration_pulp2packagecategory,
144
- pulp_2to3_migration_pulp2packageenvironment,
145
- pulp_2to3_migration_pulp2packagegroup,
146
- pulp_2to3_migration_pulp2packagelangpacks,
147
- pulp_2to3_migration_pulp2repocontent,
148
- pulp_2to3_migration_pulp2repository,
149
- pulp_2to3_migration_pulp2rpm,
150
- pulp_2to3_migration_pulp2srpm,
151
- pulp_2to3_migration_pulp2tag,
152
- pulp_2to3_migration_pulp2yumrepometadatafile,
153
- pulp_2to3_migration_reposetup CASCADE;
154
- DROP SEQUENCE IF EXISTS pulp_2to3_migration_pulp2distributor_pulp2_repos_id_seq;
155
- END;
156
- SQL
157
- end
158
- end
159
-
160
- def drop_migrations
161
- with_spinner('Dropping migrations') do
162
- feature(:pulpcore_database).psql(<<-SQL)
163
- BEGIN;
164
- DELETE FROM django_migrations WHERE app = 'pulp_2to3_migration';
165
- DELETE FROM auth_permission WHERE content_type_id in (SELECT id FROM django_content_type WHERE app_label = 'pulp_2to3_migration');
166
- DELETE FROM django_admin_log WHERE content_type_id in (SELECT id FROM django_content_type WHERE app_label = 'pulp_2to3_migration');
167
- DELETE FROM django_content_type WHERE app_label = 'pulp_2to3_migration';
168
- END;
169
- SQL
170
- end
171
- end
172
- # rubocop:enable Metrics/BlockLength
173
-
174
- def delete_pulp_data
175
- non_mountpoints = data_dir_removal_cmds(deletable_pulp_dirs)
176
- mountpoints = pulp_data_dirs_mountpoints
177
- with_spinner('') do |spinner|
178
- if non_mountpoints.any?
179
- spinner.update('Deleting pulp2 data directories.')
180
- non_mountpoints.each do |cmd|
181
- execute!(cmd)
182
- end
183
- msg_for_del_non_mountpoints(mountpoints, spinner)
184
- end
185
- if mountpoints.any?
186
- msg_for_del_mountpoints(mountpoints, spinner)
187
- end
188
- end
189
- end
190
-
191
- def msg_for_del_non_mountpoints(mountpoints, spinner)
192
- if mountpoints.empty?
193
- spinner.update('Done deleting all pulp2 data directories.')
194
- else
195
- spinner.update("Deleted: #{deletable_pulp_dirs.join("\n")}")
196
- end
197
- end
198
-
199
- def msg_for_del_mountpoints(mountpoints, spinner)
200
- _, cmd_name = ForemanMaintain.pkg_and_cmd_name
201
- if mountpoints.count > 1
202
- spinner.update("The directories #{mountpoints.join(',')} are individual mountpoints.")
203
- puts "\nThe #{cmd_name} won't delete these directories.\n"\
204
- 'You need to remove content and these directories on your own.'
205
- else
206
- spinner.update("The directory #{mountpoints.join(',')} is individual mountpoint.")
207
- puts "\nThe #{cmd_name} won't delete the directory.\n"\
208
- 'You need to remove content and the directory on your own.'
209
- end
210
- end
211
-
212
- def restart_pulpcore_services
213
- with_spinner('Restarting pulpcore services') do |spinner|
214
- pulp_services = feature(:pulpcore).services
215
-
216
- feature(:service).handle_services(spinner, 'stop', :only => pulp_services)
217
- feature(:service).handle_services(spinner, 'start', :only => pulp_services)
218
- spinner.update('Done restarting pulpcore services')
219
- end
220
- end
221
- end
222
- end
@@ -1,35 +0,0 @@
1
- module Procedures::Restore
2
- class EnsureMongoEngineMatches < ForemanMaintain::Procedure
3
- metadata do
4
- description 'Ensure restored MongoDB storage engine matches the current DB'
5
- for_feature :mongo
6
- end
7
-
8
- # rubocop:disable Metrics/AbcSize
9
- def run
10
- if feature(:mongo).local? && mongo_data_dir_exists? && engine_mismatch?
11
- with_spinner('Clean MongoDB data') do |spinner|
12
- feature(:service).handle_services(spinner, 'stop', :only => feature(:mongo).services)
13
- spinner.update('Clean MongoDB data')
14
- data_path = Dir[feature(:mongo).data_dir + '/*']
15
- FileUtils.rm_rf(data_path)
16
- FileUtils.rm_rf('/var/tmp/mongodb_engine_upgrade')
17
- feature(:service).handle_services(spinner, 'start', :only => feature(:mongo).services)
18
- end
19
- end
20
- end
21
- # rubocop:enable Metrics/AbcSize
22
-
23
- private
24
-
25
- def engine_mismatch?
26
- tiger_file = File.join(feature(:mongo).data_dir, 'WiredTiger.wt')
27
- config_file = feature(:mongo).core.server_config_files.first
28
- File.exist?(tiger_file) && File.open(config_file).grep(/^storage.engine:\s*mmapv1/).any?
29
- end
30
-
31
- def mongo_data_dir_exists?
32
- File.directory?(feature(:mongo).data_dir)
33
- end
34
- end
35
- end
@@ -1,41 +0,0 @@
1
- module Procedures::Restore
2
- class MongoDump < ForemanMaintain::Procedure
3
- metadata do
4
- description 'Restore mongo dump'
5
- for_feature :pulp2
6
- param :backup_dir,
7
- 'Path to backup directory',
8
- :required => true
9
- preparation_steps do
10
- [Checks::Mongo::DBUp.new, Checks::Mongo::ToolsInstalled.new]
11
- end
12
- confine do
13
- feature(:mongo) && feature(:pulp2)
14
- end
15
- end
16
-
17
- def run
18
- backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
19
- with_spinner('Restoring mongo dump') do |spinner|
20
- handle_mongo_service('start', spinner)
21
- drop_and_restore_mongo(backup, spinner)
22
- handle_mongo_service('stop', spinner)
23
- end
24
- end
25
-
26
- def handle_mongo_service(action, spinner)
27
- if feature(:instance).database_local?(:mongo)
28
- feature(:service).handle_services(spinner, action,
29
- :only => feature(:mongo).services)
30
- end
31
- end
32
-
33
- def drop_and_restore_mongo(backup, spinner)
34
- spinner.update('Dropping pulp_database')
35
- feature(:mongo).dropdb
36
-
37
- spinner.update('Restoring mongo dump')
38
- feature(:mongo).restore(backup.file_map[:mongo_dump][:path])
39
- end
40
- end
41
- end
@@ -1,69 +0,0 @@
1
- module Procedures::Restore
2
- class RegenerateQueues < ForemanMaintain::Procedure
3
- metadata do
4
- advanced_run false
5
- description 'Regenerate required activemq and/or qpidd queues while restoring online backup'
6
- confine do
7
- feature(:pulp2)
8
- end
9
- end
10
-
11
- def qpid_router_broker_port
12
- @qpid_router_broker_port ||= feature(:installer).
13
- answers['foreman_proxy_content']['qpid_router_broker_port']
14
- end
15
-
16
- def qpid_configs
17
- @qpid_configs ||= {
18
- 'ssl_cert' => "/etc/pki/katello/certs/#{hostname}-qpid-broker.crt",
19
- 'ssl_key' => "/etc/pki/katello/private/#{hostname}-qpid-broker.key",
20
- 'amqps_url' => "amqps://localhost:#{qpid_router_broker_port}"
21
- }
22
- end
23
-
24
- def katello_events
25
- %w[compliance.created
26
- entitlement.created
27
- entitlement.deleted
28
- pool.created
29
- pool.deleted]
30
- end
31
-
32
- def run
33
- with_spinner('Resetting the queues') do |spinner|
34
- regenerate_activemq_queues(spinner) if feature(:candlepin)
35
- regenerate_qpidd_queues(spinner)
36
- spinner.update('Queues created successfully')
37
- end
38
- end
39
-
40
- def regenerate_activemq_queues(spinner)
41
- # The activemq queues(/var/lib/candlepin/activemq-artemis) regenerate on tomcat restart.
42
- # After stopping the tomcat here, service start is triggered from the restore scenario.
43
- spinner.update('Stopping tomcat service')
44
- feature(:candlepin).services.select(&:exist?).first.stop
45
- spinner.update('Recreating activemq queues')
46
- execute!('rm -rf /var/lib/candlepin/activemq-artemis/')
47
- end
48
-
49
- def run_qpid_command(opts)
50
- execute!("qpid-config --ssl-certificate #{qpid_configs['ssl_cert']} \\
51
- --ssl-key #{qpid_configs['ssl_key']} -b #{qpid_configs['amqps_url']} #{opts}")
52
- end
53
-
54
- def regenerate_qpidd_queues(spinner)
55
- feature(:service).handle_services(spinner, 'stop', :only => ['qpidd'])
56
- execute!('rm -rf /var/lib/qpidd/.qpidd/qls')
57
- spinner.update('Starting qpidd service')
58
- feature(:service).handle_services(spinner, 'start', :only => ['qpidd'])
59
- spinner.update('Service qpidd started, waiting 60 seconds to start it completely')
60
- sleep 60
61
- spinner.update('Recreating qpidd queues')
62
- run_qpid_command('add exchange topic event --durable')
63
- run_qpid_command('add queue katello_event_queue --durable')
64
- katello_events.each do |event|
65
- run_qpid_command("bind event katello_event_queue #{event}")
66
- end
67
- end
68
- end
69
- end
@@ -1,158 +0,0 @@
1
- module ForemanMaintain::Scenarios
2
- module Content
3
- class ContentBase < ForemanMaintain::Scenario
4
- def enable_and_start_services
5
- add_step(Procedures::Service::Enable.
6
- new(:only => Features::Pulpcore.pulpcore_migration_services))
7
- add_step(Procedures::Service::Start.
8
- new(:include => Features::Pulpcore.pulpcore_migration_services))
9
- end
10
-
11
- def disable_and_stop_services
12
- add_step(Procedures::Service::Stop.
13
- new(:only => Features::Pulpcore.pulpcore_migration_services))
14
- add_step(Procedures::Service::Disable.
15
- new(:only => Features::Pulpcore.pulpcore_migration_services))
16
- end
17
- end
18
-
19
- class Prepare < ContentBase
20
- metadata do
21
- label :content_prepare
22
- description 'Prepare content for Pulp 3'
23
- manual_detection
24
- end
25
-
26
- def compose
27
- if feature(:satellite) && feature(:satellite).at_least_version?('6.9')
28
- enable_and_start_services
29
- add_step(Procedures::Content::Prepare.new(quiet: quiet?))
30
- disable_and_stop_services
31
- elsif !feature(:satellite)
32
- add_step(Procedures::Content::Prepare.new(quiet: quiet?))
33
- end
34
- end
35
-
36
- private
37
-
38
- def quiet?
39
- !!context.get(:quiet)
40
- end
41
- end
42
-
43
- class Switchover < ContentBase
44
- metadata do
45
- label :content_switchover
46
- description 'Switch support for certain content from Pulp 2 to Pulp 3'
47
- manual_detection
48
- end
49
-
50
- def compose
51
- add_step_with_context(Procedures::Content::Switchover)
52
- add_step(Procedures::Foreman::ApipieCache)
53
- end
54
- end
55
-
56
- class PrepareAbort < ContentBase
57
- metadata do
58
- label :content_prepare_abort
59
- description 'Abort all running Pulp 2 to Pulp 3 migration tasks'
60
- manual_detection
61
- end
62
-
63
- def compose
64
- if !feature(:satellite) || feature(:satellite).at_least_version?('6.9')
65
- enable_and_start_services if feature(:satellite)
66
- add_step(Procedures::Content::PrepareAbort)
67
- disable_and_stop_services if feature(:satellite)
68
- end
69
- end
70
- end
71
-
72
- class MigrationStats < ContentBase
73
- metadata do
74
- label :content_migration_stats
75
- description 'Retrieve Pulp 2 to Pulp 3 migration statistics'
76
- manual_detection
77
- end
78
-
79
- def compose
80
- if !feature(:satellite) || feature(:satellite).at_least_version?('6.9')
81
- add_step(Procedures::Content::MigrationStats)
82
- end
83
- end
84
- end
85
-
86
- class MigrationReset < ContentBase
87
- metadata do
88
- label :content_migration_reset
89
- description 'Reset the Pulp 2 to Pulp 3 migration data (pre-switchover)'
90
- manual_detection
91
- end
92
-
93
- def compose
94
- if feature(:satellite) && feature(:satellite).at_least_version?('6.9')
95
- enable_and_start_services
96
- add_step(Procedures::Content::MigrationReset)
97
- disable_and_stop_services
98
- elsif !feature(:satellite)
99
- add_step(Procedures::Content::MigrationReset)
100
- end
101
- end
102
- end
103
-
104
- class CleanupRepositoryMetadata < ContentBase
105
- metadata do
106
- label :cleanup_repository_metadata
107
- description 'Remove old leftover repository metadata'
108
- param :remove_files, 'Actually remove the files? Otherwise a dryrun is performed.'
109
-
110
- manual_detection
111
- end
112
-
113
- def compose
114
- add_step_with_context(Procedures::Pulp::CleanupOldMetadataFiles)
115
- end
116
-
117
- def set_context_mapping
118
- context.map(:remove_files, Procedures::Pulp::CleanupOldMetadataFiles => :remove_files)
119
- end
120
- end
121
-
122
- class RemovePulp2 < ContentBase
123
- metadata do
124
- label :content_remove_pulp2
125
- description 'Remove Pulp2 and mongodb packages and data'
126
- param :assumeyes, 'Do not ask for confirmation'
127
- manual_detection
128
- end
129
-
130
- def set_context_mapping
131
- context.map(:assumeyes, Procedures::Pulp::Remove => :assumeyes)
132
- context.map(:assumeyes, Procedures::Content::FixPulpcoreArtifactOwnership => :assumeyes)
133
- end
134
-
135
- def compose
136
- add_step_with_context(Procedures::Pulp::Remove)
137
- add_step_with_context(Procedures::Content::FixPulpcoreArtifactOwnership)
138
- end
139
- end
140
-
141
- class FixPulpcoreArtifactOwnership < ContentBase
142
- metadata do
143
- label :content_fix_pulpcore_artifact_ownership
144
- description 'Fix Pulpcore artifact ownership to be pulp:pulp'
145
- param :assumeyes, 'Do not ask for confirmation'
146
- manual_detection
147
- end
148
-
149
- def set_context_mapping
150
- context.map(:assumeyes, Procedures::Content::FixPulpcoreArtifactOwnership => :assumeyes)
151
- end
152
-
153
- def compose
154
- add_step_with_context(Procedures::Content::FixPulpcoreArtifactOwnership)
155
- end
156
- end
157
- end
158
- end
@@ -1,13 +0,0 @@
1
- module ForemanMaintain::Scenarios
2
- class Prep610Upgrade < ForemanMaintain::Scenario
3
- metadata do
4
- label :prep_6_10_upgrade
5
- description 'Preparations for the Satellite 6.10 upgrade'
6
- manual_detection
7
- end
8
-
9
- def compose
10
- add_step(Procedures::Prep610Upgrade)
11
- end
12
- end
13
- end