foreman_maintain 0.8.21 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/definitions/checks/foreman/check_puppet_capsules.rb +43 -0
  3. data/definitions/checks/pulpcore/group_ownership_check.rb +18 -0
  4. data/definitions/checks/repositories/validate.rb +1 -2
  5. data/definitions/checks/restore/validate_interfaces.rb +24 -0
  6. data/definitions/features/candlepin.rb +1 -2
  7. data/definitions/features/pulpcore.rb +2 -1
  8. data/definitions/features/system_repos.rb +8 -0
  9. data/definitions/procedures/backup/metadata.rb +11 -0
  10. data/definitions/procedures/installer/upgrade_rake_task.rb +3 -1
  11. data/definitions/procedures/pulpcore/migrate.rb +1 -1
  12. data/definitions/procedures/puppet/remove_puppet.rb +50 -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/enable.rb +13 -0
  16. data/definitions/procedures/repositories/setup.rb +0 -4
  17. data/definitions/procedures/restore/configs.rb +5 -1
  18. data/definitions/scenarios/puppet.rb +21 -0
  19. data/definitions/scenarios/restore.rb +14 -1
  20. data/definitions/scenarios/self_upgrade.rb +102 -0
  21. data/definitions/scenarios/upgrade_to_capsule_7_0.rb +89 -0
  22. data/definitions/scenarios/upgrade_to_capsule_7_0_z.rb +89 -0
  23. data/definitions/scenarios/upgrade_to_satellite_6_10.rb +1 -8
  24. data/definitions/scenarios/upgrade_to_satellite_7_0.rb +93 -0
  25. data/definitions/scenarios/upgrade_to_satellite_7_0_z.rb +90 -0
  26. data/lib/foreman_maintain/cli/plugin_command.rb +14 -0
  27. data/lib/foreman_maintain/cli/restore_command.rb +5 -1
  28. data/lib/foreman_maintain/cli/self_upgrade_command.rb +38 -0
  29. data/lib/foreman_maintain/cli.rb +4 -0
  30. data/lib/foreman_maintain/concerns/downstream.rb +50 -22
  31. data/lib/foreman_maintain/concerns/os_facts.rb +70 -0
  32. data/lib/foreman_maintain/concerns/system_helpers.rb +12 -33
  33. data/lib/foreman_maintain/utils/backup.rb +36 -11
  34. data/lib/foreman_maintain/utils.rb +0 -1
  35. data/lib/foreman_maintain/version.rb +1 -1
  36. data/lib/foreman_maintain.rb +1 -0
  37. metadata +36 -11
  38. data/lib/foreman_maintain/concerns/el_repos_manager_common.rb +0 -20
  39. data/lib/foreman_maintain/repos_manager/dnf_config_manager.rb +0 -13
  40. data/lib/foreman_maintain/repos_manager/el_common.rb +0 -0
  41. data/lib/foreman_maintain/repos_manager/yum_config_manager.rb +0 -20
  42. data/lib/foreman_maintain/utils/facter.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34a580f07f36c4c9ab021f465d02b0430ac81a444765f2793a7940d18182ce25
4
- data.tar.gz: ef70e629eec6f635d2515b9eea748567c2d3e559fc762a3005a0ab9a85d7e61b
3
+ metadata.gz: bc78f39bf65ff7aa89be6ba1dda201de03f6d9a4b637599e5afd3d489ac4495d
4
+ data.tar.gz: 5554b12a68af2a4710ef7725d39079fbe7452b280b40b9ebfe0bd23cad058f40
5
5
  SHA512:
6
- metadata.gz: '0797ffb2141b60a5811f62dcdddb2d600221c22df75868674a4628838a445836058b003d67296bc91a2bc4593f06dbe4bcd1223417263fb9335d4bb141dc8c14'
7
- data.tar.gz: a40dd53e0d8633bd01301e2b85b2d38cf62d8ca0ab502c9c3747939d5a7b38f3fc90fc6b8f861ec956846660ab6ac0a22e2c257e3c07c3963fec945ee03cadde
6
+ metadata.gz: d68910821f5bcbdc2267d7fa5201fe348b4f32af27531d15a621567aaef88dc52bfdc17e3fcaf6ec70899514c103d501b785edd2cb6c9100bb50762b7050236e
7
+ data.tar.gz: bede7c7b5521c991a83ca714fbdc10bee1df94d992daa4d54c142a51717bfae130f2e5ddf4b789f5c34274a0eb766fed0d62b0bd1f09017c14c0a9378402307c
@@ -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
@@ -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 directory'
6
+ label :group_ownership_check_of_pulp_content
7
+ manual_detection
8
+ end
9
+
10
+ def run
11
+ group_id = File.stat('/var/lib/pulp/').gid
12
+ if Etc.getgrgid(group_id).name != 'pulp'
13
+ fail! "Please run 'foreman-maintain prep-6.10-upgrade' prior to upgrading."
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -3,8 +3,7 @@ module Checks::Repositories
3
3
  metadata do
4
4
  description 'Validate availability of repositories'
5
5
  preparation_steps do
6
- [Checks::Repositories::CheckNonRhRepository.new,
7
- Procedures::Packages::Install.new(:packages => [ForemanMaintain::Utils::Facter.package])]
6
+ Checks::Repositories::CheckNonRhRepository.new
8
7
  end
9
8
 
10
9
  confine do
@@ -0,0 +1,24 @@
1
+ require 'foreman_maintain/utils/backup'
2
+
3
+ module Checks::Restore
4
+ class ValidateInterfaces < ForemanMaintain::Check
5
+ metadata do
6
+ description 'Validate network interfaces match the backup'
7
+
8
+ param :backup_dir,
9
+ 'Path to backup directory',
10
+ :required => true
11
+ manual_detection
12
+ end
13
+
14
+ def run
15
+ backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
16
+ invalid_interfaces = backup.validate_interfaces
17
+ msg = 'The following features are enabled in the backup, '\
18
+ "\nbut the system does not have the interfaces used by these features: "
19
+ msg << invalid_interfaces.map { |k, v| "#{k} (#{v['configured']})" }.join(', ')
20
+ msg << '.'
21
+ assert(backup.validate_interfaces.empty?, msg)
22
+ end
23
+ end
24
+ end
@@ -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
 
@@ -21,6 +21,10 @@ class Features::SystemRepos < ForemanMaintain::Feature
21
21
  Hash[*repos.delete!(' ').split("\n")]
22
22
  end
23
23
 
24
+ def enabled_repos_ids
25
+ trim_repoids(enabled_repos_hash.keys)
26
+ end
27
+
24
28
  def upstream_repos_ids
25
29
  trim_repoids(upstream_repos.keys)
26
30
  end
@@ -29,6 +33,10 @@ class Features::SystemRepos < ForemanMaintain::Feature
29
33
  execute!("yum-config-manager --disable #{repo_ids.join(',')}")
30
34
  end
31
35
 
36
+ def enable_repos(repo_ids)
37
+ execute!("yum-config-manager --enable #{repo_ids.join(',')}")
38
+ end
39
+
32
40
  private
33
41
 
34
42
  def trim_repoids(repos)
@@ -9,6 +9,8 @@ module Procedures::Backup
9
9
  param :online_backup, 'Select for online backup', :flag => true, :default => false
10
10
  end
11
11
 
12
+ PROXY_CONFIG_ENTRIES = %w[dns dns_interface dhcp dhcp_interface].freeze
13
+
12
14
  def run
13
15
  with_spinner('Collecting metadata') do |spinner|
14
16
  metadata = {}
@@ -18,6 +20,8 @@ module Procedures::Backup
18
20
  metadata['rpms'] = rpms(spinner)
19
21
  metadata['incremental'] = @incremental_dir || false
20
22
  metadata['online'] = @online_backup
23
+ metadata['hostname'] = hostname
24
+ metadata['proxy_config'] = proxy_config(spinner)
21
25
  save_metadata(metadata, spinner)
22
26
  end
23
27
  end
@@ -54,5 +58,12 @@ module Procedures::Backup
54
58
  feature(:foreman_proxy).features
55
59
  end
56
60
  end
61
+
62
+ def proxy_config(spinner)
63
+ spinner.update('Collecting proxy configuration')
64
+ feature(:installer).answers['foreman_proxy'].select do |key, _|
65
+ PROXY_CONFIG_ENTRIES.include?(key)
66
+ end
67
+ end
57
68
  end
58
69
  end
@@ -5,7 +5,9 @@ module Procedures::Installer
5
5
  end
6
6
 
7
7
  def run
8
- execute!('foreman-rake upgrade:run')
8
+ # only run this in the Satellite scenario, as in others
9
+ # the installer runs this rake task for us already
10
+ execute!('foreman-rake upgrade:run') if feature(:satellite)
9
11
  end
10
12
  end
11
13
  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,50 @@
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
+ services = feature(:foreman_server).services + feature(:dynflow_sidekiq).services
14
+ Procedures::Service::Stop.new(:only => services)
15
+ execute!('foreman-rake db:migrate VERSION=0 SCOPE=foreman_puppet') if server_with_puppet?
16
+ feature(:installer).run(installer_arguments_disabling_puppet.join(' '), :interactive => false)
17
+ packages_action(:remove, packages_to_remove, :assumeyes => true)
18
+ end
19
+
20
+ private
21
+
22
+ def server_with_puppet?
23
+ find_package(foreman_plugin_name('foreman_puppet'))
24
+ end
25
+
26
+ def installer_arguments_disabling_puppet
27
+ answers = feature(:installer).answers
28
+
29
+ options = []
30
+ options << '--no-enable-puppet' if answers.key?('puppet')
31
+ options << '--no-enable-foreman-plugin-puppet' if answers['foreman::plugin::puppet']
32
+ options << '--no-enable-foreman-cli-puppet' if answers['foreman::cli::puppet']
33
+ if answers['foreman_proxy']
34
+ options << '--foreman-proxy-puppet false'
35
+ options << '--foreman-proxy-puppetca false'
36
+ end
37
+ options << '--foreman-proxy-content-puppet false' if answers.key?('foreman_proxy_content')
38
+ options
39
+ end
40
+
41
+ def packages_to_remove
42
+ packages = ['puppetserver']
43
+ if server_with_puppet?
44
+ packages << foreman_plugin_name('foreman_puppet')
45
+ packages << hammer_plugin_name('foreman_puppet')
46
+ end
47
+ packages
48
+ end
49
+ end
50
+ 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 = feature(:system_repos).enabled_repos_ids
10
+ unless enabled_repos_ids.empty?
11
+ backup_dir = File.expand_path(ForemanMaintain.config.backup_dir)
12
+ File.write(File.join(backup_dir, 'enabled_repos.yml'), enabled_repos_ids.to_yaml)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module Procedures::Repositories
2
+ class Enable < ForemanMaintain::Procedure
3
+ metadata do
4
+ param :repos, 'List of repositories to enable'
5
+ description 'Enable repositories'
6
+ end
7
+ def run
8
+ with_spinner('Enabling repositories') do
9
+ feature(:system_repos).enable_repos(@repos)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,10 +2,6 @@ module Procedures::Repositories
2
2
  class Setup < ForemanMaintain::Procedure
3
3
  metadata do
4
4
  description 'Setup repositories'
5
- preparation_steps do
6
- Procedures::Packages::Install.new(:packages => [ForemanMaintain::Utils::Facter.package])
7
- end
8
-
9
5
  confine do
10
6
  feature(:instance).downstream || feature(:upstream)
11
7
  end
@@ -56,7 +56,11 @@ module Procedures::Restore
56
56
  def reset_qpid_jrnls
57
57
  # on restore without pulp data qpid fails to start
58
58
  # https://access.redhat.com/solutions/4645231
59
- execute('rm -rf /var/lib/qpidd/.qpidd/qls/dat2/__db.00*')
59
+ ['/var/lib/qpidd/.qpidd/', '/var/lib/qpidd/'].each do |qpidd_path|
60
+ if Dir.exist?("#{qpidd_path}/qls/dat2/")
61
+ execute("rm -rf #{qpidd_path}/qls/dat2/__db.00*")
62
+ end
63
+ end
60
64
  end
61
65
  end
62
66
  end
@@ -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,18 +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,
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,
21
30
  Procedures::Selinux::SetFileSecurity,
22
31
  Procedures::Restore::Configs)
23
32
  add_step_with_context(Procedures::Crond::Stop) if feature(:cron)
@@ -42,9 +51,12 @@ module ForemanMaintain::Scenarios
42
51
  add_steps_with_context(Procedures::Restore::RegenerateQueues) if backup.online_backup?
43
52
  add_steps_with_context(Procedures::Service::Start,
44
53
  Procedures::Service::DaemonReload)
54
+ add_step(Procedures::Installer::Upgrade.new(:assumeyes => true))
55
+ add_step_with_context(Procedures::Installer::UpgradeRakeTask)
45
56
  add_step_with_context(Procedures::Crond::Start) if feature(:cron)
46
57
  end
47
58
  # rubocop:enable Metrics/MethodLength,Metrics/AbcSize
59
+ # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
48
60
 
49
61
  def drop_dbs(backup)
50
62
  if backup.file_map[:candlepin_dump][:present] ||
@@ -87,6 +99,7 @@ module ForemanMaintain::Scenarios
87
99
  context.map(:backup_dir,
88
100
  Checks::Restore::ValidateBackup => :backup_dir,
89
101
  Checks::Restore::ValidateHostname => :backup_dir,
102
+ Checks::Restore::ValidateInterfaces => :backup_dir,
90
103
  Procedures::Restore::Configs => :backup_dir,
91
104
  Procedures::Restore::DropDatabases => :backup_dir,
92
105
  Procedures::Restore::PgGlobalObjects => :backup_dir,
@@ -0,0 +1,102 @@
1
+ module ForemanMaintain::Scenarios
2
+ class SelfUpgradeBase < ForemanMaintain::Scenario
3
+ def enabled_system_repos_id
4
+ feature(:system_repos).enabled_repos_ids
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