foreman_maintain 0.8.6 → 0.8.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5d17c606d64e5edab8bcbf3b37d54c08b2930def998f3cb963b0a8e84ee3d81
4
- data.tar.gz: c83587b88d96cc21347fd863205cefa7228471ac4d9e2d020a01f49869ddff0a
3
+ metadata.gz: ba12e565c1d9d7ef2121f766d68231fd287364dbd3f5feb20bb21623fcb046f1
4
+ data.tar.gz: 70d982478fc721efa83ace6be2544afee4438a826eac4991ba42bf68627e252e
5
5
  SHA512:
6
- metadata.gz: 256b2868145fcca0b1c1a9df5b37a1d0f1ee5adf4345df8e13bf6ed38f9e03de7832f9d8873a24f900c11a75f18029ce56a473d4de25fa17c2af1f370b6f6a0b
7
- data.tar.gz: a7e636e968d2457fdc2f09124f6976c872b639467d8993f629959b163a2e380e0e86bdc89bd8129848f72f2b1a6e47972cddffad72f4a5b472b555d96bc46fab
6
+ metadata.gz: 46ca4a2c64ad3228b85e57e319e9e39413616cea7ba5503206d398c5e921d33d8d796ceb1741865cde4c0229b9729dfabae4b80d3765d822298a4502266063ef
7
+ data.tar.gz: 7b0a7a51038947db2860e537402c6ccc87f0ea24b01ad051c8dd6a63c6601aea7295a2634ba1fa72cde23ee28d4c5ef56b7981e3ef93bac286b6bbf64c7cf3b0
@@ -45,7 +45,7 @@ class Features::Service < ForemanMaintain::Feature
45
45
 
46
46
  def filter_disabled_services!(action, service_list)
47
47
  if %w[start stop restart status].include?(action)
48
- service_list.select!(&:enabled?)
48
+ service_list.select! { |service| !service.respond_to?(:enabled?) || service.enabled? }
49
49
  end
50
50
  service_list
51
51
  end
@@ -6,6 +6,7 @@ module Procedures::Content
6
6
  end
7
7
 
8
8
  def run
9
+ sleep(20) # in satellite 6.9 the services are still coming up
9
10
  # use interactive to get realtime output
10
11
  puts execute!('foreman-rake katello:pulp3_migration', :interactive => true)
11
12
  end
@@ -8,8 +8,11 @@ module Procedures::Content
8
8
  # FIXME: remove this condition for the 6.10 upgrade scenario
9
9
  !feature(:instance).downstream
10
10
  end
11
+
12
+ param :skip_deb, 'Do not run debian options in installer.'
11
13
  end
12
14
 
15
+ # rubocop:disable Metrics/MethodLength
13
16
  def run
14
17
  puts 'Performing final content migration before switching content'
15
18
  puts execute!('foreman-rake katello:pulp3_migration')
@@ -20,11 +23,15 @@ module Procedures::Content
20
23
  puts 'Re-running the installer to switch specified content over to pulp3'
21
24
  args = ['--foreman-proxy-content-proxy-pulp-isos-to-pulpcore=true',
22
25
  '--foreman-proxy-content-proxy-pulp-yum-to-pulpcore=true',
23
- '--foreman-proxy-content-proxy-pulp-deb-to-pulpcore=true',
24
26
  '--katello-use-pulp-2-for-file=false',
25
27
  '--katello-use-pulp-2-for-docker=false',
26
- '--katello-use-pulp-2-for-deb=false',
27
28
  '--katello-use-pulp-2-for-yum=false']
29
+
30
+ unless @skip_deb
31
+ args += ['--katello-use-pulp-2-for-deb=false',
32
+ '--foreman-proxy-content-proxy-pulp-deb-to-pulpcore=true']
33
+ end
34
+
28
35
  feature(:installer).run(args.join(' '))
29
36
  end
30
37
  end
@@ -0,0 +1,11 @@
1
+ module Procedures::Packages
2
+ class CheckUpdate < ForemanMaintain::Procedure
3
+ metadata do
4
+ description 'Check for available package updates'
5
+ end
6
+
7
+ def run
8
+ puts package_manager.check_update
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
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
@@ -2,10 +2,13 @@ module Procedures::Pulp
2
2
  class Remove < ForemanMaintain::Procedure
3
3
  metadata do
4
4
  description 'Remove pulp2'
5
+ param :assumeyes, 'Do not ask for confirmation', :default => false
5
6
 
6
7
  confine do
7
8
  check_min_version('katello-common', '4.0')
8
9
  end
10
+
11
+ param :assume_yes, 'Run the full removal without asking.'
9
12
  end
10
13
 
11
14
  def sys
@@ -41,7 +44,8 @@ module Procedures::Pulp
41
44
  python-pulp-python-common python-pulp-repoauth python-pulp-rpm-common
42
45
  python-pulp-streamer python-pymongo python-pymongo-gridfs python2-amqp
43
46
  python2-billiard python2-celery python2-debpkgr python2-django python2-kombu
44
- python2-solv python2-vine pulp-katello]
47
+ python2-solv python2-vine pulp-katello pulp-maintenance
48
+ python3-pulp-2to3-migration]
45
49
 
46
50
  @installed_pulp_packages ||= possible.select { |pkg| find_package(pkg) }
47
51
  @installed_pulp_packages
@@ -52,9 +56,9 @@ module Procedures::Pulp
52
56
  end
53
57
 
54
58
  def ask_to_proceed(rm_cmds)
55
- question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n" \
56
- "\n# rpm -e #{pulp_packages.join(' ')}" \
57
- "\n# yum remove rh-mongodb34-*" \
59
+ question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n"
60
+ question += "\n# rpm -e #{pulp_packages.join(' ')}" if pulp_packages.any?
61
+ question += "\n# yum remove rh-mongodb34-*" \
58
62
  "\n\nAll pulp2 data will be removed.\n"
59
63
  question += rm_cmds.collect { |cmd| "\n# #{cmd}" }.join
60
64
  question += "\n\nDo you want to proceed?"
@@ -64,12 +68,19 @@ module Procedures::Pulp
64
68
 
65
69
  def run
66
70
  rm_cmds = data_dir_removal_cmds
67
- ask_to_proceed(rm_cmds) if rm_cmds.any?
68
71
 
69
- remove_pulp
72
+ assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
73
+
74
+ ask_to_proceed(rm_cmds) unless assumeyes_val
75
+
76
+ remove_pulp if pulp_packages.any?
70
77
 
71
78
  remove_mongo
72
79
 
80
+ drop_migration_tables
81
+
82
+ drop_migrations
83
+
73
84
  delete_pulp_data(rm_cmds) if rm_cmds.any?
74
85
  end
75
86
 
@@ -85,6 +96,60 @@ module Procedures::Pulp
85
96
  end
86
97
  end
87
98
 
99
+ def drop_migration_tables
100
+ with_spinner('Dropping migration tables') do
101
+ feature(:pulpcore_database).psql(<<-SQL)
102
+ BEGIN;
103
+ DROP TABLE IF EXISTS pulp_2to3_migration_migrationplan,
104
+ pulp_2to3_migration_pulp2blob,
105
+ pulp_2to3_migration_pulp2content,
106
+ pulp_2to3_migration_pulp2debcomponent,
107
+ pulp_2to3_migration_pulp2debcomponentpackage,
108
+ pulp_2to3_migration_pulp2debpackage,
109
+ pulp_2to3_migration_pulp2debrelease,
110
+ pulp_2to3_migration_pulp2debreleasearchitecture,
111
+ pulp_2to3_migration_pulp2distribution,
112
+ pulp_2to3_migration_pulp2distributor,
113
+ pulp_2to3_migration_pulp2distributor_pulp2_repos,
114
+ pulp_2to3_migration_pulp2erratum,
115
+ pulp_2to3_migration_pulp2importer,
116
+ pulp_2to3_migration_pulp2iso,
117
+ pulp_2to3_migration_pulp2lazycatalog,
118
+ pulp_2to3_migration_pulp2manifest,
119
+ pulp_2to3_migration_pulp2manifestlist,
120
+ pulp_2to3_migration_pulp2modulemd,
121
+ pulp_2to3_migration_pulp2modulemddefaults,
122
+ pulp_2to3_migration_pulp2packagecategory,
123
+ pulp_2to3_migration_pulp2packageenvironment,
124
+ pulp_2to3_migration_pulp2packagegroup,
125
+ pulp_2to3_migration_pulp2packagelangpacks,
126
+ pulp_2to3_migration_pulp2repocontent,
127
+ pulp_2to3_migration_pulp2repository,
128
+ pulp_2to3_migration_pulp2rpm,
129
+ pulp_2to3_migration_pulp2srpm,
130
+ pulp_2to3_migration_pulp2tag,
131
+ pulp_2to3_migration_pulp2yumrepometadatafile,
132
+ pulp_2to3_migration_reposetup CASCADE;
133
+ DROP SEQUENCE IF EXISTS pulp_2to3_migration_pulp2distributor_pulp2_repos_id_seq;
134
+ END;
135
+ SQL
136
+ end
137
+ end
138
+
139
+ def drop_migrations
140
+ with_spinner('Dropping migrations') do
141
+ feature(:pulpcore_database).psql(<<-SQL)
142
+ BEGIN;
143
+ DELETE FROM django_migrations WHERE app = 'pulp_2to3_migration';
144
+ DELETE FROM auth_permission WHERE content_type_id in (SELECT id FROM django_content_type WHERE app_label = 'pulp_2to3_migration');
145
+ DELETE FROM django_admin_log WHERE content_type_id in (SELECT id FROM django_content_type WHERE app_label = 'pulp_2to3_migration');
146
+ DELETE FROM django_content_type WHERE app_label = 'pulp_2to3_migration';
147
+ END;
148
+ SQL
149
+ end
150
+ end
151
+ # rubocop:enable Metrics/BlockLength
152
+
88
153
  def delete_pulp_data(rm_cmds)
89
154
  with_spinner('Deleting pulp2 data directories') do |spinner|
90
155
  rm_cmds.each do |cmd|
@@ -101,9 +101,14 @@ module ForemanMaintain::Scenarios
101
101
  metadata do
102
102
  label :content_remove_pulp2
103
103
  description 'Remove Pulp2 and mongodb packages and data'
104
+ param :assumeyes, 'Do not ask for confirmation'
104
105
  manual_detection
105
106
  end
106
107
 
108
+ def set_context_mapping
109
+ context.map(:assumeyes, Procedures::Pulp::Remove => :assumeyes)
110
+ end
111
+
107
112
  def compose
108
113
  add_step_with_context(Procedures::Pulp::Remove)
109
114
  end
@@ -50,6 +50,18 @@ module ForemanMaintain::Scenarios
50
50
  end
51
51
  end
52
52
 
53
+ class CheckUpdate < ForemanMaintain::Scenario
54
+ metadata do
55
+ label :packages_check_update
56
+ description 'Check for available package updates'
57
+ manual_detection
58
+ end
59
+
60
+ def compose
61
+ add_step(Procedures::Packages::CheckUpdate)
62
+ end
63
+ end
64
+
53
65
  class Install < ForemanMaintain::Scenario
54
66
  metadata do
55
67
  description 'install packages in unlocked session'
@@ -48,13 +48,29 @@ module Scenarios::Satellite_6_10
48
48
  upgrade_metadata do
49
49
  description 'Migration scripts to Satellite 6.10'
50
50
  tags :migrations
51
+ run_strategy :fail_fast
51
52
  end
52
53
 
53
54
  def set_context_mapping
54
55
  context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
55
56
  end
56
57
 
58
+ def check_var_lib_pulp
59
+ group_id = File.stat('/var/lib/pulp/').gid
60
+ if Etc.getgrgid(group_id).name != 'pulp'
61
+ raise "Please run 'foreman-maintain prep-6.10-upgrade' prior to upgrading."
62
+ end
63
+ end
64
+
57
65
  def compose
66
+ check_var_lib_pulp
67
+
68
+ add_step(Procedures::Service::Start)
69
+ add_step(Procedures::Service::Enable.
70
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
71
+ add_step(Procedures::Service::Start.
72
+ new(:only => Features::Pulpcore.pulpcore_migration_services))
73
+ add_step(Procedures::Content::Switchover.new(:skip_deb => true))
58
74
  add_step(Procedures::Repositories::Setup.new(:version => '6.10'))
59
75
  add_step(Procedures::Packages::UnlockVersions.new)
60
76
  add_step(Procedures::Packages::Update.new(:assumeyes => true))
@@ -86,6 +102,7 @@ module Scenarios::Satellite_6_10
86
102
  def compose
87
103
  add_steps(find_checks(:default))
88
104
  add_steps(find_checks(:post_upgrade))
105
+ add_step(Procedures::Pulp::PrintRemoveInstructions.new)
89
106
  end
90
107
  end
91
108
  end
@@ -35,8 +35,11 @@ module ForemanMaintain
35
35
  end
36
36
 
37
37
  subcommand 'remove-pulp2', 'Remove pulp2 and mongodb packages and data' do
38
+ interactive_option(%w[assumeyes plaintext])
38
39
  def execute
39
- run_scenarios_and_exit(Scenarios::Content::RemovePulp2.new)
40
+ run_scenarios_and_exit(
41
+ Scenarios::Content::RemovePulp2.new(:assumeyes => assumeyes?)
42
+ )
40
43
  end
41
44
  end
42
45
  end
@@ -22,6 +22,13 @@ module ForemanMaintain
22
22
  end
23
23
  end
24
24
 
25
+ subcommand 'check-update', 'Check for available package updates' do
26
+ interactive_option
27
+ def execute
28
+ run_scenarios_and_exit(Scenarios::Packages::CheckUpdate.new)
29
+ end
30
+ end
31
+
25
32
  subcommand 'install', 'Install packages in an unlocked session' do
26
33
  interactive_option(['assumeyes'])
27
34
  parameter 'PACKAGES ...', 'packages to install', :attribute_name => :packages
@@ -61,6 +61,10 @@ module ForemanMaintain::PackageManager
61
61
  yum_action('clean', 'all', :assumeyes => assumeyes)
62
62
  end
63
63
 
64
+ def check_update
65
+ yum_action('check-update', nil, :assumeyes => true, :valid_exit_statuses => [100])
66
+ end
67
+
64
68
  def update_available?(package)
65
69
  cmd_output = yum_action('check-update -q', package, :with_status => true, :assumeyes => false)
66
70
  cmd_output[0] == 100
@@ -109,10 +113,11 @@ module ForemanMaintain::PackageManager
109
113
  File.open(protector_config_file, 'w') { |file| file.puts config }
110
114
  end
111
115
 
112
- def yum_action(action, packages, with_status: false, assumeyes: false)
116
+ def yum_action(action, packages, with_status: false, assumeyes: false, valid_exit_statuses: [0])
113
117
  yum_options = []
114
118
  packages = [packages].flatten(1)
115
119
  yum_options << '-y' if assumeyes
120
+ yum_options << '--disableplugin=foreman-protector'
116
121
  yum_options_s = yum_options.empty? ? '' : ' ' + yum_options.join(' ')
117
122
  packages_s = packages.empty? ? '' : ' ' + packages.join(' ')
118
123
  if with_status
@@ -120,7 +125,7 @@ module ForemanMaintain::PackageManager
120
125
  :interactive => !assumeyes)
121
126
  else
122
127
  sys.execute!("yum#{yum_options_s} #{action}#{packages_s}",
123
- :interactive => !assumeyes)
128
+ :interactive => !assumeyes, :valid_exit_statuses => valid_exit_statuses)
124
129
  end
125
130
  end
126
131
 
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.8.6'.freeze
2
+ VERSION = '0.8.7'.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.8.6
4
+ version: 0.8.7
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-07-13 00:00:00.000000000 Z
11
+ date: 2021-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -251,6 +251,7 @@ files:
251
251
  - definitions/procedures/iptables/remove_maintenance_mode_chain.rb
252
252
  - definitions/procedures/knowledge_base_article.rb
253
253
  - definitions/procedures/maintenance_mode/is_enabled.rb
254
+ - definitions/procedures/packages/check_update.rb
254
255
  - definitions/procedures/packages/enable_version_locking.rb
255
256
  - definitions/procedures/packages/install.rb
256
257
  - definitions/procedures/packages/installer_confirmation.rb
@@ -262,6 +263,7 @@ files:
262
263
  - definitions/procedures/passenger_recycler.rb
263
264
  - definitions/procedures/prep_6_10_upgrade.rb
264
265
  - definitions/procedures/pulp/migrate.rb
266
+ - definitions/procedures/pulp/print_remove_instructions.rb
265
267
  - definitions/procedures/pulp/remove.rb
266
268
  - definitions/procedures/pulpcore/migrate.rb
267
269
  - definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb