foreman_maintain 0.9.2 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/definitions/checks/foreman/check_puppet_capsules.rb +43 -0
  3. data/definitions/checks/foreman_proxy/check_tftp_storage.rb +3 -1
  4. data/definitions/checks/pulpcore/group_ownership_check.rb +18 -0
  5. data/definitions/checks/repositories/check_non_rh_repository.rb +9 -4
  6. data/definitions/checks/repositories/check_upstream_repository.rb +4 -4
  7. data/definitions/features/candlepin.rb +1 -2
  8. data/definitions/features/pulpcore.rb +2 -1
  9. data/definitions/features/upstream_repositories.rb +23 -0
  10. data/definitions/procedures/pulp/remove.rb +12 -0
  11. data/definitions/procedures/pulpcore/migrate.rb +1 -1
  12. data/definitions/procedures/puppet/remove_puppet.rb +58 -0
  13. data/definitions/procedures/puppet/remove_puppet_data.rb +21 -0
  14. data/definitions/procedures/repositories/backup_enabled_repos.rb +16 -0
  15. data/definitions/procedures/repositories/disable.rb +2 -2
  16. data/definitions/procedures/repositories/enable.rb +13 -0
  17. data/definitions/scenarios/puppet.rb +21 -0
  18. data/definitions/scenarios/restore.rb +11 -2
  19. data/definitions/scenarios/self_upgrade.rb +102 -0
  20. data/definitions/scenarios/upgrade_to_capsule_7_0.rb +89 -0
  21. data/definitions/scenarios/upgrade_to_capsule_7_0_z.rb +89 -0
  22. data/definitions/scenarios/upgrade_to_satellite_6_10.rb +1 -8
  23. data/definitions/scenarios/upgrade_to_satellite_7_0.rb +93 -0
  24. data/definitions/scenarios/upgrade_to_satellite_7_0_z.rb +90 -0
  25. data/lib/foreman_maintain/cli/plugin_command.rb +14 -0
  26. data/lib/foreman_maintain/cli/restore_command.rb +5 -1
  27. data/lib/foreman_maintain/cli/self_upgrade_command.rb +38 -0
  28. data/lib/foreman_maintain/cli.rb +4 -0
  29. data/lib/foreman_maintain/concerns/downstream.rb +57 -29
  30. data/lib/foreman_maintain/concerns/system_helpers.rb +11 -4
  31. data/lib/foreman_maintain/repository_manager/el.rb +85 -0
  32. data/lib/foreman_maintain/repository_manager.rb +13 -0
  33. data/lib/foreman_maintain/version.rb +1 -1
  34. data/lib/foreman_maintain.rb +1 -0
  35. metadata +19 -7
  36. data/definitions/features/system_repos.rb +0 -50
  37. data/lib/foreman_maintain/concerns/el_repos_manager_common.rb +0 -20
  38. data/lib/foreman_maintain/repos_manager/dnf_config_manager.rb +0 -13
  39. data/lib/foreman_maintain/repos_manager/el_common.rb +0 -0
  40. data/lib/foreman_maintain/repos_manager/yum_config_manager.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55215ac64deedb1ab1aafcef2f6b28392b48952a9f0923be2f95706aaa26d6b4
4
- data.tar.gz: 0cadfaad877d10e17658ed3650ba483a8e7b8fdd9e898d383ee3871bf88ba498
3
+ metadata.gz: 65892e9e2d93db0e9b4793b00743b75474ce7900cb425abe85e006cf7b6190ad
4
+ data.tar.gz: ee0ddd71d2dbb04805e080c60bff8a4b943122d6dd0e4c96b14401cf731fe7bf
5
5
  SHA512:
6
- metadata.gz: 1b2dbeddc647b557a0196fcea8e290e29a17e92a8ab38cee7acccbc165318bdd48cc43312232f928a30a2637dc290fd629fd07cfa27cdcb1808eb70b9903b261
7
- data.tar.gz: 7dc280857da4485c5312d7b5047a94f1e0084da1c7e798964d2d66d7068daaced1268d34fcda1033e4fd73a6bd8caec8fa6450da7e5fb52f81866abb58bc0e04
6
+ metadata.gz: df314cd4b969b7e9a71dfc3255ee6bd54ce598a42b26596ec499b866385b0838f8c455a4adc5e74acafbfd7cc733c63f072ada1d2d2af5b5473f8ba329ab77a2
7
+ data.tar.gz: 41f7380430eb839081e4fa70610b0ef87b733d08acfaa3573a8a4750d2e4880e650a91e415c4a04e4be9c28e828dd4e2c9d9245839a4891c50690247c62697a5
@@ -0,0 +1,43 @@
1
+ module Checks
2
+ class CheckPuppetCapsules < ForemanMaintain::Check
3
+ metadata do
4
+ label :puppet_capsules
5
+ for_feature :foreman_database
6
+ description 'Check for Puppet capsules from the database'
7
+ manual_detection
8
+ end
9
+
10
+ def run
11
+ puppet_proxies = find_puppet_proxies.reject { |proxy| local_proxy?(proxy['url']) }
12
+ unless puppet_proxies.empty?
13
+ names = puppet_proxies.map { |proxy| proxy['name'] }
14
+ print('You have proxies with Puppet feature enabled, '\
15
+ "please disable Puppet on all proxies first.\n"\
16
+ "The following proxies have Puppet feature: #{names.join(', ')}.")
17
+ abort!
18
+ end
19
+ end
20
+
21
+ def find_puppet_proxies
22
+ feature(:foreman_database).query(puppet_proxies_query)
23
+ end
24
+
25
+ private
26
+
27
+ def local_proxy?(url)
28
+ URI.parse(url).hostname.casecmp(hostname) == 0
29
+ end
30
+
31
+ def puppet_proxies_query
32
+ <<-SQL
33
+ SELECT \"smart_proxies\".*
34
+ FROM \"smart_proxies\"
35
+ INNER JOIN \"smart_proxy_features\"
36
+ ON \"smart_proxies\".\"id\" = \"smart_proxy_features\".\"smart_proxy_id\"
37
+ INNER JOIN \"features\"
38
+ ON \"features\".\"id\" = \"smart_proxy_features\".\"feature_id\"
39
+ WHERE \"features\".\"name\" = 'Puppet'
40
+ SQL
41
+ end
42
+ end
43
+ end
@@ -44,7 +44,9 @@ module Checks::ForemanProxy
44
44
  def self.lookup_token_duration
45
45
  data = feature(:foreman_database). \
46
46
  query("select s.value, s.default from settings s \
47
- where category = 'Setting::Provisioning' and name = 'token_duration'")
47
+ where category IN ('Setting::Provisioning','Setting') \
48
+ and name = 'token_duration'")
49
+
48
50
  YAML.load(data[0]['value'] || data[0]['default'])
49
51
  end
50
52
  end
@@ -0,0 +1,18 @@
1
+ module Checks
2
+ module Pulpcore
3
+ class GroupOwnershipCheck < ForemanMaintain::Check
4
+ metadata do
5
+ description 'Check the group owner of /var/lib/pulp/content 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/content/').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
@@ -11,13 +11,18 @@ module Checks::Repositories
11
11
 
12
12
  def run
13
13
  with_spinner('Checking repositories enabled on the system') do
14
- assert(!epel_enabled?, 'System is subscribed to non Red Hat repositories')
14
+ assert(epel_not_enabled?, 'System is subscribed to non Red Hat repositories')
15
15
  end
16
16
  end
17
17
 
18
- def epel_enabled?
19
- system_repos = execute("yum repolist enabled -d 6 -e 0| grep -E 'Repo-baseurl|Repo-id'")
20
- system_repos.to_s.match(/\bepel\b/i)
18
+ def epel_not_enabled?
19
+ system_repos = repository_manager.enabled_repos
20
+ system_repos.each do |repoid, repourl|
21
+ unless repoid.match(/\bepel\b/i).nil? || repourl.match(/\bepel\b/i).nil?
22
+ return false
23
+ end
24
+ end
25
+ true
21
26
  end
22
27
  end
23
28
  end
@@ -14,10 +14,10 @@ class Checks::CheckUpstreamRepository < ForemanMaintain::Check
14
14
 
15
15
  def run
16
16
  with_spinner('Checking for presence of upstream repositories') do
17
- enabled_upstream_repos = feature(:system_repos).upstream_repos_ids
18
- assert(enabled_upstream_repos.empty?,
19
- "System has upstream #{enabled_upstream_repos.join(',')} repositories enabled",
20
- :next_steps => Procedures::Repositories::Disable.new(:repos => enabled_upstream_repos))
17
+ enabled_repo_ids = feature(:upstream_repositories).repoids_and_urls.keys
18
+ assert(enabled_repo_ids.empty?,
19
+ "System has upstream #{enabled_repo_ids.join(',')} repositories enabled",
20
+ :next_steps => Procedures::Repositories::Disable.new(:repos => enabled_repo_ids))
21
21
  end
22
22
  end
23
23
  end
@@ -13,8 +13,7 @@ class Features::Candlepin < ForemanMaintain::Feature
13
13
 
14
14
  def services
15
15
  [
16
- system_service('tomcat', 20),
17
- system_service('tomcat6', 20)
16
+ system_service('tomcat', 20)
18
17
  ]
19
18
  end
20
19
  end
@@ -37,7 +37,8 @@ class Features::Pulpcore < ForemanMaintain::Feature
37
37
 
38
38
  def config_files
39
39
  [
40
- '/etc/pulp/settings.py'
40
+ '/etc/pulp/settings.py',
41
+ '/etc/pulp/certs/database_fields.symmetric.key'
41
42
  ]
42
43
  end
43
44
 
@@ -0,0 +1,23 @@
1
+ class Features::UpstreamRepositories < ForemanMaintain::Feature
2
+ metadata do
3
+ label :upstream_repositories
4
+ description 'Feature for operations on upstream repositories'
5
+ end
6
+
7
+ def repoids_and_urls
8
+ repoids_and_urls = {}
9
+ repository_manager.enabled_repos.each do |repo, url|
10
+ repo_urls.each do |regex|
11
+ repoids_and_urls[repo] = url if url =~ regex
12
+ end
13
+ end
14
+ repoids_and_urls
15
+ end
16
+
17
+ private
18
+
19
+ def repo_urls
20
+ [%r{yum.theforeman.org\/*},
21
+ %r{yum.puppetlabs.com\/*}]
22
+ end
23
+ end
@@ -86,6 +86,8 @@ module Procedures::Pulp
86
86
  drop_migrations
87
87
 
88
88
  delete_pulp_data(rm_cmds) if rm_cmds.any?
89
+
90
+ restart_pulpcore_services
89
91
  end
90
92
 
91
93
  def remove_pulp
@@ -168,5 +170,15 @@ module Procedures::Pulp
168
170
  spinner.update('Done deleting pulp2 data directories')
169
171
  end
170
172
  end
173
+
174
+ def restart_pulpcore_services
175
+ with_spinner('Restarting pulpcore services') do |spinner|
176
+ pulp_services = feature(:pulpcore).services
177
+
178
+ feature(:service).handle_services(spinner, 'stop', :only => pulp_services)
179
+ feature(:service).handle_services(spinner, 'start', :only => pulp_services)
180
+ spinner.update('Done restarting pulpcore services')
181
+ end
182
+ end
171
183
  end
172
184
  end
@@ -18,7 +18,7 @@ module Procedures::Pulpcore
18
18
  spinner.update('Migrating pulpcore database')
19
19
  execute!('sudo PULP_SETTINGS=/etc/pulp/settings.py '\
20
20
  'DJANGO_SETTINGS_MODULE=pulpcore.app.settings '\
21
- 'python3-django-admin migrate --noinput')
21
+ 'pulpcore-manager migrate --noinput')
22
22
  end
23
23
  end
24
24
  end
@@ -0,0 +1,58 @@
1
+ module Procedures::Puppet
2
+ class RemovePuppet < ForemanMaintain::Procedure
3
+ metadata do
4
+ description 'Remove Puppet feature'
5
+ confine do
6
+ feature(:puppet_server) &&
7
+ (check_min_version('foreman', '3.0') || check_min_version('foreman-proxy', '3.0'))
8
+ end
9
+ advanced_run false
10
+ end
11
+
12
+ def run
13
+ stop_applicable_services
14
+ if server_with_puppet? && feature(:foreman_server)
15
+ execute!('foreman-rake db:migrate VERSION=0 SCOPE=foreman_puppet')
16
+ end
17
+ feature(:installer).run(installer_arguments_disabling_puppet.join(' '), :interactive => false)
18
+ packages_action(:remove, packages_to_remove, :assumeyes => true)
19
+ end
20
+
21
+ private
22
+
23
+ def stop_applicable_services
24
+ services = []
25
+ services = feature(:foreman_server).services if feature(:foreman_server)
26
+ services << feature(:dynflow_sidekiq).services if feature(:dynflow_sidekiq)
27
+ Procedures::Service::Stop.new(:only => services) unless services.empty?
28
+ end
29
+
30
+ def server_with_puppet?
31
+ find_package(foreman_plugin_name('foreman_puppet'))
32
+ end
33
+
34
+ def installer_arguments_disabling_puppet
35
+ answers = feature(:installer).answers
36
+
37
+ options = []
38
+ options << '--no-enable-puppet' if answers.key?('puppet')
39
+ options << '--no-enable-foreman-plugin-puppet' if answers['foreman::plugin::puppet']
40
+ options << '--no-enable-foreman-cli-puppet' if answers['foreman::cli::puppet']
41
+ if answers['foreman_proxy']
42
+ options << '--foreman-proxy-puppet false'
43
+ options << '--foreman-proxy-puppetca false'
44
+ end
45
+ options << '--foreman-proxy-content-puppet false' if answers.key?('foreman_proxy_content')
46
+ options
47
+ end
48
+
49
+ def packages_to_remove
50
+ packages = ['puppetserver']
51
+ if server_with_puppet?
52
+ packages << foreman_plugin_name('foreman_puppet')
53
+ packages << hammer_plugin_name('foreman_puppet')
54
+ end
55
+ packages
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,21 @@
1
+ module Procedures::Puppet
2
+ class RemovePuppetData < ForemanMaintain::Procedure
3
+ metadata do
4
+ description 'Remove Puppet data'
5
+ end
6
+
7
+ def run
8
+ execute!('foreman-rake purge:puppet')
9
+ execute!('rm -r ' + files_to_purge.join(' '))
10
+ end
11
+
12
+ private
13
+
14
+ def files_to_purge
15
+ %w[
16
+ /etc/puppetlabs
17
+ /opt/puppetlabs/server/data
18
+ ]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
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 = repository_manager.enabled_repos.keys
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,12 +1,12 @@
1
1
  module Procedures::Repositories
2
2
  class Disable < ForemanMaintain::Procedure
3
3
  metadata do
4
- param :repos, 'List of repositories to disable'
4
+ param :repos, 'Array of repositories to disable'
5
5
  description 'Disable repositories'
6
6
  end
7
7
  def run
8
8
  with_spinner('Disabling repositories') do
9
- feature(:system_repos).disable_repos(@repos)
9
+ repository_manager.disable_repos(@repos)
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,13 @@
1
+ module Procedures::Repositories
2
+ class Enable < ForemanMaintain::Procedure
3
+ metadata do
4
+ param :repos, 'Array of repositories to enable'
5
+ description 'Enable repositories'
6
+ end
7
+ def run
8
+ with_spinner('Enabling repositories') do
9
+ repository_manager.enable_repos(@repos)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module ForemanMaintain::Scenarios
2
+ module Puppet
3
+ class RemovePuppet < ForemanMaintain::Scenario
4
+ metadata do
5
+ description 'Remove Puppet feature'
6
+ tags :puppet_disable
7
+ label :puppet_disable
8
+ param :remove_data, 'Purge the Puppet data after disabling plugin'
9
+ manual_detection
10
+ end
11
+
12
+ def compose
13
+ if check_min_version('foreman', '3.0') || check_min_version('foreman-proxy', '3.0')
14
+ add_step(Checks::CheckPuppetCapsules) if server?
15
+ add_step(Procedures::Puppet::RemovePuppet)
16
+ add_step(Procedures::Puppet::RemovePuppetData) if context.get(:remove_data)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -6,19 +6,27 @@ module ForemanMaintain::Scenarios
6
6
  description 'Restore backup'
7
7
  param :backup_dir, 'Path to backup directory'
8
8
  param :incremental_backup, 'Is the backup incremental?'
9
+ param :dry_run, 'Check if backup could be restored, without performing the restore'
9
10
  manual_detection
10
11
  end
11
12
 
12
13
  # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
14
+ # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
13
15
  def compose
14
16
  backup = ForemanMaintain::Utils::Backup.new(context.get(:backup_dir))
15
17
 
16
18
  add_steps(find_checks(:root_user))
17
19
  supported_version_check
18
20
  add_steps_with_context(Checks::Restore::ValidateBackup,
19
- Procedures::Restore::Confirmation,
20
21
  Checks::Restore::ValidateHostname,
21
- Checks::Restore::ValidateInterfaces,
22
+ Checks::Restore::ValidateInterfaces)
23
+
24
+ if context.get(:dry_run)
25
+ self.class.metadata[:run_strategy] = :fail_slow
26
+ return
27
+ end
28
+
29
+ add_steps_with_context(Procedures::Restore::Confirmation,
22
30
  Procedures::Selinux::SetFileSecurity,
23
31
  Procedures::Restore::Configs)
24
32
  add_step_with_context(Procedures::Crond::Stop) if feature(:cron)
@@ -48,6 +56,7 @@ module ForemanMaintain::Scenarios
48
56
  add_step_with_context(Procedures::Crond::Start) if feature(:cron)
49
57
  end
50
58
  # rubocop:enable Metrics/MethodLength,Metrics/AbcSize
59
+ # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
51
60
 
52
61
  def drop_dbs(backup)
53
62
  if backup.file_map[:candlepin_dump][:present] ||
@@ -0,0 +1,102 @@
1
+ module ForemanMaintain::Scenarios
2
+ class SelfUpgradeBase < ForemanMaintain::Scenario
3
+ def enabled_system_repos_id
4
+ repository_manager.enabled_repos.keys
5
+ end
6
+
7
+ def enable_repos(repo_ids = stored_enabled_repos_ids)
8
+ add_step(Procedures::Repositories::Enable.new(repos: repo_ids))
9
+ end
10
+
11
+ def disable_repos(repo_ids = stored_enabled_repos_ids)
12
+ add_step(Procedures::Repositories::Disable.new(repos: repo_ids))
13
+ end
14
+
15
+ def target_version
16
+ @target_version ||= context.get(:target_version)
17
+ end
18
+
19
+ def current_version
20
+ feature(:instance).downstream.current_minor_version
21
+ end
22
+
23
+ def maintenance_repo_id(version)
24
+ if (repo = ENV['maintenance_repo'])
25
+ return repo unless repo.empty?
26
+ end
27
+
28
+ maintenance_repo(version)
29
+ end
30
+
31
+ def maintenance_repo(version)
32
+ if el7?
33
+ "rhel-#{el_major_version}-server-satellite-maintenance-#{version}-rpms"
34
+ else
35
+ "satellite-maintenance-#{version}-for-rhel-#{el_major_version}-x86_64-rpms"
36
+ end
37
+ end
38
+
39
+ def maintenance_repo_version
40
+ return '6' if current_version == '6.10'
41
+
42
+ current_version
43
+ end
44
+
45
+ def stored_enabled_repos_ids
46
+ @stored_enabled_repos_ids ||= begin
47
+ path = File.expand_path('enabled_repos.yml', ForemanMaintain.config.backup_dir)
48
+ @stored_enabled_repos_ids = File.file?(path) ? YAML.load(File.read(path)) : []
49
+ end
50
+ end
51
+
52
+ def all_maintenance_repos
53
+ repo_regex = if el7?
54
+ /rhel-\d-server-satellite-maintenance-\d.\d-rpms/
55
+ else
56
+ /satellite-maintenance-\d.\d-for-rhel-\d-x86_64-rpms/
57
+ end
58
+ stored_enabled_repos_ids.select { |id| !id.match(repo_regex).nil? }
59
+ end
60
+
61
+ def repos_ids_to_reenable
62
+ repos_ids_to_reenable = stored_enabled_repos_ids - all_maintenance_repos
63
+ repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
64
+ end
65
+ end
66
+
67
+ class SelfUpgrade < SelfUpgradeBase
68
+ metadata do
69
+ label :self_upgrade_foreman_maintain
70
+ description "Enables the specified version's maintenance repository and, "\
71
+ 'updates the foreman-maintain packages'
72
+ manual_detection
73
+ end
74
+
75
+ def compose
76
+ if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
77
+ pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
78
+ add_step(Procedures::Repositories::BackupEnabledRepos.new)
79
+ disable_repos
80
+ add_step(Procedures::Repositories::Enable.new(repos: [maintenance_repo_id(target_version)]))
81
+ add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true))
82
+ enable_repos(repos_ids_to_reenable)
83
+ end
84
+ end
85
+ end
86
+
87
+ class SelfUpgradeRescue < SelfUpgradeBase
88
+ metadata do
89
+ label :rescue_self_upgrade
90
+ description 'Disables all version specific maintenance repos and,'\
91
+ ' enables the repositories which were configured prior to self upgrade'
92
+ manual_detection
93
+ run_strategy :fail_slow
94
+ end
95
+
96
+ def compose
97
+ if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
98
+ enable_repos(repos_ids_to_reenable)
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,89 @@
1
+ module Scenarios::Capsule_7_0
2
+ class Abstract < ForemanMaintain::Scenario
3
+ def self.upgrade_metadata(&block)
4
+ metadata do
5
+ tags :upgrade_scenario
6
+ confine do
7
+ feature(:capsule) &&
8
+ (feature(:capsule).current_minor_version == '6.10' || \
9
+ ForemanMaintain.upgrade_in_progress == '7.0')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '7.0'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Capsule 7.0'
23
+ tags :pre_upgrade_checks
24
+ run_strategy :fail_slow
25
+ end
26
+
27
+ def compose
28
+ add_steps(find_checks(:default))
29
+ add_steps(find_checks(:pre_upgrade))
30
+ add_step(Checks::Repositories::Validate.new(:version => '7.0'))
31
+ end
32
+ end
33
+
34
+ class PreMigrations < Abstract
35
+ upgrade_metadata do
36
+ description 'Procedures before migrating to Capsule 7.0'
37
+ tags :pre_migrations
38
+ end
39
+
40
+ def compose
41
+ add_steps(find_procedures(:pre_migrations))
42
+ add_step(Procedures::Service::Stop.new)
43
+ end
44
+ end
45
+
46
+ class Migrations < Abstract
47
+ upgrade_metadata do
48
+ description 'Migration scripts to Capsule 7.0'
49
+ tags :migrations
50
+ end
51
+
52
+ def set_context_mapping
53
+ context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
54
+ end
55
+
56
+ def compose
57
+ add_step(Procedures::Repositories::Setup.new(:version => '7.0'))
58
+ add_step(Procedures::Packages::UnlockVersions.new)
59
+ add_step(Procedures::Packages::Update.new(:assumeyes => true))
60
+ add_step_with_context(Procedures::Installer::Upgrade)
61
+ end
62
+ end
63
+
64
+ class PostMigrations < Abstract
65
+ upgrade_metadata do
66
+ description 'Procedures after migrating to Capsule 7.0'
67
+ tags :post_migrations
68
+ end
69
+
70
+ def compose
71
+ add_step(Procedures::RefreshFeatures)
72
+ add_step(Procedures::Service::Start.new)
73
+ add_steps(find_procedures(:post_migrations))
74
+ end
75
+ end
76
+
77
+ class PostUpgradeChecks < Abstract
78
+ upgrade_metadata do
79
+ description 'Checks after upgrading to Capsule 7.0'
80
+ tags :post_upgrade_checks
81
+ run_strategy :fail_slow
82
+ end
83
+
84
+ def compose
85
+ add_steps(find_checks(:default))
86
+ add_steps(find_checks(:post_upgrade))
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,89 @@
1
+ module Scenarios::Capsule_7_0_z
2
+ class Abstract < ForemanMaintain::Scenario
3
+ def self.upgrade_metadata(&block)
4
+ metadata do
5
+ tags :upgrade_scenario
6
+ confine do
7
+ feature(:capsule) &&
8
+ (feature(:capsule).current_minor_version == '7.0' || \
9
+ ForemanMaintain.upgrade_in_progress == '7.0.z')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '7.0.z'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Capsule 7.0.z'
23
+ tags :pre_upgrade_checks
24
+ run_strategy :fail_slow
25
+ end
26
+
27
+ def compose
28
+ add_steps(find_checks(:default))
29
+ add_steps(find_checks(:pre_upgrade))
30
+ add_step(Checks::Repositories::Validate.new(:version => '7.0'))
31
+ end
32
+ end
33
+
34
+ class PreMigrations < Abstract
35
+ upgrade_metadata do
36
+ description 'Procedures before migrating to Capsule 7.0.z'
37
+ tags :pre_migrations
38
+ end
39
+
40
+ def compose
41
+ add_steps(find_procedures(:pre_migrations))
42
+ add_step(Procedures::Service::Stop.new)
43
+ end
44
+ end
45
+
46
+ class Migrations < Abstract
47
+ upgrade_metadata do
48
+ description 'Migration scripts to Capsule 7.0.z'
49
+ tags :migrations
50
+ end
51
+
52
+ def set_context_mapping
53
+ context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
54
+ end
55
+
56
+ def compose
57
+ add_step(Procedures::Repositories::Setup.new(:version => '7.0'))
58
+ add_step(Procedures::Packages::UnlockVersions.new)
59
+ add_step(Procedures::Packages::Update.new(:assumeyes => true))
60
+ add_step_with_context(Procedures::Installer::Upgrade)
61
+ end
62
+ end
63
+
64
+ class PostMigrations < Abstract
65
+ upgrade_metadata do
66
+ description 'Procedures after migrating to Capsule 7.0.z'
67
+ tags :post_migrations
68
+ end
69
+
70
+ def compose
71
+ add_step(Procedures::RefreshFeatures)
72
+ add_step(Procedures::Service::Start.new)
73
+ add_steps(find_procedures(:post_migrations))
74
+ end
75
+ end
76
+
77
+ class PostUpgradeChecks < Abstract
78
+ upgrade_metadata do
79
+ description 'Checks after upgrading to Capsule 7.0.z'
80
+ tags :post_upgrade_checks
81
+ run_strategy :fail_slow
82
+ end
83
+
84
+ def compose
85
+ add_steps(find_checks(:default))
86
+ add_steps(find_checks(:post_upgrade))
87
+ end
88
+ end
89
+ end