foreman_maintain 1.0.12 → 1.0.13

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: 40bec791581fb8e2670586e331afd5e89ba1ca436b38d95e848837fc8ce1fdd3
4
- data.tar.gz: 54f35bb8139e221173ca57786c93e36559957116577907fa936d0ff3f4256858
3
+ metadata.gz: c6b379bdb79107fc7f416af7bf700834ec7ae0591b734926398a09311d86879e
4
+ data.tar.gz: bf901e325a757e8e5c31787019dd9ba662bedef4a5692f20d78f4204f45bbcc4
5
5
  SHA512:
6
- metadata.gz: 2e00f5941e44f62e5fa09d47924fa231af050cf32ae555a775bdb247753c0b38d1a2b3c554e86d3699287f1a4367a461f780be6fca5c897031feffbf07de9f53
7
- data.tar.gz: 80447d1b43a06edcdd7d9846637c4f484f8bd454e9bdda303355223f64671fa276e37e1c0c8bf50aff1c6213ed30d23028c850b31e1e9f3463b1660994109902
6
+ metadata.gz: 49831252dbbb12f0dc9f6e591d24aa9cb112e9dacfe50470c5ef9cb1a5c6a4f5e7070b95a0929f970dfcb7430ffad4cffce74f6cbd1c8f28231e26411cc42886
7
+ data.tar.gz: e0173b351c72f65b1d17cca48c31a7b3896781c8a2af6d07a23c25593318ed1f548f73a54e8ece99b8ced0ff6fb0828f6d850bde95a9de07950c03a433861987
@@ -6,12 +6,14 @@ module Procedures::Packages
6
6
  param :force, 'Do not skip if package is installed', :flag => true, :default => false
7
7
  param :warn_on_errors, 'Do not interrupt scenario on failure',
8
8
  :flag => true, :default => false
9
+ param :yum_options, 'Extra yum options if any', :array => true, :default => []
9
10
  end
10
11
 
11
12
  def run
12
13
  assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
13
14
  package_manager.clean_cache(:assumeyes => assumeyes_val)
14
- packages_action(:update, @packages, :assumeyes => assumeyes_val)
15
+ opts = { :assumeyes => assumeyes_val, :yum_options => @yum_options }
16
+ packages_action(:update, @packages, opts)
15
17
  rescue ForemanMaintain::Error::ExecutionError => e
16
18
  if @warn_on_errors
17
19
  set_status(:warning, e.message)
@@ -1,18 +1,6 @@
1
1
  module ForemanMaintain::Scenarios
2
2
  class SelfUpgradeBase < ForemanMaintain::Scenario
3
3
  include ForemanMaintain::Concerns::Downstream
4
- def enabled_system_repos_id
5
- repository_manager.enabled_repos.keys
6
- end
7
-
8
- def enable_repos(repo_ids = stored_enabled_repos_ids)
9
- add_step(Procedures::Repositories::Enable.new(repos: repo_ids))
10
- end
11
-
12
- def disable_repos(repo_ids = stored_enabled_repos_ids)
13
- add_step(Procedures::Repositories::Disable.new(repos: repo_ids))
14
- end
15
-
16
4
  def target_version
17
5
  current_full_version = feature(:instance).downstream.current_version
18
6
  @target_version ||= current_full_version.bump
@@ -44,36 +32,6 @@ module ForemanMaintain::Scenarios
44
32
  end
45
33
  end
46
34
 
47
- def maintenance_repo_version
48
- return '6' if current_version == '6.10'
49
-
50
- current_version
51
- end
52
-
53
- def stored_enabled_repos_ids
54
- @stored_enabled_repos_ids ||= begin
55
- path = File.expand_path('enabled_repos.yml', ForemanMaintain.config.backup_dir)
56
- @stored_enabled_repos_ids = File.file?(path) ? YAML.load(File.read(path)) : []
57
- end
58
- end
59
-
60
- def all_maintenance_repos
61
- repo_regex = if el7?
62
- /rhel-\d-server-satellite-maintenance-\d.\d-rpms/
63
- else
64
- /satellite-maintenance-\d.\d-for-rhel-\d-x86_64-rpms/
65
- end
66
- stored_enabled_repos_ids.select { |id| !id.match(repo_regex).nil? }
67
- end
68
-
69
- def repos_ids_to_reenable
70
- repos_ids_to_reenable = stored_enabled_repos_ids - all_maintenance_repos
71
- if use_rhsm?
72
- repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
73
- end
74
- repos_ids_to_reenable
75
- end
76
-
77
35
  def use_rhsm?
78
36
  return false if maintenance_repo_label
79
37
 
@@ -100,30 +58,11 @@ module ForemanMaintain::Scenarios
100
58
  def compose
101
59
  if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
102
60
  pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
103
- add_step(Procedures::Repositories::BackupEnabledRepos.new)
104
- disable_repos
105
- add_step(Procedures::Repositories::Enable.new(repos: req_repos_to_update_pkgs,
106
- use_rhsm: use_rhsm?))
107
- add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true))
108
- disable_repos('*')
109
- enable_repos(repos_ids_to_reenable)
110
- end
111
- end
112
- end
113
-
114
- class SelfUpgradeRescue < SelfUpgradeBase
115
- metadata do
116
- label :rescue_self_upgrade
117
- description 'Disables all version specific maintenance repositories and,'\
118
- "\nenables the repositories which were configured prior to self upgrade"
119
- manual_detection
120
- run_strategy :fail_slow
121
- end
122
-
123
- def compose
124
- if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
125
- disable_repos('*')
126
- enable_repos(repos_ids_to_reenable)
61
+ yum_options = req_repos_to_update_pkgs.map do |id|
62
+ "--enablerepo=#{id}"
63
+ end
64
+ add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
65
+ yum_options: yum_options))
127
66
  end
128
67
  end
129
68
  end
@@ -5,7 +5,7 @@ module ForemanMaintain
5
5
  'Repository label from which packages should be updated.'\
6
6
  'This can be used when standard CDN repositories are unavailable.'
7
7
  def execute
8
- run_scenario(upgrade_scenario, upgrade_rescue_scenario)
8
+ run_scenario(upgrade_scenario)
9
9
  end
10
10
 
11
11
  def upgrade_scenario
@@ -13,12 +13,6 @@ module ForemanMaintain
13
13
  maintenance_repo_label: maintenance_repo_label
14
14
  )
15
15
  end
16
-
17
- def upgrade_rescue_scenario
18
- Scenarios::SelfUpgradeRescue.new(
19
- maintenance_repo_label: maintenance_repo_label
20
- )
21
- end
22
16
  end
23
17
  end
24
18
  end
@@ -100,12 +100,13 @@ module ForemanMaintain
100
100
  end
101
101
 
102
102
  def packages_action(action, packages, options = {})
103
- options.validate_options!(:assumeyes)
103
+ options.validate_options!(:assumeyes, :yum_options)
104
104
  case action
105
105
  when :install
106
106
  package_manager.install(packages, :assumeyes => options[:assumeyes])
107
107
  when :update
108
- package_manager.update(packages, :assumeyes => options[:assumeyes])
108
+ package_manager.update(packages, :assumeyes => options[:assumeyes],
109
+ :yum_options => options[:yum_options])
109
110
  when :remove
110
111
  package_manager.remove(packages, :assumeyes => options[:assumeyes])
111
112
  else
@@ -55,8 +55,8 @@ module ForemanMaintain::PackageManager
55
55
  yum_action('remove', packages, :assumeyes => assumeyes)
56
56
  end
57
57
 
58
- def update(packages = [], assumeyes: false)
59
- yum_action('update', packages, :assumeyes => assumeyes)
58
+ def update(packages = [], assumeyes: false, yum_options: [])
59
+ yum_action('update', packages, :assumeyes => assumeyes, :yum_options => yum_options)
60
60
  end
61
61
 
62
62
  def clean_cache(assumeyes: false)
@@ -116,8 +116,12 @@ module ForemanMaintain::PackageManager
116
116
  File.open(protector_config_file, 'w') { |file| file.puts config }
117
117
  end
118
118
 
119
- def yum_action(action, packages, with_status: false, assumeyes: false, valid_exit_statuses: [0])
120
- yum_options = []
119
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
120
+ def yum_action(action, packages, options)
121
+ with_status = options.fetch(:with_status, false)
122
+ assumeyes = options.fetch(:assumeyes, false)
123
+ valid_exit_statuses = options.fetch(:valid_exit_statuses, [0])
124
+ yum_options = options.fetch(:yum_options, [])
121
125
  packages = [packages].flatten(1)
122
126
  yum_options << '-y' if assumeyes
123
127
  yum_options << '--disableplugin=foreman-protector'
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.0.12'.freeze
2
+ VERSION = '1.0.13'.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.12
4
+ version: 1.0.13
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: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp