foreman_maintain 1.0.19 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/definitions/features/candlepin_database.rb +10 -1
  3. data/definitions/features/capsule.rb +1 -1
  4. data/definitions/features/installer.rb +8 -4
  5. data/definitions/features/katello.rb +1 -1
  6. data/definitions/features/nftables.rb +3 -5
  7. data/definitions/features/puppet_server.rb +2 -0
  8. data/definitions/features/satellite.rb +1 -1
  9. data/definitions/procedures/content/prepare.rb +0 -1
  10. data/definitions/procedures/content/switchover.rb +0 -1
  11. data/definitions/procedures/foreman/apipie_cache.rb +1 -1
  12. data/definitions/procedures/packages/update.rb +1 -3
  13. data/definitions/scenarios/puppet.rb +0 -3
  14. data/definitions/scenarios/restore.rb +0 -5
  15. data/definitions/scenarios/self_upgrade.rb +64 -16
  16. data/definitions/scenarios/upgrade_to_capsule_6_11.rb +0 -1
  17. data/definitions/scenarios/upgrade_to_capsule_6_11_z.rb +0 -1
  18. data/definitions/scenarios/upgrade_to_satellite_6_11.rb +1 -2
  19. data/definitions/scenarios/upgrade_to_satellite_6_11_z.rb +0 -1
  20. data/lib/foreman_maintain/cli/self_upgrade_command.rb +7 -1
  21. data/lib/foreman_maintain/concerns/downstream.rb +3 -2
  22. data/lib/foreman_maintain/concerns/firewall/nftables_maintenance_mode.rb +3 -3
  23. data/lib/foreman_maintain/concerns/metadata.rb +0 -4
  24. data/lib/foreman_maintain/concerns/system_helpers.rb +4 -11
  25. data/lib/foreman_maintain/package_manager/yum.rb +15 -15
  26. data/lib/foreman_maintain/reporter/cli_reporter.rb +6 -24
  27. data/lib/foreman_maintain/utils/service/systemd.rb +8 -13
  28. data/lib/foreman_maintain/version.rb +1 -1
  29. metadata +6 -22
  30. data/definitions/procedures/installer/run_for_6_11.rb +0 -52
  31. data/definitions/procedures/restore/reindex_databases.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16cb6948c9fce9920fd8916aba9c0ecb641b6acfee457aa984599976287e097b
4
- data.tar.gz: ed5f56c95835b3c742323686d4207c33d9c5c1d37a9760013bb3810597f6296b
3
+ metadata.gz: 38a7ae9f24c88731e052acb62c13b25d29074a07ad852daa258bed6322c1d22d
4
+ data.tar.gz: e0420aa7dc1935c61ef479aed3a43069281797ca41f131048902c727676c6634
5
5
  SHA512:
6
- metadata.gz: e6daa7f789d47bf1d810f9974a34955695151f4481db5b0d5628de85fe97ede1dd7202985de28e8ca2d010abdef02b51509aa242abce37773daf8afda135b67c
7
- data.tar.gz: fc1e55d663a20afa249d409318800282a78b652b9ebc1cb1bb5655a9ef608d79be1c5434421dfcbd3d3906b156d5262aca8dbcfb05b0de61b8342ef8ffb9e87f
6
+ metadata.gz: e0b38e2d2819e152a508874b060b22f161aa4b56523d9b6869b714f9186920fa7d61fd10b09840158c94e4b55a7c18a718307e9a02f4320426f54baa9bdfdd9f
7
+ data.tar.gz: d53fb1934cdc2cbbc2cad92e43a4132ff0f8ea8eec1435bd930be575d3e2284a48278809b7576bdf24b8d7df36ac39fe2dcb223813dc9f8c3b57632e08e030e5
@@ -75,7 +75,7 @@ class Features::CandlepinDatabase < ForemanMaintain::Feature
75
75
  # rubocop:enable Metrics/MethodLength
76
76
 
77
77
  def extend_with_db_options
78
- db_options = { '-d' => configuration['database'] }
78
+ db_options = { '-d' => construct_database_string }
79
79
  if check_option_using_cpdb_help('dbhost')
80
80
  db_options['--dbhost'] = configuration['host']
81
81
  db_options['--dbport'] = configuration['port']
@@ -83,6 +83,15 @@ class Features::CandlepinDatabase < ForemanMaintain::Feature
83
83
  db_options
84
84
  end
85
85
 
86
+ def construct_database_string
87
+ db_str = configuration['database']
88
+ extra_opts = []
89
+ extra_opts << "ssl=#{configuration['ssl']}" if configuration['ssl']
90
+ extra_opts << "sslfactory=#{configuration['sslfactory']}" if configuration['sslfactory']
91
+ db_str += "?#{extra_opts.join('&')}" unless extra_opts.empty?
92
+ db_str
93
+ end
94
+
86
95
  def fetch_extra_param(url, key_name)
87
96
  query_string = url.split('?')[1]
88
97
  return nil unless query_string
@@ -12,7 +12,7 @@ class Features::Capsule < ForemanMaintain::Feature
12
12
  end
13
13
 
14
14
  def current_version
15
- @current_version ||= rpm_version(package_name)
15
+ @current_version ||= package_version(package_name)
16
16
  end
17
17
 
18
18
  def package_name
@@ -64,9 +64,7 @@ class Features::Installer < ForemanMaintain::Feature
64
64
  def config_files
65
65
  Dir.glob(File.join(config_directory, '**/*')) +
66
66
  [
67
- '/usr/local/bin/validate_postgresql_connection.sh',
68
- '/opt/puppetlabs/puppet/cache/foreman_cache_data',
69
- '/opt/puppetlabs/puppet/cache/pulpcore_cache_data'
67
+ '/usr/local/bin/validate_postgresql_connection.sh'
70
68
  ]
71
69
  end
72
70
 
@@ -102,7 +100,13 @@ class Features::Installer < ForemanMaintain::Feature
102
100
  end
103
101
 
104
102
  def installer_arguments
105
- installer_args = ' --disable-system-checks'
103
+ installer_args = ''
104
+
105
+ if feature(:foreman_proxy) &&
106
+ feature(:foreman_proxy).with_content?
107
+ installer_args += ' --disable-system-checks'
108
+ end
109
+
106
110
  unless check_min_version('foreman', '2.1') || check_min_version('foreman-proxy', '2.1')
107
111
  installer_args += ' --upgrade' if can_upgrade?
108
112
  end
@@ -12,7 +12,7 @@ class Features::Katello < ForemanMaintain::Feature
12
12
  end
13
13
 
14
14
  def current_version
15
- @current_version ||= rpm_version('katello')
15
+ @current_version ||= package_version('katello')
16
16
  end
17
17
 
18
18
  def services
@@ -25,14 +25,12 @@ class Features::Nftables < ForemanMaintain::Feature
25
25
  execute!("nft add chain #{family} #{table} #{chain} #{chain_options}")
26
26
  end
27
27
 
28
- def add_rules(options = {})
28
+ def add_rule(options = {})
29
29
  family = options.fetch(:family, ip_family)
30
30
  table = options.fetch(:table, table_name)
31
31
  chain = options.fetch(:chain, chain_name)
32
- rules = options.fetch(:rules) # needs validation
33
- rules.each do |rule|
34
- execute!("nft add rule #{family} #{table} #{chain} #{rule}")
35
- end
32
+ rule = options.fetch(:rule) # needs validation
33
+ execute!("nft add rule #{family} #{table} #{chain} #{rule}")
36
34
  end
37
35
 
38
36
  def table_exist?(name = table_name)
@@ -11,6 +11,8 @@ class Features::PuppetServer < ForemanMaintain::Feature
11
11
  [
12
12
  '/etc/puppet',
13
13
  '/etc/puppetlabs',
14
+ '/opt/puppetlabs/puppet/cache/foreman_cache_data',
15
+ '/var/lib/puppet/foreman_cache_data',
14
16
  '/opt/puppetlabs/puppet/ssl/',
15
17
  '/var/lib/puppet/ssl',
16
18
  '/var/lib/puppet',
@@ -10,7 +10,7 @@ class Features::Satellite < ForemanMaintain::Feature
10
10
  end
11
11
 
12
12
  def current_version
13
- @current_version ||= rpm_version(package_name) || version_from_source
13
+ @current_version ||= package_version(package_name) || version_from_source
14
14
  end
15
15
 
16
16
  def package_name
@@ -4,7 +4,6 @@ module Procedures::Content
4
4
  description 'Prepare content for Pulp 3'
5
5
  for_feature :pulpcore
6
6
  param :quiet, 'Keep the output on a single line', :flag => true, :default => false
7
- do_not_whitelist
8
7
  end
9
8
 
10
9
  def run
@@ -9,7 +9,6 @@ module Procedures::Content
9
9
  end
10
10
 
11
11
  param :skip_deb, 'Do not run debian options in installer.'
12
- do_not_whitelist
13
12
  end
14
13
 
15
14
  def run
@@ -6,7 +6,7 @@ module Procedures::Foreman
6
6
  end
7
7
 
8
8
  def run
9
- execute!('FOREMAN_APIPIE_LANGS=en foreman-rake apipie:cache')
9
+ execute!('foreman-rake apipie:cache')
10
10
  end
11
11
  end
12
12
  end
@@ -6,14 +6,12 @@ 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 => []
10
9
  end
11
10
 
12
11
  def run
13
12
  assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
14
13
  package_manager.clean_cache(:assumeyes => assumeyes_val)
15
- opts = { :assumeyes => assumeyes_val, :yum_options => @yum_options }
16
- packages_action(:update, @packages, opts)
14
+ packages_action(:update, @packages, :assumeyes => assumeyes_val)
17
15
  rescue ForemanMaintain::Error::ExecutionError => e
18
16
  if @warn_on_errors
19
17
  set_status(:warning, e.message)
@@ -15,9 +15,6 @@ 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
21
18
  end
22
19
  end
23
20
  end
@@ -45,11 +45,6 @@ module ForemanMaintain::Scenarios
45
45
  add_step(Procedures::Service::Stop.new(:only => ['postgresql']))
46
46
  end
47
47
  restore_mongo_dump(backup)
48
-
49
- if feature(:instance).postgresql_local? && !backup.online_backup?
50
- add_step_with_context(Procedures::Restore::ReindexDatabases)
51
- end
52
-
53
48
  add_steps_with_context(Procedures::Pulp::Migrate,
54
49
  Procedures::Pulpcore::Migrate,
55
50
  Procedures::Restore::CandlepinResetMigrations)
@@ -1,12 +1,24 @@
1
1
  module ForemanMaintain::Scenarios
2
2
  class SelfUpgradeBase < ForemanMaintain::Scenario
3
- include ForemanMaintain::Concerns::Downstream
3
+ def enabled_system_repos_id
4
+ repository_manager.enabled_repos.keys
5
+ end
6
+
7
+ def enable_repos(repo_ids = stored_enabled_repos_ids)
8
+ add_step(Procedures::Repositories::Enable.new(repos: repo_ids))
9
+ end
10
+
11
+ def disable_repos(repo_ids = stored_enabled_repos_ids)
12
+ add_step(Procedures::Repositories::Disable.new(repos: repo_ids))
13
+ end
14
+
4
15
  def target_version
5
- @target_version ||= Gem::Version.new(current_version).bump.to_s
16
+ current_full_version = feature(:instance).downstream.current_version
17
+ @target_version ||= current_full_version.bump
6
18
  end
7
19
 
8
20
  def current_version
9
- feature(:instance).downstream.current_version.to_s[/^\d+\.\d+\.\d+/]
21
+ feature(:instance).downstream.current_minor_version
10
22
  end
11
23
 
12
24
  def maintenance_repo_label
@@ -31,6 +43,33 @@ module ForemanMaintain::Scenarios
31
43
  end
32
44
  end
33
45
 
46
+ def maintenance_repo_version
47
+ return '6' if current_version == '6.10'
48
+
49
+ current_version
50
+ end
51
+
52
+ def stored_enabled_repos_ids
53
+ @stored_enabled_repos_ids ||= begin
54
+ path = File.expand_path('enabled_repos.yml', ForemanMaintain.config.backup_dir)
55
+ @stored_enabled_repos_ids = File.file?(path) ? YAML.load(File.read(path)) : []
56
+ end
57
+ end
58
+
59
+ def all_maintenance_repos
60
+ repo_regex = if el7?
61
+ /rhel-\d-server-satellite-maintenance-\d.\d-rpms/
62
+ else
63
+ /satellite-maintenance-\d.\d-for-rhel-\d-x86_64-rpms/
64
+ end
65
+ stored_enabled_repos_ids.select { |id| !id.match(repo_regex).nil? }
66
+ end
67
+
68
+ def repos_ids_to_reenable
69
+ repos_ids_to_reenable = stored_enabled_repos_ids - all_maintenance_repos
70
+ repos_ids_to_reenable << maintenance_repo(maintenance_repo_version)
71
+ end
72
+
34
73
  def use_rhsm?
35
74
  return false if maintenance_repo_label
36
75
 
@@ -40,14 +79,6 @@ module ForemanMaintain::Scenarios
40
79
 
41
80
  true
42
81
  end
43
-
44
- def req_repos_to_update_pkgs
45
- if use_rhsm?
46
- main_rh_repos + [maintenance_repo_id(target_version)]
47
- else
48
- [maintenance_repo_id(target_version)]
49
- end
50
- end
51
82
  end
52
83
 
53
84
  class SelfUpgrade < SelfUpgradeBase
@@ -61,11 +92,28 @@ module ForemanMaintain::Scenarios
61
92
  def compose
62
93
  if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
63
94
  pkgs_to_update = %w[satellite-maintain rubygem-foreman_maintain]
64
- yum_options = req_repos_to_update_pkgs.map do |id|
65
- "--enablerepo=#{id}"
66
- end
67
- add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
68
- yum_options: yum_options))
95
+ add_step(Procedures::Repositories::BackupEnabledRepos.new)
96
+ disable_repos
97
+ add_step(Procedures::Repositories::Enable.new(repos: [maintenance_repo_id(target_version)],
98
+ use_rhsm: use_rhsm?))
99
+ add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true))
100
+ enable_repos(repos_ids_to_reenable)
101
+ end
102
+ end
103
+ end
104
+
105
+ class SelfUpgradeRescue < SelfUpgradeBase
106
+ metadata do
107
+ label :rescue_self_upgrade
108
+ description 'Disables all version specific maintenance repositories and,'\
109
+ "\nenables the repositories which were configured prior to self upgrade"
110
+ manual_detection
111
+ run_strategy :fail_slow
112
+ end
113
+
114
+ def compose
115
+ if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
116
+ enable_repos(repos_ids_to_reenable)
69
117
  end
70
118
  end
71
119
  end
@@ -40,7 +40,6 @@ module Scenarios::Capsule_6_11
40
40
  def compose
41
41
  add_steps(find_procedures(:pre_migrations))
42
42
  add_step(Procedures::Pulp::Remove.new(:assumeyes => true))
43
- add_step(Procedures::Content::FixPulpcoreArtifactOwnership.new(:assumeyes => true))
44
43
  add_step(Procedures::Service::Stop.new)
45
44
  end
46
45
  end
@@ -39,7 +39,6 @@ module Scenarios::Capsule_6_11_z
39
39
 
40
40
  def compose
41
41
  add_steps(find_procedures(:pre_migrations))
42
- add_step(Procedures::Content::FixPulpcoreArtifactOwnership.new(:assumeyes => true))
43
42
  add_step(Procedures::Service::Stop.new)
44
43
  end
45
44
  end
@@ -42,7 +42,6 @@ module Scenarios::Satellite_6_11
42
42
  def compose
43
43
  add_steps(find_procedures(:pre_migrations))
44
44
  add_step(Procedures::Pulp::Remove.new(:assumeyes => true))
45
- add_step(Procedures::Content::FixPulpcoreArtifactOwnership.new(:assumeyes => true))
46
45
  add_step(Procedures::Service::Stop.new)
47
46
  end
48
47
  end
@@ -62,7 +61,7 @@ module Scenarios::Satellite_6_11
62
61
  add_step(Procedures::Repositories::Setup.new(:version => '6.11'))
63
62
  add_step(Procedures::Packages::UnlockVersions.new)
64
63
  add_step(Procedures::Packages::Update.new(:assumeyes => true))
65
- add_step_with_context(Procedures::Installer::RunFor6_11)
64
+ add_step_with_context(Procedures::Installer::Upgrade)
66
65
  add_step(Procedures::Installer::UpgradeRakeTask)
67
66
  end
68
67
  end
@@ -39,7 +39,6 @@ module Scenarios::Satellite_6_11_z
39
39
 
40
40
  def compose
41
41
  add_steps(find_procedures(:pre_migrations))
42
- add_step(Procedures::Content::FixPulpcoreArtifactOwnership.new(:assumeyes => true))
43
42
  add_step(Procedures::Service::Stop.new)
44
43
  end
45
44
  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)
8
+ run_scenario(upgrade_scenario, upgrade_rescue_scenario)
9
9
  end
10
10
 
11
11
  def upgrade_scenario
@@ -13,6 +13,12 @@ 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
16
22
  end
17
23
  end
18
24
  end
@@ -66,8 +66,7 @@ module ForemanMaintain
66
66
  server_version_full = "#{server_version.major}.#{server_version.minor}"
67
67
  rh_repos.concat(product_specific_repos(server_version_full))
68
68
  if server_version > version('6.3')
69
- ansible_repo = ansible_repo(server_version)
70
- rh_repos << ansible_repo if ansible_repo
69
+ rh_repos << ansible_repo(server_version)
71
70
  end
72
71
 
73
72
  rh_repos
@@ -84,6 +83,8 @@ module ForemanMaintain
84
83
 
85
84
  if el7?
86
85
  "rhel-#{el_major_version}-server-ansible-#{ansible_version}-rpms"
86
+ else
87
+ "ansible-#{ansible_version}-for-rhel-#{el_major_version}-x86_64-rpms"
87
88
  end
88
89
  end
89
90
 
@@ -10,7 +10,7 @@ module ForemanMaintain
10
10
  unless table_exist?
11
11
  add_table
12
12
  add_chain(:chain_options => nftables_chain_options)
13
- add_rules(rules: nftables_rules)
13
+ add_rule(rule: nftables_rule)
14
14
  end
15
15
  end
16
16
 
@@ -22,8 +22,8 @@ module ForemanMaintain
22
22
  '{type filter hook input priority 0\\;}'
23
23
  end
24
24
 
25
- def nftables_rules
26
- ['iifname "lo" accept', 'tcp dport 443 reject']
25
+ def nftables_rule
26
+ 'tcp dport https reject'
27
27
  end
28
28
 
29
29
  def status_for_maintenance_mode
@@ -100,10 +100,6 @@ module ForemanMaintain
100
100
  @data[:advanced_run] = advanced_run
101
101
  end
102
102
 
103
- def do_not_whitelist
104
- @data[:do_not_whitelist] = true
105
- end
106
-
107
103
  def self.eval_dsl(metadata, &block)
108
104
  new(metadata).tap do |dsl|
109
105
  dsl.instance_eval(&block)
@@ -100,13 +100,12 @@ module ForemanMaintain
100
100
  end
101
101
 
102
102
  def packages_action(action, packages, options = {})
103
- options.validate_options!(:assumeyes, :yum_options)
103
+ options.validate_options!(:assumeyes)
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],
109
- :yum_options => options[:yum_options])
108
+ package_manager.update(packages, :assumeyes => options[:assumeyes])
110
109
  when :remove
111
110
  package_manager.remove(packages, :assumeyes => options[:assumeyes])
112
111
  else
@@ -116,7 +115,8 @@ module ForemanMaintain
116
115
 
117
116
  def package_version(name)
118
117
  # space for extension to support non-rpm distributions
119
- rpm_version(name)
118
+ pkg = package_manager.find_installed_package(name, '%{VERSION}')
119
+ version(pkg) unless pkg.nil?
120
120
  end
121
121
 
122
122
  def parse_csv(data)
@@ -133,13 +133,6 @@ module ForemanMaintain
133
133
  nil
134
134
  end
135
135
 
136
- def rpm_version(name)
137
- rpm_version = execute(%(rpm -q '#{name}' --queryformat="%{VERSION}"))
138
- if $CHILD_STATUS.success?
139
- version(rpm_version)
140
- end
141
- end
142
-
143
136
  def shellescape(string)
144
137
  Shellwords.escape(string)
145
138
  end
@@ -36,8 +36,12 @@ module ForemanMaintain::PackageManager
36
36
  sys.execute?(%(rpm -q #{packages_list}))
37
37
  end
38
38
 
39
- def find_installed_package(name)
40
- status, result = sys.execute_with_status(%(rpm -q '#{name}'))
39
+ def find_installed_package(name, queryformat = '')
40
+ rpm_cmd = "rpm -q '#{name}'"
41
+ unless queryformat.empty?
42
+ rpm_cmd += " --qf '#{queryformat}'"
43
+ end
44
+ status, result = sys.execute_with_status(rpm_cmd)
41
45
  if status == 0
42
46
  result
43
47
  end
@@ -55,8 +59,8 @@ module ForemanMaintain::PackageManager
55
59
  yum_action('remove', packages, :assumeyes => assumeyes)
56
60
  end
57
61
 
58
- def update(packages = [], assumeyes: false, yum_options: [])
59
- yum_action('update', packages, :assumeyes => assumeyes, :yum_options => yum_options)
62
+ def update(packages = [], assumeyes: false)
63
+ yum_action('update', packages, :assumeyes => assumeyes)
60
64
  end
61
65
 
62
66
  def clean_cache(assumeyes: false)
@@ -78,12 +82,12 @@ module ForemanMaintain::PackageManager
78
82
  sys.execute(find_cmd).split("\n")
79
83
  end
80
84
 
81
- def list_installed_packages(queryfm = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
82
- # The queryfm should only include valid tag(s) as per `rpm --querytag` list.
85
+ def list_installed_packages(queryformat = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
86
+ # The queryformat should only include valid tag(s) as per `rpm --querytags` list.
83
87
  # If any special formatting is required with querytag then it should be provided with tag i.e,
84
- # querytag = "--%{VENDOR}"
85
- # The queryfm string must end with '\n'
86
- sys.execute!("rpm -qa --qf '#{queryfm}'").split("\n")
88
+ # "--%{VENDOR}"
89
+ # The queryformat string must end with '\n'
90
+ sys.execute!("rpm -qa --qf '#{queryformat}'").split("\n")
87
91
  end
88
92
 
89
93
  private
@@ -116,12 +120,8 @@ module ForemanMaintain::PackageManager
116
120
  File.open(protector_config_file, 'w') { |file| file.puts config }
117
121
  end
118
122
 
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, [])
123
+ def yum_action(action, packages, with_status: false, assumeyes: false, valid_exit_statuses: [0])
124
+ yum_options = []
125
125
  packages = [packages].flatten(1)
126
126
  yum_options << '-y' if assumeyes
127
127
  yum_options << '--disableplugin=foreman-protector'
@@ -317,11 +317,7 @@ module ForemanMaintain
317
317
 
318
318
  steps_with_error = scenario.steps_with_error(:whitelisted => false)
319
319
  steps_with_skipped = scenario.steps_with_skipped(:whitelisted => true)
320
- not_skippable_steps = scenario.steps_with_error.select do |step|
321
- step.metadata[:do_not_whitelist] == true
322
- end
323
-
324
- steps_to_whitelist = steps_with_error + steps_with_skipped - not_skippable_steps
320
+ steps_to_whitelist = steps_with_error + steps_with_skipped
325
321
  unless steps_with_error.empty?
326
322
  message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
327
323
  The following steps ended up in failing state:
@@ -329,25 +325,11 @@ module ForemanMaintain
329
325
  %s
330
326
  MESSAGE
331
327
  whitelist_labels = steps_to_whitelist.map(&:label_dashed).join(',')
332
- unless whitelist_labels.empty?
333
- recommend << if scenario.detector.feature(:instance).downstream
334
- format(<<-MESSAGE.strip_heredoc, whitelist_labels)
335
- Resolve the failed steps and rerun the command.
336
-
337
- If the situation persists and, you are unclear what to do next,
338
- contact Red Hat Technical Support.
339
-
340
- In case the failures are false positives, use
341
- --whitelist="%s"
342
- MESSAGE
343
- else
344
- format(<<-MESSAGE.strip_heredoc, whitelist_labels)
345
- Resolve the failed steps and rerun the command.
346
- In case the failures are false positives, use
347
- --whitelist="%s"
348
- MESSAGE
349
- end
350
- end
328
+ recommend << format(<<-MESSAGE.strip_heredoc, whitelist_labels)
329
+ Resolve the failed steps and rerun
330
+ the command. In case the failures are false positives,
331
+ use --whitelist="%s"
332
+ MESSAGE
351
333
  end
352
334
 
353
335
  steps_with_warning = scenario.steps_with_warning(:whitelisted => false)
@@ -8,21 +8,16 @@ module ForemanMaintain::Utils
8
8
  @instance_parent_unit = options.fetch(:instance_parent_unit, nil)
9
9
  end
10
10
 
11
- def command(action, options = {})
12
- do_wait = options.fetch(:wait, true) # wait for service to start
11
+ def command(action)
13
12
  all = @options.fetch(:all, false)
14
13
  skip_enablement = @options.fetch(:skip_enablement, false)
15
14
  if skip_enablement && %w[enable disable].include?(action)
16
15
  return skip_enablement_message(action, @name)
17
16
  end
18
17
 
19
- if do_wait && File.exist?('/usr/sbin/service-wait')
20
- "service-wait #{@name} #{action}"
21
- else
22
- cmd = "systemctl #{action} #{@name}"
23
- cmd += ' --all' if all
24
- cmd
25
- end
18
+ cmd = "systemctl #{action} #{@name}"
19
+ cmd += ' --all' if all
20
+ cmd
26
21
  end
27
22
 
28
23
  def status
@@ -38,11 +33,11 @@ module ForemanMaintain::Utils
38
33
  end
39
34
 
40
35
  def enable
41
- execute('enable', :wait => false)
36
+ execute('enable')
42
37
  end
43
38
 
44
39
  def disable
45
- execute('disable', :wait => false)
40
+ execute('disable')
46
41
  end
47
42
 
48
43
  def running?
@@ -66,8 +61,8 @@ module ForemanMaintain::Utils
66
61
 
67
62
  private
68
63
 
69
- def execute(action, options = {})
70
- @sys.execute_with_status(command(action, options))
64
+ def execute(action)
65
+ @sys.execute_with_status(command(action))
71
66
  end
72
67
 
73
68
  def service_enabled_status
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.0.19'.freeze
2
+ VERSION = '1.1.1'.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.19
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-09 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.50.0
111
- - !ruby/object:Gem::Dependency
112
- name: minitest-stub-const
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
111
  description: Provides various features that helps keeping the Foreman/Satellite up
126
112
  and running.
127
113
  email: inecas@redhat.com
@@ -280,7 +266,6 @@ files:
280
266
  - definitions/procedures/foreman_tasks/ui_investigate.rb
281
267
  - definitions/procedures/hammer_setup.rb
282
268
  - definitions/procedures/installer/run.rb
283
- - definitions/procedures/installer/run_for_6_11.rb
284
269
  - definitions/procedures/installer/upgrade.rb
285
270
  - definitions/procedures/installer/upgrade_rake_task.rb
286
271
  - definitions/procedures/knowledge_base_article.rb
@@ -325,7 +310,6 @@ files:
325
310
  - definitions/procedures/restore/postgres_owner.rb
326
311
  - definitions/procedures/restore/pulpcore_dump.rb
327
312
  - definitions/procedures/restore/regenerate_queues.rb
328
- - definitions/procedures/restore/reindex_databases.rb
329
313
  - definitions/procedures/selinux/set_file_security.rb
330
314
  - definitions/procedures/service/base.rb
331
315
  - definitions/procedures/service/daemon_reload.rb
@@ -468,7 +452,7 @@ homepage: https://github.com/theforeman/foreman_maintain
468
452
  licenses:
469
453
  - GPL-3.0
470
454
  metadata: {}
471
- post_install_message:
455
+ post_install_message:
472
456
  rdoc_options: []
473
457
  require_paths:
474
458
  - lib
@@ -483,8 +467,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
483
467
  - !ruby/object:Gem::Version
484
468
  version: '0'
485
469
  requirements: []
486
- rubygems_version: 3.3.26
487
- signing_key:
470
+ rubygems_version: 3.0.9
471
+ signing_key:
488
472
  specification_version: 4
489
473
  summary: Foreman maintenance tool belt
490
474
  test_files: []
@@ -1,52 +0,0 @@
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
@@ -1,22 +0,0 @@
1
- module Procedures::Restore
2
- class ReindexDatabases < ForemanMaintain::Procedure
3
- include ForemanMaintain::Concerns::SystemService
4
-
5
- metadata do
6
- description 'REINDEX databases'
7
-
8
- confine do
9
- feature(:instance).postgresql_local?
10
- end
11
- end
12
-
13
- def run
14
- with_spinner('Reindexing the databases') do |spinner|
15
- feature(:service).handle_services(spinner, 'start', :only => ['postgresql'])
16
-
17
- spinner.update('Reindexing the databases')
18
- execute!('runuser - postgres -c "reindexdb -a"')
19
- end
20
- end
21
- end
22
- end