foreman_maintain 1.0.10 → 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: 6f3b029d12907c373c22b065792200ff3c8087051d1d3573da149124c4a7b9d4
4
- data.tar.gz: d70220606c7f0c5af7ea9115b16d5f9cb248765f2420f01f72482031495dc980
3
+ metadata.gz: c6b379bdb79107fc7f416af7bf700834ec7ae0591b734926398a09311d86879e
4
+ data.tar.gz: bf901e325a757e8e5c31787019dd9ba662bedef4a5692f20d78f4204f45bbcc4
5
5
  SHA512:
6
- metadata.gz: 657e8536192d1fa4ac0a9ec16161a1ce128e9747a827ea4d87869049f35d1cae8683a691efd3ab629b82fdc3ca1251153768cf208444daa412780061f0fb0862
7
- data.tar.gz: '039b4a5cb9389ca78a2497f05e14bfb2ee9e7f1f4298025ee254cbbc02f4317f4bdfe9a5e71722e6bfb75e4b6679d3473fe7d080d9f55d811fe1d554549b2da1'
6
+ metadata.gz: 49831252dbbb12f0dc9f6e591d24aa9cb112e9dacfe50470c5ef9cb1a5c6a4f5e7070b95a0929f970dfcb7430ffad4cffce74f6cbd1c8f28231e26411cc42886
7
+ data.tar.gz: e0173b351c72f65b1d17cca48c31a7b3896781c8a2af6d07a23c25593318ed1f548f73a54e8ece99b8ced0ff6fb0828f6d850bde95a9de07950c03a433861987
@@ -6,7 +6,7 @@ module Procedures::Foreman
6
6
  end
7
7
 
8
8
  def run
9
- execute!('foreman-rake apipie:cache')
9
+ execute!('FOREMAN_APIPIE_LANGS=en foreman-rake apipie:cache')
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,52 @@
1
+ module Procedures::Installer
2
+ class RunFor6_11 < ForemanMaintain::Procedure
3
+ metadata do
4
+ description 'Run installer with Candlepin SSL CA'\
5
+ ' when using external database with SSL'
6
+ param :assumeyes, 'Do not ask for confirmation'
7
+ manual_detection
8
+ end
9
+
10
+ def run
11
+ if extdb_and_ssl?
12
+ run_installer_with_extra_option
13
+ else
14
+ run_installer
15
+ end
16
+ end
17
+
18
+ def ext_db?
19
+ !feature(:foreman_database).local?
20
+ end
21
+
22
+ def installer_answers
23
+ @installer_answers ||= feature(:installer).answers
24
+ end
25
+
26
+ def server_db_with_ssl?
27
+ installer_answers.fetch('katello')['candlepin_db_ssl']
28
+ end
29
+
30
+ def extdb_and_ssl?
31
+ ext_db? && server_db_with_ssl?
32
+ end
33
+
34
+ def run_installer_with_extra_option
35
+ ssl_ca_path = installer_answers.fetch('foreman')['db_root_cert']
36
+ spinner_msg = "Running installer with --katello-candlepin-db-ssl-ca #{ssl_ca_path} argument!"
37
+ with_spinner(spinner_msg) do
38
+ installer_args = feature(:installer).installer_arguments
39
+ new_ssl_arg = " --katello-candlepin-db-ssl-ca #{ssl_ca_path}"
40
+ installer_args << new_ssl_arg
41
+ feature(:installer).run(installer_args)
42
+ end
43
+ end
44
+
45
+ def run_installer
46
+ with_spinner('Executing installer') do
47
+ assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
48
+ feature(:installer).upgrade(:interactive => !assumeyes_val)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -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)
@@ -15,6 +15,9 @@ module ForemanMaintain::Scenarios
15
15
  add_step(Procedures::Puppet::RemovePuppet)
16
16
  add_step(Procedures::Puppet::RemovePuppetData) if context.get(:remove_data)
17
17
  add_step(Procedures::Service::Restart)
18
+ if server?
19
+ add_step(Procedures::Foreman::ApipieCache)
20
+ end
18
21
  end
19
22
  end
20
23
  end
@@ -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
@@ -61,7 +61,7 @@ module Scenarios::Satellite_6_11
61
61
  add_step(Procedures::Repositories::Setup.new(:version => '6.11'))
62
62
  add_step(Procedures::Packages::UnlockVersions.new)
63
63
  add_step(Procedures::Packages::Update.new(:assumeyes => true))
64
- add_step_with_context(Procedures::Installer::Upgrade)
64
+ add_step_with_context(Procedures::Installer::RunFor6_11)
65
65
  add_step(Procedures::Installer::UpgradeRakeTask)
66
66
  end
67
67
  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.10'.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.10
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-05-11 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
@@ -266,6 +266,7 @@ files:
266
266
  - definitions/procedures/foreman_tasks/ui_investigate.rb
267
267
  - definitions/procedures/hammer_setup.rb
268
268
  - definitions/procedures/installer/run.rb
269
+ - definitions/procedures/installer/run_for_6_11.rb
269
270
  - definitions/procedures/installer/upgrade.rb
270
271
  - definitions/procedures/installer/upgrade_rake_task.rb
271
272
  - definitions/procedures/knowledge_base_article.rb