foreman_maintain 0.7.8 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/definitions/checks/disk/available_space_postgresql12.rb +45 -0
  3. data/definitions/checks/non_rh_packages.rb +34 -0
  4. data/definitions/checks/services_up.rb +3 -1
  5. data/definitions/features/dynflow_sidekiq.rb +1 -1
  6. data/definitions/features/foreman_proxy.rb +5 -4
  7. data/definitions/features/katello.rb +8 -3
  8. data/definitions/features/pulp2.rb +7 -1
  9. data/definitions/features/service.rb +15 -4
  10. data/definitions/procedures/backup/pulp.rb +1 -1
  11. data/definitions/procedures/content/switchover.rb +3 -0
  12. data/definitions/procedures/prep_6_10_upgrade.rb +4 -4
  13. data/definitions/procedures/pulp/remove.rb +28 -18
  14. data/definitions/procedures/restore/regenerate_queues.rb +2 -2
  15. data/definitions/procedures/service/base.rb +1 -1
  16. data/definitions/scenarios/upgrade_to_capsule_6_10.rb +88 -0
  17. data/definitions/scenarios/upgrade_to_capsule_6_10_z.rb +88 -0
  18. data/definitions/scenarios/upgrade_to_satellite_6_10.rb +90 -0
  19. data/definitions/scenarios/upgrade_to_satellite_6_10_z.rb +89 -0
  20. data/definitions/scenarios/upgrade_to_satellite_6_8.rb +1 -0
  21. data/definitions/scenarios/upgrade_to_satellite_6_9.rb +1 -0
  22. data/lib/foreman_maintain/concerns/base_database.rb +1 -1
  23. data/lib/foreman_maintain/concerns/downstream.rb +24 -26
  24. data/lib/foreman_maintain/concerns/system_helpers.rb +25 -0
  25. data/lib/foreman_maintain/package_manager/yum.rb +8 -0
  26. data/lib/foreman_maintain/runner.rb +8 -2
  27. data/lib/foreman_maintain/utils/disk/io_device.rb +4 -0
  28. data/lib/foreman_maintain/utils/facter.rb +0 -4
  29. data/lib/foreman_maintain/version.rb +1 -1
  30. metadata +9 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae46ef9452f9bbb61d9f453a1d3aba399aa39aad83c8340ba2ba7129196eb6ec
4
- data.tar.gz: daae5660ce5a676c230b6ef4360e7341f3fdb5d82ce46cc53a0ac3596926ab94
3
+ metadata.gz: e7e6e1bff90945614408bb1ae3e73b9a12fd43d75d7d164da74c9292e87f7d56
4
+ data.tar.gz: 8f7d7d509bd2e88738a9025bd53c2a09f21933a65c4d1ce617ade128a2473542
5
5
  SHA512:
6
- metadata.gz: 62d82ea9a9d4ece0797e5872b8b0a551940864965416b23f3dfa7a7b054c68b8cd684d76f2cfd85532d6c744ab9f88942b03a8282a43aac96ae2282cb2a715ec
7
- data.tar.gz: 00f495d544d54df325d9e0541a0b206dab5fbd2a2f5930e5d17eb86173d450e92926cc41c74379fda20a878ed634c8e473abfaf440d0034ae6c0c44e50c88fe5
6
+ metadata.gz: 69b30ba9d0f4aa6bd74ac5ec609c8e6baaa26954aee7b50291c244dd90571546381ba7f929ec36466eae92a745e62f9ce5855a5f671c851b87a8cb5ecc69f82f
7
+ data.tar.gz: 76f1d2b051c4b062e1719303b0b87c450847702b4dd2c784f7afa31195886e46e6fe44a342fad9d3d3d130ac514dc4addbb9bdff32cd03fb75a165024cc9f295
@@ -0,0 +1,45 @@
1
+ module Checks
2
+ module Disk
3
+ class AvailableSpacePostgresql12 < ForemanMaintain::Check
4
+ metadata do
5
+ label :available_space_for_postgresql12
6
+ description 'Check to make sure PostgreSQL 12 work directory has enough space for upgrade'
7
+ confine do
8
+ (feature(:foreman_database) || feature(:candlepin_database)) && \
9
+ (file_exists?('/var/lib/pgsql') && \
10
+ file_exists?('/var/opt/rh/rh-postgresql12'))
11
+ end
12
+ end
13
+
14
+ def run
15
+ assert(psql_12_available_space >= psql_9_consumed_space, warning_message, :warn => true)
16
+ end
17
+
18
+ def pgsql_dir(version)
19
+ if version == 9
20
+ '/var/lib/pgsql/'
21
+ elsif version == 12
22
+ '/var/opt/rh/rh-postgresql12/'
23
+ end
24
+ end
25
+
26
+ def psql_9_consumed_space
27
+ io_obj = ForemanMaintain::Utils::Disk::IODevice.new(pgsql_dir(9))
28
+ io_obj.space_used
29
+ end
30
+
31
+ def psql_12_available_space
32
+ io_obj = ForemanMaintain::Utils::Disk::IODevice.new(pgsql_dir(12))
33
+ io_obj.available_space
34
+ end
35
+
36
+ def warning_message
37
+ sat_version = feature(:satellite).current_version.version[0..2]
38
+ "Satellite #{sat_version} uses PostgreSQL 12. \nThis changes PostgreSQL "\
39
+ "work directory to #{pgsql_dir(12)}\n"\
40
+ "The new work directory requires at least #{psql_9_consumed_space}"\
41
+ 'MiB free space for upgrade!'
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,34 @@
1
+ class Checks::NonRhPackages < ForemanMaintain::Check
2
+ metadata do
3
+ label :non_rh_packages
4
+ description 'Check if system has any non Red Hat RPMs installed (e.g.: Fedora)'
5
+ tags :pre_upgrade
6
+ confine do
7
+ feature(:instance).downstream
8
+ end
9
+ end
10
+
11
+ def run
12
+ rpm_query_format = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH} : %{VENDOR}\n'
13
+ all_packages = package_manager.list_installed_packages(rpm_query_format)
14
+ non_rh_packages = all_packages - \
15
+ all_packages.grep(Regexp.union(rh_regexp_list + ansible_runner_regexp_list))
16
+ assert(non_rh_packages.empty?, error_msg(non_rh_packages), :warn => true)
17
+ end
18
+
19
+ def error_msg(packages)
20
+ "Found #{packages.count} unexpected non Red Hat Package(s) installed!\
21
+ \nPackage : Vendor\n#{packages.join("\n")}"
22
+ end
23
+
24
+ def rh_regexp_list
25
+ [/Red Hat, Inc\./, /Red Hat Inc./, /-apache/, /-foreman-proxy/, /-foreman-client/,
26
+ /-puppet-client/, /-qpid-broker/, /-qpid-client-cert/, /-qpid-router-client/,
27
+ /-qpid-router-server/, /java-client/, /pulp-client/, /katello-default-ca/, /katello-server-ca/,
28
+ /katello-ca-consumer/, /gpg-pubkey/, /-tomcat/]
29
+ end
30
+
31
+ def ansible_runner_regexp_list
32
+ [/ansible-runner/, /[python\d]+-ansible-runner/]
33
+ end
34
+ end
@@ -6,7 +6,9 @@ class Checks::ServicesUp < ForemanMaintain::Check
6
6
  end
7
7
 
8
8
  def run
9
- failed_services = feature(:service).existing_services.reject(&:running?)
9
+ all_services = feature(:service).existing_services
10
+ failed_services = feature(:service).filter_disabled_services!('status', all_services).
11
+ reject(&:running?)
10
12
  restart_procedure = Procedures::Service::Restart.new(
11
13
  :only => failed_services,
12
14
  :wait_for_server_response => true
@@ -37,6 +37,6 @@ class Features::DynflowSidekiq < ForemanMaintain::Feature
37
37
  end
38
38
 
39
39
  def configured_instances
40
- Dir['/etc/foreman/dynflow/*'].map { |config| File.basename(config, '.yml') }
40
+ Dir['/etc/foreman/dynflow/*.yml'].map { |config| File.basename(config, '.yml') }
41
41
  end
42
42
  end
@@ -28,10 +28,11 @@ class Features::ForemanProxy < ForemanMaintain::Feature
28
28
  end
29
29
 
30
30
  def services
31
- [
32
- system_service('smart_proxy_dynflow_core', 20),
33
- system_service('foreman-proxy', 40)
34
- ]
31
+ services = [system_service('foreman-proxy', 40)]
32
+ if check_max_version('foreman-proxy', '2.4')
33
+ services << system_service('smart_proxy_dynflow_core', 20)
34
+ end
35
+ services
35
36
  end
36
37
 
37
38
  def features
@@ -16,9 +16,14 @@ class Features::Katello < ForemanMaintain::Feature
16
16
  end
17
17
 
18
18
  def services
19
- [
20
- system_service('elasticsearch', 30)
21
- ]
19
+ if feature(:pulp2)
20
+ []
21
+ else
22
+ [
23
+ system_service('qpidd', 10),
24
+ system_service('qdrouterd', 10)
25
+ ]
26
+ end
22
27
  end
23
28
 
24
29
  # rubocop:disable Metrics/MethodLength
@@ -5,7 +5,7 @@ class Features::Pulp < ForemanMaintain::Feature
5
5
  label :pulp2
6
6
 
7
7
  confine do
8
- find_package('pulp-server')
8
+ find_package('pulp-server') && !check_min_version('katello-common', '4.0')
9
9
  end
10
10
  end
11
11
 
@@ -34,4 +34,10 @@ class Features::Pulp < ForemanMaintain::Feature
34
34
  '/etc/default/pulp_workers'
35
35
  ]
36
36
  end
37
+
38
+ def exclude_from_backup
39
+ # Exclude /var/lib/pulp/katello-export and /var/lib/pulp/cache
40
+ # since the tar is run from /var/lib/pulp, list subdir paths only
41
+ ['katello-export', 'cache']
42
+ end
37
43
  end
@@ -25,9 +25,10 @@ class Features::Service < ForemanMaintain::Feature
25
25
  select(&:exist?)
26
26
  end
27
27
 
28
- def filtered_services(options)
28
+ def filtered_services(options, action = '')
29
29
  services = include_unregistered_services(existing_services, options[:include])
30
- services = filter_services(services, options)
30
+ services = filter_services(services, options, action)
31
+
31
32
  raise 'No services found matching your parameters' unless services.any?
32
33
  return services unless options[:reverse]
33
34
 
@@ -42,6 +43,13 @@ class Features::Service < ForemanMaintain::Feature
42
43
  action_word_modified(action) + 'ed'
43
44
  end
44
45
 
46
+ def filter_disabled_services!(action, service_list)
47
+ if %w[start stop restart status].include?(action)
48
+ service_list.select!(&:enabled?)
49
+ end
50
+ service_list
51
+ end
52
+
45
53
  private
46
54
 
47
55
  def use_system_service(action, options, spinner)
@@ -61,7 +69,7 @@ class Features::Service < ForemanMaintain::Feature
61
69
  def run_action_on_services(action, options, spinner)
62
70
  status = 0
63
71
  failed_services = []
64
- filtered_services(options).each_value do |group|
72
+ filtered_services(options, action).each_value do |group|
65
73
  fork_threads_for_services(action, group, spinner).each do |service, status_and_output|
66
74
  spinner.update("#{action_noun(action)} #{service}") if action == 'status'
67
75
  item_status, output = status_and_output
@@ -115,7 +123,8 @@ class Features::Service < ForemanMaintain::Feature
115
123
  service_list + socket_list
116
124
  end
117
125
 
118
- def filter_services(service_list, options)
126
+ # rubocop:disable Metrics/AbcSize
127
+ def filter_services(service_list, options, action)
119
128
  if options[:only] && options[:only].any?
120
129
  service_list = service_list.select do |service|
121
130
  options[:only].any? { |opt| service.matches?(opt) }
@@ -128,8 +137,10 @@ class Features::Service < ForemanMaintain::Feature
128
137
  end
129
138
 
130
139
  service_list = extend_service_list_with_sockets(service_list, options)
140
+ service_list = filter_disabled_services!(action, service_list)
131
141
  service_list.group_by(&:priority).to_h
132
142
  end
143
+ # rubocop:enable Metrics/AbcSize
133
144
 
134
145
  def include_unregistered_services(service_list, services_filter)
135
146
  return service_list unless services_filter
@@ -30,7 +30,7 @@ module Procedures::Backup
30
30
  feature(:tar).run(
31
31
  :archive => File.join(@backup_dir, 'pulp_data.tar'),
32
32
  :command => 'create',
33
- :exclude => ['var/lib/pulp/katello-export'],
33
+ :exclude => feature(:pulp2).exclude_from_backup,
34
34
  :listed_incremental => File.join(@backup_dir, '.pulp.snar'),
35
35
  :transform => 's,^,var/lib/pulp/,S',
36
36
  :volume_size => @tar_volume_size,
@@ -19,8 +19,11 @@ module Procedures::Content
19
19
  puts execute!('foreman-rake katello:pulp3_content_switchover')
20
20
  puts 'Re-running the installer to switch specified content over to pulp3'
21
21
  args = ['--foreman-proxy-content-proxy-pulp-isos-to-pulpcore=true',
22
+ '--foreman-proxy-content-proxy-pulp-yum-to-pulpcore=true',
23
+ '--foreman-proxy-content-proxy-pulp-deb-to-pulpcore=true',
22
24
  '--katello-use-pulp-2-for-file=false',
23
25
  '--katello-use-pulp-2-for-docker=false',
26
+ '--katello-use-pulp-2-for-deb=false',
24
27
  '--katello-use-pulp-2-for-yum=false']
25
28
  feature(:installer).run(args.join(' '))
26
29
  end
@@ -11,11 +11,11 @@ class Procedures::Prep610Upgrade < ForemanMaintain::Procedure
11
11
  def run
12
12
  puts time_warning
13
13
  with_spinner('Updating filesystem permissions for Pulp 3') do |spinner|
14
- spinner.update('$ chmod -R g+rwX /var/lib/pulp/content')
14
+ spinner.update('# chmod -R g=rwX /var/lib/pulp/content')
15
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('$ chown -R :pulp /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
19
  FileUtils.chown_R nil, 'pulp', '/var/lib/pulp/content'
20
20
  end
21
21
  end
@@ -22,26 +22,38 @@ module Procedures::Pulp
22
22
  ]
23
23
  end
24
24
 
25
+ # rubocop:disable Metrics/MethodLength
25
26
  def pulp_packages
26
- [
27
- 'pulp-server', 'python-pulp-streamer', 'pulp-puppet-plugins',
28
- 'python-pulp-rpm-common', 'python-pulp-common',
29
- 'pulp-selinux', 'python-pulp-oid_validation',
30
- 'python-pulp-puppet-common', 'python-pulp-repoauth',
31
- 'pulp-rpm-plugins', 'python-blinker', 'python-celery',
32
- 'python-django', 'python-isodate', 'python-ldap',
33
- 'python-mongoengine', 'python-nectar', 'python-oauth2',
34
- 'python-pymongo'
35
- ]
27
+ possible = %w[pulp-admin-client pulp-agent pulp-consumer-client pulp-deb-admin-extensions
28
+ pulp-deb-plugins pulp-docker-admin-extensions pulp-docker-plugins
29
+ pulp-nodes-admin-extensions pulp-nodes-child pulp-nodes-common
30
+ pulp-nodes-consumer-extensions pulp-nodes-parent pulp-ostree-admin-extensions
31
+ pulp-ostree-plugins pulp-puppet-admin-extensions
32
+ pulp-puppet-consumer-extensions pulp-puppet-handlers pulp-puppet-plugins
33
+ pulp-puppet-tools pulp-python-admin-extensions pulp-python-plugins
34
+ pulp-rpm-admin-extensions pulp-rpm-consumer-extensions pulp-rpm-handlers
35
+ pulp-rpm-plugins pulp-rpm-yumplugins pulp-selinux pulp-server python-bson
36
+ python-crane python-isodate python-mongoengine python-nectar
37
+ python-pulp-agent-lib python-pulp-bindings python-pulp-client-lib
38
+ python-pulp-common python-pulp-deb-common python-pulp-devel
39
+ python-pulp-docker-common python-pulp-integrity python-pulp-manifest
40
+ python-pulp-oid_validation python-pulp-ostree-common python-pulp-puppet-common
41
+ python-pulp-python-common python-pulp-repoauth python-pulp-rpm-common
42
+ python-pulp-streamer python-pymongo python-pymongo-gridfs python2-amqp
43
+ python2-billiard python2-celery python2-debpkgr python2-django python2-kombu
44
+ python2-solv python2-vine pulp-katello]
45
+
46
+ @installed_pulp_packages ||= possible.select { |pkg| find_package(pkg) }
47
+ @installed_pulp_packages
36
48
  end
37
49
 
38
50
  def data_dir_removal_cmds
39
- pulp_data_dirs.collect { |dir| "rm -rf #{dir}" }
51
+ pulp_data_dirs.select { |dir| File.directory?(dir) }.map { |dir| "rm -rf #{dir}" }
40
52
  end
41
53
 
42
54
  def ask_to_proceed(rm_cmds)
43
55
  question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n" \
44
- "\n# yum remove #{pulp_packages.join(' ')}" \
56
+ "\n# rpm -e #{pulp_packages.join(' ')}" \
45
57
  "\n# yum remove rh-mongodb34-*" \
46
58
  "\n\nAll pulp2 data will be removed.\n"
47
59
  question += rm_cmds.collect { |cmd| "\n# #{cmd}" }.join
@@ -52,18 +64,18 @@ module Procedures::Pulp
52
64
 
53
65
  def run
54
66
  rm_cmds = data_dir_removal_cmds
55
- ask_to_proceed(rm_cmds)
67
+ ask_to_proceed(rm_cmds) if rm_cmds.any?
56
68
 
57
69
  remove_pulp
58
70
 
59
71
  remove_mongo
60
72
 
61
- delete_pulp_data(rm_cmds)
73
+ delete_pulp_data(rm_cmds) if rm_cmds.any?
62
74
  end
63
75
 
64
76
  def remove_pulp
65
77
  with_spinner('Removing pulp2 packages') do
66
- packages_action(:remove, pulp_packages, :assumeyes => true)
78
+ execute!("rpm -e #{pulp_packages.join(' ')}")
67
79
  end
68
80
  end
69
81
 
@@ -76,9 +88,7 @@ module Procedures::Pulp
76
88
  def delete_pulp_data(rm_cmds)
77
89
  with_spinner('Deleting pulp2 data directories') do |spinner|
78
90
  rm_cmds.each do |cmd|
79
- if File.directory?(cmd.split[2])
80
- execute!(cmd)
81
- end
91
+ execute!(cmd)
82
92
  end
83
93
  spinner.update('Done deleting pulp2 data directories')
84
94
  end
@@ -2,7 +2,7 @@ module Procedures::Restore
2
2
  class RegenerateQueues < ForemanMaintain::Procedure
3
3
  metadata do
4
4
  advanced_run false
5
- description 'Regenerate required activemq and qpidd queues while restoring online backup'
5
+ description 'Regenerate required activemq and/or qpidd queues while restoring online backup'
6
6
  confine do
7
7
  feature(:pulp2)
8
8
  end
@@ -31,7 +31,7 @@ module Procedures::Restore
31
31
 
32
32
  def run
33
33
  with_spinner('Resetting the queues') do |spinner|
34
- regenerate_activemq_queues(spinner)
34
+ regenerate_activemq_queues(spinner) if feature(:candlepin)
35
35
  regenerate_qpidd_queues(spinner)
36
36
  spinner.update('Queues created successfully')
37
37
  end
@@ -16,7 +16,7 @@ module Procedures
16
16
  def run_service_action(action, options)
17
17
  action_noun = feature(:service).action_noun(action).capitalize
18
18
  puts "\n#{action_noun} the following service(s):"
19
- services = feature(:service).filtered_services(options)
19
+ services = feature(:service).filtered_services(options, action)
20
20
  print_services(services)
21
21
  with_spinner('') do |spinner|
22
22
  feature(:service).handle_services(spinner, action, options)
@@ -0,0 +1,88 @@
1
+ module Scenarios::Capsule_6_10
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.9' || \
9
+ ForemanMaintain.upgrade_in_progress == '6.10')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '6.10'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Capsule 6.10'
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 => '6.10'))
31
+ end
32
+ end
33
+
34
+ class PreMigrations < Abstract
35
+ upgrade_metadata do
36
+ description 'Procedures before migrating to Capsule 6.10'
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 6.10'
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 => '6.10'))
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 6.10'
67
+ tags :post_migrations
68
+ end
69
+
70
+ def compose
71
+ add_step(Procedures::Service::Start.new)
72
+ add_steps(find_procedures(:post_migrations))
73
+ end
74
+ end
75
+
76
+ class PostUpgradeChecks < Abstract
77
+ upgrade_metadata do
78
+ description 'Checks after upgrading to Capsule 6.10'
79
+ tags :post_upgrade_checks
80
+ run_strategy :fail_slow
81
+ end
82
+
83
+ def compose
84
+ add_steps(find_checks(:default))
85
+ add_steps(find_checks(:post_upgrade))
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,88 @@
1
+ module Scenarios::Capsule_6_10_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 == '6.10' || \
9
+ ForemanMaintain.upgrade_in_progress == '6.10.z')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '6.10.z'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Capsule 6.10.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 => '6.10'))
31
+ end
32
+ end
33
+
34
+ class PreMigrations < Abstract
35
+ upgrade_metadata do
36
+ description 'Procedures before migrating to Capsule 6.10.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 6.10.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 => '6.10'))
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 6.10.z'
67
+ tags :post_migrations
68
+ end
69
+
70
+ def compose
71
+ add_step(Procedures::Service::Start.new)
72
+ add_steps(find_procedures(:post_migrations))
73
+ end
74
+ end
75
+
76
+ class PostUpgradeChecks < Abstract
77
+ upgrade_metadata do
78
+ description 'Checks after upgrading to Capsule 6.10.z'
79
+ tags :post_upgrade_checks
80
+ run_strategy :fail_slow
81
+ end
82
+
83
+ def compose
84
+ add_steps(find_checks(:default))
85
+ add_steps(find_checks(:post_upgrade))
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,90 @@
1
+ module Scenarios::Satellite_6_10
2
+ class Abstract < ForemanMaintain::Scenario
3
+ def self.upgrade_metadata(&block)
4
+ metadata do
5
+ tags :upgrade_scenario
6
+ confine do
7
+ feature(:satellite) &&
8
+ (feature(:satellite).current_minor_version == '6.9' || \
9
+ ForemanMaintain.upgrade_in_progress == '6.10')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '6.10'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Satellite 6.10'
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::Foreman::CheckpointSegments)
31
+ add_step(Checks::Repositories::Validate.new(:version => '6.10'))
32
+ end
33
+ end
34
+
35
+ class PreMigrations < Abstract
36
+ upgrade_metadata do
37
+ description 'Procedures before migrating to Satellite 6.10'
38
+ tags :pre_migrations
39
+ end
40
+
41
+ def compose
42
+ add_steps(find_procedures(:pre_migrations))
43
+ add_step(Procedures::Service::Stop.new)
44
+ end
45
+ end
46
+
47
+ class Migrations < Abstract
48
+ upgrade_metadata do
49
+ description 'Migration scripts to Satellite 6.10'
50
+ tags :migrations
51
+ end
52
+
53
+ def set_context_mapping
54
+ context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
55
+ end
56
+
57
+ def compose
58
+ add_step(Procedures::Repositories::Setup.new(:version => '6.10'))
59
+ add_step(Procedures::Packages::UnlockVersions.new)
60
+ add_step(Procedures::Packages::Update.new(:assumeyes => true))
61
+ add_step_with_context(Procedures::Installer::Upgrade)
62
+ add_step(Procedures::Installer::UpgradeRakeTask)
63
+ end
64
+ end
65
+
66
+ class PostMigrations < Abstract
67
+ upgrade_metadata do
68
+ description 'Procedures after migrating to Satellite 6.10'
69
+ tags :post_migrations
70
+ end
71
+
72
+ def compose
73
+ add_step(Procedures::Service::Start.new)
74
+ add_steps(find_procedures(:post_migrations))
75
+ end
76
+ end
77
+
78
+ class PostUpgradeChecks < Abstract
79
+ upgrade_metadata do
80
+ description 'Checks after upgrading to Satellite 6.10'
81
+ tags :post_upgrade_checks
82
+ run_strategy :fail_slow
83
+ end
84
+
85
+ def compose
86
+ add_steps(find_checks(:default))
87
+ add_steps(find_checks(:post_upgrade))
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,89 @@
1
+ module Scenarios::Satellite_6_10_z
2
+ class Abstract < ForemanMaintain::Scenario
3
+ def self.upgrade_metadata(&block)
4
+ metadata do
5
+ tags :upgrade_scenario
6
+ confine do
7
+ feature(:satellite) &&
8
+ (feature(:satellite).current_minor_version == '6.10' || \
9
+ ForemanMaintain.upgrade_in_progress == '6.10.z')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '6.10.z'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Satellite 6.10.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 => '6.10'))
31
+ end
32
+ end
33
+
34
+ class PreMigrations < Abstract
35
+ upgrade_metadata do
36
+ description 'Procedures before migrating to Satellite 6.10.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 Satellite 6.10.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 => '6.10'))
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
+ add_step(Procedures::Installer::UpgradeRakeTask)
62
+ end
63
+ end
64
+
65
+ class PostMigrations < Abstract
66
+ upgrade_metadata do
67
+ description 'Procedures after migrating to Satellite 6.10.z'
68
+ tags :post_migrations
69
+ end
70
+
71
+ def compose
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 Satellite 6.10.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
@@ -28,6 +28,7 @@ module Scenarios::Satellite_6_8
28
28
  add_steps(find_checks(:default))
29
29
  add_steps(find_checks(:pre_upgrade))
30
30
  add_step(Checks::Foreman::CheckpointSegments)
31
+ add_step(Checks::Disk::AvailableSpacePostgresql12)
31
32
  add_step(Checks::Repositories::Validate.new(:version => '6.8'))
32
33
  end
33
34
  end
@@ -28,6 +28,7 @@ module Scenarios::Satellite_6_9
28
28
  add_steps(find_checks(:default))
29
29
  add_steps(find_checks(:pre_upgrade))
30
30
  add_step(Checks::Foreman::CheckpointSegments)
31
+ add_step(Checks::Disk::AvailableSpacePostgresql12)
31
32
  add_step(Checks::Repositories::Validate.new(:version => '6.9'))
32
33
  end
33
34
  end
@@ -2,7 +2,7 @@ module ForemanMaintain
2
2
  module Concerns
3
3
  module BaseDatabase
4
4
  def data_dir
5
- if check_min_version('foreman', '2.0')
5
+ if el7? && check_min_version('foreman', '2.0')
6
6
  '/var/opt/rh/rh-postgresql12/lib/pgsql/data/'
7
7
  else
8
8
  '/var/lib/pgsql/data/'
@@ -62,53 +62,51 @@ module ForemanMaintain
62
62
 
63
63
  def rh_repos(server_version)
64
64
  server_version = version(server_version)
65
- rh_version_major = ForemanMaintain::Utils::Facter.os_major_release
66
- rh_repos = main_rh_repos(rh_version_major)
67
-
65
+ rh_repos = main_rh_repos
68
66
  server_version_full = "#{server_version.major}.#{server_version.minor}"
69
- rh_repos.concat(product_specific_repos(rh_version_major, server_version_full))
70
-
67
+ rh_repos.concat(product_specific_repos(server_version_full))
71
68
  if server_version > version('6.3')
72
- rh_repos << ansible_repo(server_version, rh_version_major)
69
+ rh_repos << ansible_repo(server_version)
73
70
  end
74
71
 
75
72
  rh_repos
76
73
  end
77
74
 
78
- def ansible_repo(server_version, rh_version_major)
75
+ def ansible_repo(server_version)
79
76
  if server_version >= version('6.8')
80
- "rhel-#{rh_version_major}-server-ansible-2.9-rpms"
77
+ "rhel-#{el_major_version}-server-ansible-2.9-rpms"
81
78
  elsif server_version >= version('6.6')
82
- "rhel-#{rh_version_major}-server-ansible-2.8-rpms"
79
+ "rhel-#{el_major_version}-server-ansible-2.8-rpms"
83
80
  elsif server_version >= version('6.4')
84
- "rhel-#{rh_version_major}-server-ansible-2.6-rpms"
81
+ "rhel-#{el_major_version}-server-ansible-2.6-rpms"
85
82
  end
86
83
  end
87
84
 
88
- # TODO: refactoring
89
- def product_specific_repos(rh_version_major, full_version)
85
+ def product_specific_repos(full_version)
90
86
  repos = []
91
87
  repos << if ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
92
- "rhel-server-#{rh_version_major}-#{package_name}-6-beta-rpms"
88
+ "rhel-server-#{el_major_version}-#{package_name}-6-beta-rpms"
93
89
  else
94
- "rhel-#{rh_version_major}-server-#{package_name}-#{full_version}-rpms"
90
+ "rhel-#{el_major_version}-server-#{package_name}-#{full_version}-rpms"
95
91
  end
92
+ repos << puppet4_repo(full_version) unless puppet4_repo(full_version).nil?
93
+ repos.concat(common_repos(full_version))
94
+ end
95
+
96
+ def puppet4_repo(full_version)
96
97
  if current_minor_version == '6.3' && full_version.to_s != '6.4' && (
97
98
  feature(:puppet_server) && feature(:puppet_server).puppet_version.major == 4)
98
- # TODO: confirm repo for capsule. It might be same repo
99
- repos << "rhel-#{rh_version_major}-server-satellite-tools-6.3-puppet4-rpms"
99
+ "rhel-#{el_major_version}-server-#{package_name}-tools-6.3-puppet4-rpms"
100
100
  end
101
-
102
- repos.concat(common_repos(rh_version_major, full_version))
103
101
  end
104
102
 
105
- def common_repos(rh_version_major, full_version)
103
+ def common_repos(full_version)
106
104
  repos_arrary = if ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
107
- ["rhel-#{rh_version_major}-server-satellite-maintenance-6-beta-rpms",
108
- "rhel-#{rh_version_major}-server-satellite-tools-6-beta-rpms"]
105
+ ["rhel-#{el_major_version}-server-satellite-maintenance-6-beta-rpms",
106
+ "rhel-#{el_major_version}-server-satellite-tools-6-beta-rpms"]
109
107
  else
110
- ["rhel-#{rh_version_major}-server-satellite-maintenance-6-rpms",
111
- "rhel-#{rh_version_major}-server-satellite-tools-#{full_version}-rpms"]
108
+ ["rhel-#{el_major_version}-server-satellite-maintenance-6-rpms",
109
+ "rhel-#{el_major_version}-server-satellite-tools-#{full_version}-rpms"]
112
110
  end
113
111
 
114
112
  return repos_arrary.first(1) if feature(:satellite)
@@ -116,9 +114,9 @@ module ForemanMaintain
116
114
  repos_arrary
117
115
  end
118
116
 
119
- def main_rh_repos(rh_version_major)
120
- ["rhel-#{rh_version_major}-server-rpms",
121
- "rhel-server-rhscl-#{rh_version_major}-rpms"]
117
+ def main_rh_repos
118
+ ["rhel-#{el_major_version}-server-rpms",
119
+ "rhel-server-rhscl-#{el_major_version}-rpms"]
122
120
  end
123
121
 
124
122
  def version_from_source
@@ -192,6 +192,31 @@ module ForemanMaintain
192
192
  yield current_version
193
193
  end
194
194
  end
195
+
196
+ def os_facts
197
+ facter = ForemanMaintain::Utils::Facter.path
198
+ @os_facts ||= JSON.parse(execute("#{facter} -j os"))
199
+ end
200
+
201
+ def el?
202
+ os_facts['os']['family'] == 'RedHat'
203
+ end
204
+
205
+ def debian?
206
+ os_facts['os']['family'] == 'Debian'
207
+ end
208
+
209
+ def el7?
210
+ os_facts['os']['release']['major'] = '7' && el?
211
+ end
212
+
213
+ def el8?
214
+ os_facts['os']['release']['major'] = '8' && el?
215
+ end
216
+
217
+ def el_major_version
218
+ return os_facts['os']['release']['major'] if el?
219
+ end
195
220
  end
196
221
  end
197
222
  end
@@ -71,6 +71,14 @@ module ForemanMaintain::PackageManager
71
71
  sys.execute(find_cmd).split("\n")
72
72
  end
73
73
 
74
+ def list_installed_packages(queryfm = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
75
+ # The queryfm should only include valid tag(s) as per `rpm --querytag` list.
76
+ # If any special formatting is required with querytag then it should be provided with tag i.e,
77
+ # querytag = "--%{VENDOR}"
78
+ # The queryfm string must end with '\n'
79
+ sys.execute!("rpm -qa --qf '#{queryfm}'").split("\n")
80
+ end
81
+
74
82
  private
75
83
 
76
84
  def protector_config
@@ -15,6 +15,7 @@ module ForemanMaintain
15
15
  @reporter = reporter
16
16
  @scenarios = Array(scenarios)
17
17
  @quit = false
18
+ @rescue = false
18
19
  @last_scenario = nil
19
20
  @last_scenario_continuation_confirmed = false
20
21
  @exit_code = 0
@@ -29,12 +30,17 @@ module ForemanMaintain
29
30
  @assumeyes
30
31
  end
31
32
 
33
+ def rescue?
34
+ @rescue
35
+ end
36
+
32
37
  def run
33
38
  @scenarios.each do |scenario|
34
39
  run_scenario(scenario)
35
40
  next unless @quit
36
41
 
37
42
  if @rescue_scenario
43
+ @rescue = true
38
44
  logger.debug('=== Rescue scenario found. Executing ===')
39
45
  execute_scenario_steps(@rescue_scenario, true)
40
46
  end
@@ -44,10 +50,10 @@ module ForemanMaintain
44
50
 
45
51
  def run_scenario(scenario)
46
52
  return if scenario.steps.empty?
47
- raise 'The runner is already in quit state' if quit?
53
+ raise 'The runner is already in quit state' if quit? && !rescue?
48
54
 
49
55
  confirm_scenario(scenario)
50
- return if quit?
56
+ return if quit? && !rescue?
51
57
 
52
58
  execute_scenario_steps(scenario)
53
59
  ensure
@@ -26,6 +26,10 @@ module ForemanMaintain
26
26
  execute!("df #{dir}|awk {'print $5'}|tail -1").to_i
27
27
  end
28
28
 
29
+ def space_used
30
+ convert_kb_to_mb(execute!("du -ks #{dir} | awk {'print $1'}").to_i)
31
+ end
32
+
29
33
  private
30
34
 
31
35
  # In fio command, --direct option bypass the cache page
@@ -13,9 +13,5 @@ module ForemanMaintain::Utils
13
13
  def self.path
14
14
  FACTER_FILES.find { |path| File.exist?(path) }
15
15
  end
16
-
17
- def self.os_major_release
18
- execute!("#{path} operatingsystemmajrelease")
19
- end
20
16
  end
21
17
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.7.8'.freeze
2
+ VERSION = '0.8.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -126,6 +126,7 @@ files:
126
126
  - definitions/checks/check_tmout.rb
127
127
  - definitions/checks/disk/available_space.rb
128
128
  - definitions/checks/disk/available_space_candlepin.rb
129
+ - definitions/checks/disk/available_space_postgresql12.rb
129
130
  - definitions/checks/disk/performance.rb
130
131
  - definitions/checks/env_proxy.rb
131
132
  - definitions/checks/foreman/check_checkpoint_segments.rb
@@ -147,6 +148,7 @@ files:
147
148
  - definitions/checks/maintenance_mode/check_consistency.rb
148
149
  - definitions/checks/mongo/db_up.rb
149
150
  - definitions/checks/mongo/tools_installed.rb
151
+ - definitions/checks/non_rh_packages.rb
150
152
  - definitions/checks/original_assets.rb
151
153
  - definitions/checks/package_manager/yum/validate_yum_config.rb
152
154
  - definitions/checks/pulpcore/db_up.rb
@@ -298,10 +300,14 @@ files:
298
300
  - definitions/scenarios/prep_6_10_upgrade.rb
299
301
  - definitions/scenarios/restore.rb
300
302
  - definitions/scenarios/services.rb
303
+ - definitions/scenarios/upgrade_to_capsule_6_10.rb
304
+ - definitions/scenarios/upgrade_to_capsule_6_10_z.rb
301
305
  - definitions/scenarios/upgrade_to_capsule_6_8.rb
302
306
  - definitions/scenarios/upgrade_to_capsule_6_8_z.rb
303
307
  - definitions/scenarios/upgrade_to_capsule_6_9.rb
304
308
  - definitions/scenarios/upgrade_to_capsule_6_9_z.rb
309
+ - definitions/scenarios/upgrade_to_satellite_6_10.rb
310
+ - definitions/scenarios/upgrade_to_satellite_6_10_z.rb
305
311
  - definitions/scenarios/upgrade_to_satellite_6_2.rb
306
312
  - definitions/scenarios/upgrade_to_satellite_6_2_z.rb
307
313
  - definitions/scenarios/upgrade_to_satellite_6_3.rb
@@ -418,7 +424,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
424
  - !ruby/object:Gem::Version
419
425
  version: '0'
420
426
  requirements: []
421
- rubygems_version: 3.2.3
427
+ rubygems_version: 3.0.9
422
428
  signing_key:
423
429
  specification_version: 4
424
430
  summary: Foreman maintenance tool belt