foreman_maintain 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e70bdc300a891fd04cb9e489737a0a96a46d83977f192eddc1ee14a8deff7b9b
4
- data.tar.gz: ac5dc055fc90930f91c844f7c7bd411d156c943d911b56d9df5aafab4262481a
3
+ metadata.gz: eee1f58199b0dd709acdfd9095292306de60d75d067edac09d28287caf323439
4
+ data.tar.gz: bd0b37c9668e6db36895a5a13b1568ea2cd171feacb670d5f5c912b9a7e7e7b6
5
5
  SHA512:
6
- metadata.gz: ce61614ae7a224595e48ef2cf4a8e0f268e3a7f1f59b8bc67af8ea19c7926ee6fe2d1f6474a8a13fb758627e7c2aa87d272163a064298c208a97e6e3279978da
7
- data.tar.gz: 983efdf31d1fdfc9dedca4c66374d178ef34310da40900e60af7f85550627d0416f88713316c93551f66c75bc775d7a533524b38b1e28e603944c6edf3d8bb6d
6
+ metadata.gz: 8c4117234bfaf93217d80f8f076b0187c59bb240fd3f8210867c41422d47c3a033d31c2eb2be61252303fe371ce1ab1c33d6f362576ed5a411d5c4c989b58c45
7
+ data.tar.gz: 97a10cdf47b6838eef3b7d79bc91849bc7d3f991e090f16d7a6a013b377b3a09e46c5ccd23de64f1520c080f7d1d56397468beb0bffe0a4d901e10c327356488
@@ -45,16 +45,24 @@ class Checks::CheckHotfixInstalled < ForemanMaintain::Check
45
45
 
46
46
  def installed_packages
47
47
  packages = []
48
- repoquery_cmd = execute!('which repoquery')
49
- IO.popen([repoquery_cmd, '-a', '--installed', '--qf', '%{ui_from_repo} %{nvra}']) do |io|
48
+ IO.popen(['repoquery', '-a', '--installed', '--qf', query_format]) do |io|
50
49
  io.each do |line|
51
50
  repo, pkg = line.chomp.split
52
- packages << pkg if /satellite|rhscl/ =~ repo[1..-1].downcase
51
+ next if repo.nil? || pkg.nil?
52
+ packages << pkg if /satellite|rhscl/ =~ repo.downcase
53
53
  end
54
54
  end
55
55
  packages
56
56
  end
57
57
 
58
+ def query_format
59
+ if el7?
60
+ return '%{ui_from_repo} %{name}-%{evr}.%{arch}'
61
+ end
62
+
63
+ '%{from_repo} %{name}-%{evr}.%{arch}'
64
+ end
65
+
58
66
  def find_hotfix_packages
59
67
  output = execute!('rpm -qa release="*HOTFIX*"').strip
60
68
  return [] if output.empty?
@@ -6,12 +6,12 @@ module Checks::ForemanProxy
6
6
  tags :default
7
7
  confine do
8
8
  feature(:satellite) && feature(:foreman_proxy) &&
9
- feature(:foreman_proxy).features.include?('tftp') && non_zero_token_duration?
9
+ feature(:foreman_proxy).features.include?('tftp')
10
10
  end
11
11
  end
12
12
 
13
13
  def run
14
- if Dir.exist?(tftp_boot_directory)
14
+ if non_zero_token_duration? && Dir.exist?(tftp_boot_directory)
15
15
  files = old_files_from_tftp_boot
16
16
  assert(files.empty?,
17
17
  'There are old initrd and vmlinuz files present in tftp',
@@ -29,7 +29,7 @@ module Checks::ForemanProxy
29
29
  end.compact
30
30
  end
31
31
 
32
- def self.non_zero_token_duration?
32
+ def non_zero_token_duration?
33
33
  lookup_token_duration != 0
34
34
  end
35
35
 
@@ -38,10 +38,10 @@ module Checks::ForemanProxy
38
38
  end
39
39
 
40
40
  def token_duration
41
- @token_duration ||= self.class.lookup_token_duration
41
+ @token_duration ||= lookup_token_duration
42
42
  end
43
43
 
44
- def self.lookup_token_duration
44
+ def lookup_token_duration
45
45
  data = feature(:foreman_database). \
46
46
  query("select s.value, s.default from settings s \
47
47
  where category IN ('Setting::Provisioning','Setting') \
@@ -2,13 +2,13 @@ module Checks
2
2
  module Pulpcore
3
3
  class GroupOwnershipCheck < ForemanMaintain::Check
4
4
  metadata do
5
- description 'Check the group owner of /var/lib/pulp directory'
5
+ description 'Check the group owner of /var/lib/pulp/content directory'
6
6
  label :group_ownership_check_of_pulp_content
7
7
  manual_detection
8
8
  end
9
9
 
10
10
  def run
11
- group_id = File.stat('/var/lib/pulp/').gid
11
+ group_id = File.stat('/var/lib/pulp/content/').gid
12
12
  if Etc.getgrgid(group_id).name != 'pulp'
13
13
  fail! "Please run 'foreman-maintain prep-6.10-upgrade' prior to upgrading."
14
14
  end
@@ -142,11 +142,15 @@ class Features::Instance < ForemanMaintain::Feature
142
142
  def component_features_map
143
143
  {
144
144
  'candlepin_auth' => %w[candlepin candlepin_database],
145
+ 'candlepin_events' => %w[candlepin candlepin_database],
145
146
  'candlepin' => %w[candlepin candlepin_database],
146
147
  'pulp_auth' => %w[pulp2 mongo],
147
148
  'pulp' => %w[pulp2 mongo],
148
149
  'pulp3' => %w[pulpcore pulpcore_database],
149
- 'foreman_tasks' => %w[foreman_tasks]
150
+ 'pulp3_content' => %w[pulpcore pulpcore_database],
151
+ 'foreman_tasks' => %w[foreman_tasks],
152
+ 'katello_agent' => %w[katello],
153
+ 'katello_events' => %w[katello]
150
154
  }
151
155
  end
152
156
 
@@ -154,7 +158,7 @@ class Features::Instance < ForemanMaintain::Feature
154
158
  components = Array(components)
155
159
  cf_map = component_features_map
156
160
  # map ping components to features
157
- features = components.map { |component| cf_map[component] }.flatten.uniq
161
+ features = components.map { |component| cf_map[component] }.flatten.uniq.compact
158
162
  # map features to existing services
159
163
  services_of_features = features.map do |name|
160
164
  feature(name.to_sym) ? feature(name.to_sym).services : []
@@ -10,15 +10,23 @@ module Procedures::Puppet
10
10
  end
11
11
 
12
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?
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
16
17
  feature(:installer).run(installer_arguments_disabling_puppet.join(' '), :interactive => false)
17
18
  packages_action(:remove, packages_to_remove, :assumeyes => true)
18
19
  end
19
20
 
20
21
  private
21
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
+
22
30
  def server_with_puppet?
23
31
  find_package(foreman_plugin_name('foreman_puppet'))
24
32
  end
@@ -5,7 +5,9 @@ module Procedures::Puppet
5
5
  end
6
6
 
7
7
  def run
8
- execute!('foreman-rake purge:puppet')
8
+ if feature(:foreman_server)
9
+ execute!('foreman-rake purge:puppet')
10
+ end
9
11
  execute!('rm -r ' + files_to_purge.join(' '))
10
12
  end
11
13
 
@@ -1,7 +1,7 @@
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
@@ -1,12 +1,18 @@
1
1
  module Procedures::Repositories
2
2
  class Enable < ForemanMaintain::Procedure
3
3
  metadata do
4
- param :repos, 'List of repositories to enable'
4
+ param :repos, 'Array of repositories to enable'
5
+ param :use_rhsm, 'Use RHSM to enable repository',
6
+ :flag => true, :default => false
5
7
  description 'Enable repositories'
6
8
  end
7
9
  def run
8
10
  with_spinner('Enabling repositories') do
9
- repository_manager.enable_repos(@repos)
11
+ if @use_rhsm
12
+ repository_manager.rhsm_enable_repos(@repos)
13
+ else
14
+ repository_manager.enable_repos(@repos)
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -14,6 +14,7 @@ module ForemanMaintain::Scenarios
14
14
  add_step(Checks::CheckPuppetCapsules) if server?
15
15
  add_step(Procedures::Puppet::RemovePuppet)
16
16
  add_step(Procedures::Puppet::RemovePuppetData) if context.get(:remove_data)
17
+ add_step(Procedures::Service::Restart)
17
18
  end
18
19
  end
19
20
  end
@@ -62,13 +62,21 @@ module ForemanMaintain::Scenarios
62
62
  repos_ids_to_reenable = stored_enabled_repos_ids - all_maintenance_repos
63
63
  repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
64
64
  end
65
+
66
+ def use_rhsm?
67
+ if (repo = ENV['maintenance_repo'])
68
+ return false unless repo.empty?
69
+ end
70
+
71
+ true
72
+ end
65
73
  end
66
74
 
67
75
  class SelfUpgrade < SelfUpgradeBase
68
76
  metadata do
69
77
  label :self_upgrade_foreman_maintain
70
- description "Enables the specified version's maintenance repository and, "\
71
- 'updates the foreman-maintain packages'
78
+ description "Enables the specified version's maintenance repository and,"\
79
+ "\nupdates the satellite-maintain packages"
72
80
  manual_detection
73
81
  end
74
82
 
@@ -77,7 +85,8 @@ module ForemanMaintain::Scenarios
77
85
  pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
78
86
  add_step(Procedures::Repositories::BackupEnabledRepos.new)
79
87
  disable_repos
80
- add_step(Procedures::Repositories::Enable.new(repos: [maintenance_repo_id(target_version)]))
88
+ add_step(Procedures::Repositories::Enable.new(repos: [maintenance_repo_id(target_version)],
89
+ use_rhsm: use_rhsm?))
81
90
  add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true))
82
91
  enable_repos(repos_ids_to_reenable)
83
92
  end
@@ -87,8 +96,8 @@ module ForemanMaintain::Scenarios
87
96
  class SelfUpgradeRescue < SelfUpgradeBase
88
97
  metadata do
89
98
  label :rescue_self_upgrade
90
- description 'Disables all version specific maintenance repos and,'\
91
- ' enables the repositories which were configured prior to self upgrade'
99
+ description 'Disables all version specific maintenance repositories and,'\
100
+ "\nenables the repositories which were configured prior to self upgrade"
92
101
  manual_detection
93
102
  run_strategy :fail_slow
94
103
  end
@@ -41,6 +41,7 @@ module Scenarios::Satellite_7_0
41
41
 
42
42
  def compose
43
43
  add_steps(find_procedures(:pre_migrations))
44
+ add_step(Procedures::Pulp::Remove.new(:assumeyes => true))
44
45
  add_step(Procedures::Service::Stop.new)
45
46
  end
46
47
  end
@@ -29,7 +29,8 @@ module ForemanMaintain
29
29
  end
30
30
  if current_downstream_version >= next_version
31
31
  message = "The target-version #{target_version} should be "\
32
- "greater than existing version #{current_downstream_version}!"
32
+ "greater than existing version #{current_downstream_version},"\
33
+ "\nand self-upgrade should be used for major version upgrades only!"
33
34
  raise Error::UsageError, message
34
35
  end
35
36
  end
@@ -30,7 +30,7 @@ module ForemanMaintain
30
30
  execute!(%(subscription-manager register #{org_options}\
31
31
  --activationkey #{shellescape(activation_key)} --force))
32
32
  else
33
- repository_manager.rhsm_disable_repos('*')
33
+ repository_manager.rhsm_disable_repos(['*'])
34
34
  repository_manager.rhsm_enable_repos(rh_repos(version))
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.0.4'.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: 1.0.1
4
+ version: 1.0.4
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-12-13 00:00:00.000000000 Z
11
+ date: 2022-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp