foreman_maintain 1.2.6 → 1.2.7

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: 193b1e7cefdc871725692b84d03636fab11dcf6a0de8928c7c8ff05179b8ddd8
4
- data.tar.gz: afdf239a676685fa3b793e78389d989029f6dd29ec806bb1cef4ee72a91c37fe
3
+ metadata.gz: 7ccc920a2ad9478b2248e92981f894eedfdb8b2daf9f26ecb45fbdef68d8f11a
4
+ data.tar.gz: b7a57772a0c219bdcd60ac45396643cd45c1d1b1edeaef7a55defffad14b5a71
5
5
  SHA512:
6
- metadata.gz: d2305610529e5ff51dc325daaaeee9da689259a0c1aeec88d155c8315d83da7551d0c00b8c5098439986602b039ae85bae3346dc679db184dc08bd856610b3d4
7
- data.tar.gz: f0fdf10df80d8a26552c1f74aed56d944b1324ef06fe8960c92aa9d8411cae211f24ff596d60c8a1fff2bae450901c40e9b478889fe118432323fb748ee07d6c
6
+ metadata.gz: 802d12634cbf41e4c2703c35c3b2e5843cbc7bf0c2f705199e9304e856de8c4115c1b9e5cad659ac3e38eae6fa0f2cfc1baf46c86e1b1433be0801188e3a1ee5
7
+ data.tar.gz: 79d2d5208fee0628b7fe6a1469b9c08a296a4ecb0ea9a9107f7f566e9b701055d1c09d21b898d4274b17ecc485af3d448564acdb873651ccbdad885f61b997b9
@@ -3,33 +3,11 @@ class Features::SyncPlans < ForemanMaintain::Feature
3
3
  label :sync_plans
4
4
  end
5
5
 
6
- def required_new_implementation
7
- @required_new_implementation ||=
8
- feature(:foreman_database).query(
9
- <<-SQL
10
- SELECT COUNT(1) FROM information_schema.table_constraints
11
- WHERE constraint_name='katello_sync_plan_foreman_tasks_recurring_logic_fk' AND table_name='katello_sync_plans'
12
- SQL
13
- ).first['count'].to_i > 0
14
- end
15
-
16
- def sync_plan_ids_by_status(enabled = true, filter_ids = nil)
17
- if filter_ids
18
- return [] if filter_ids.empty?
19
-
20
- ids_condition = filter_ids.map { |id| "'#{id}'" }.join(',')
21
- end
22
-
23
- if required_new_implementation
24
- query = <<-SQL
25
- select sp.id as id from katello_sync_plans sp inner join foreman_tasks_recurring_logics rl on sp.foreman_tasks_recurring_logic_id = rl.id
26
- where rl.state='#{enabled ? 'active' : 'disabled'}' #{ids_condition ? " AND sp.id IN (#{ids_condition})" : ''}
27
- SQL
28
- else
29
- query = <<-SQL
30
- SELECT id FROM katello_sync_plans WHERE enabled ='#{enabled ? 't' : 'f'}' #{ids_condition ? " AND id IN (#{ids_condition})" : ''}
31
- SQL
32
- end
6
+ def sync_plan_ids_by_status(enabled = true)
7
+ query = <<-SQL
8
+ select sp.id as id from katello_sync_plans sp inner join foreman_tasks_recurring_logics rl on sp.foreman_tasks_recurring_logic_id = rl.id
9
+ where rl.state='#{enabled ? 'active' : 'disabled'}'
10
+ SQL
33
11
  feature(:foreman_database).query(query).map { |r| r['id'].to_i }
34
12
  end
35
13
 
@@ -41,14 +19,17 @@ class Features::SyncPlans < ForemanMaintain::Feature
41
19
  feature(:foreman_database).query(query).map { |r| r['id'].to_i }
42
20
  end
43
21
 
44
- def make_disable(ids)
45
- update_records(ids, false)
22
+ def make_disable
23
+ cleanup_enabled_in_storage
24
+ update_records(sync_plan_ids_by_status(true), false)
25
+ @data[:disabled]
46
26
  end
47
27
 
48
28
  def make_enable
49
29
  # remove ids of sync plans which no longer exist in DB
50
30
  @data[:disabled] = validate_sync_plan_ids(@data[:disabled])
51
31
  update_records(@data[:disabled], true)
32
+ @data[:enabled]
52
33
  end
53
34
 
54
35
  def load_from_storage(storage)
@@ -80,11 +61,8 @@ class Features::SyncPlans < ForemanMaintain::Feature
80
61
  private
81
62
 
82
63
  def update_records(ids, enabled)
83
- ids_not_required_update = sync_plan_ids_by_status(enabled, ids)
84
- ids_required_update = ids - ids_not_required_update
85
- make_data_key_empty(enabled) if !ids_not_required_update.empty? && ids_required_update.empty?
86
64
  updated_record_ids = []
87
- ids_required_update.each do |sp_id|
65
+ ids.each do |sp_id|
88
66
  result = feature(:hammer).run("sync-plan update --id #{sp_id} --enabled #{enabled}")
89
67
  if result.include?('Sync plan updated')
90
68
  updated_record_ids << sp_id
@@ -92,29 +70,29 @@ class Features::SyncPlans < ForemanMaintain::Feature
92
70
  raise result
93
71
  end
94
72
  end
95
- updated_record_ids
96
73
  ensure
97
74
  update_data(enabled, updated_record_ids)
98
75
  end
99
76
 
100
77
  def data
101
78
  raise 'Use load_from_storage before accessing the data' unless defined? @data
102
-
103
79
  @data
104
80
  end
105
81
 
106
- def make_data_key_empty(enabled)
107
- key_name = enabled ? 'disabled' : 'enabled'
108
- @data[:"#{key_name}"] = []
82
+ def cleanup_enabled_in_storage
83
+ @data[:enabled] = []
109
84
  end
110
85
 
111
86
  def update_data(enabled, new_ids)
87
+ # init data
88
+ @data[:disabled] = [] unless @data[:disabled]
89
+ @data[:enabled] = [] unless @data[:enabled]
90
+
112
91
  if enabled
113
92
  @data[:disabled] -= new_ids
114
- @data[:enabled] = new_ids
93
+ @data[:enabled].concat(new_ids).uniq!
115
94
  else
116
- @data[:disabled] = [] unless @data[:disabled]
117
- @data[:enabled] = [] if @data[:disabled].empty?
95
+ @data[:enabled] -= new_ids
118
96
  @data[:disabled].concat(new_ids).uniq!
119
97
  end
120
98
  end
@@ -21,9 +21,8 @@ module Procedures::SyncPlans
21
21
  default_storage = ForemanMaintain.storage(:default)
22
22
  feature(:sync_plans).load_from_storage(default_storage)
23
23
  with_spinner('disabling sync plans') do |spinner|
24
- ids = feature(:sync_plans).sync_plan_ids_by_status(true)
25
- feature(:sync_plans).make_disable(ids)
26
- spinner.update "Total #{ids.length} sync plans are now disabled."
24
+ record_ids = feature(:sync_plans).make_disable
25
+ spinner.update "Total #{record_ids.length} sync plans are now disabled."
27
26
  end
28
27
  ensure
29
28
  feature(:sync_plans).save_to_storage(default_storage)
@@ -58,7 +58,6 @@ module ForemanMaintain::Scenarios
58
58
  Procedures::Backup::CompressData => :backup_dir,
59
59
  Procedures::Backup::Pulp => :backup_dir,
60
60
  Procedures::Backup::Online::Mongo => :backup_dir,
61
- Procedures::Backup::Online::PgGlobalObjects => :backup_dir,
62
61
  Procedures::Backup::Online::CandlepinDB => :backup_dir,
63
62
  Procedures::Backup::Online::ForemanDB => :backup_dir,
64
63
  Procedures::Backup::Online::PulpcoreDB => :backup_dir,
@@ -160,9 +159,6 @@ module ForemanMaintain::Scenarios
160
159
  end
161
160
 
162
161
  def include_dumps
163
- if feature(:instance).postgresql_local?
164
- add_step_with_context(Procedures::Backup::Online::PgGlobalObjects)
165
- end
166
162
  if feature(:instance).database_local?(:candlepin_database)
167
163
  add_step_with_context(Procedures::Backup::Online::CandlepinDB)
168
164
  end
@@ -217,7 +213,6 @@ module ForemanMaintain::Scenarios
217
213
  add_step_with_context(Procedures::Backup::Pulp, :ensure_unchanged => true)
218
214
  add_steps_with_context(
219
215
  Procedures::Backup::Online::Mongo,
220
- Procedures::Backup::Online::PgGlobalObjects,
221
216
  Procedures::Backup::Online::CandlepinDB,
222
217
  Procedures::Backup::Online::ForemanDB,
223
218
  Procedures::Backup::Online::PulpcoreDB
@@ -73,9 +73,6 @@ module ForemanMaintain::Scenarios
73
73
  end
74
74
 
75
75
  def restore_sql_dumps(backup)
76
- if backup.file_map[:pg_globals][:present]
77
- add_steps_with_context(Procedures::Restore::PgGlobalObjects)
78
- end
79
76
  if backup.file_map[:candlepin_dump][:present]
80
77
  add_steps_with_context(Procedures::Restore::CandlepinDump)
81
78
  end
@@ -108,7 +105,6 @@ module ForemanMaintain::Scenarios
108
105
  Checks::Restore::ValidateInterfaces => :backup_dir,
109
106
  Procedures::Restore::Configs => :backup_dir,
110
107
  Procedures::Restore::DropDatabases => :backup_dir,
111
- Procedures::Restore::PgGlobalObjects => :backup_dir,
112
108
  Procedures::Restore::CandlepinDump => :backup_dir,
113
109
  Procedures::Restore::ForemanDump => :backup_dir,
114
110
  Procedures::Restore::PulpcoreDump => :backup_dir,
@@ -69,6 +69,8 @@ module ForemanMaintain::Scenarios
69
69
  end
70
70
 
71
71
  def downstream_self_upgrade(pkgs_to_update)
72
+ ForemanMaintain.enable_maintenance_module
73
+
72
74
  if check_min_version('foreman', '2.5') || check_min_version('foreman-proxy', '2.5')
73
75
  yum_options = req_repos_to_update_pkgs.map do |id|
74
76
  "--enablerepo=#{id}"
@@ -0,0 +1,92 @@
1
+ module Scenarios::Capsule_6_14
2
+ class Abstract < ForemanMaintain::Scenario
3
+ def self.upgrade_metadata(&block)
4
+ metadata do
5
+ tags :upgrade_scenario
6
+ confine do
7
+ feature(:capsule) &&
8
+ (feature(:capsule).current_minor_version == '6.13' || \
9
+ ForemanMaintain.upgrade_in_progress == '6.14')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '6.14'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Capsule 6.14'
23
+ tags :pre_upgrade_checks
24
+ run_strategy :fail_slow
25
+ end
26
+
27
+ def compose
28
+ add_steps(find_checks(:default))
29
+ add_steps(find_checks(:pre_upgrade))
30
+ add_step(Checks::Foreman::CheckpointSegments)
31
+ add_step(Checks::Repositories::Validate.new(:version => '6.14'))
32
+ end
33
+ end
34
+
35
+ class PreMigrations < Abstract
36
+ upgrade_metadata do
37
+ description 'Procedures before migrating to Capsule 6.14'
38
+ tags :pre_migrations
39
+ end
40
+
41
+ def compose
42
+ add_steps(find_procedures(:pre_migrations))
43
+ add_step(Procedures::Service::Stop.new)
44
+ end
45
+ end
46
+
47
+ class Migrations < Abstract
48
+ upgrade_metadata do
49
+ description 'Migration scripts to Capsule 6.14'
50
+ tags :migrations
51
+ end
52
+
53
+ def set_context_mapping
54
+ context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
55
+ end
56
+
57
+ def compose
58
+ add_step(Procedures::Repositories::Setup.new(:version => '6.14'))
59
+ modules_to_enable = ["satellite-capsule:#{el_short_name}"]
60
+ add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
61
+ add_step(Procedures::Packages::UnlockVersions.new)
62
+ add_step(Procedures::Packages::Update.new(:assumeyes => true))
63
+ add_step_with_context(Procedures::Installer::Upgrade)
64
+ end
65
+ end
66
+
67
+ class PostMigrations < Abstract
68
+ upgrade_metadata do
69
+ description 'Procedures after migrating to Capsule 6.14'
70
+ tags :post_migrations
71
+ end
72
+
73
+ def compose
74
+ add_step(Procedures::RefreshFeatures)
75
+ add_step(Procedures::Service::Start.new)
76
+ add_steps(find_procedures(:post_migrations))
77
+ end
78
+ end
79
+
80
+ class PostUpgradeChecks < Abstract
81
+ upgrade_metadata do
82
+ description 'Checks after upgrading to Capsule 6.14'
83
+ tags :post_upgrade_checks
84
+ run_strategy :fail_slow
85
+ end
86
+
87
+ def compose
88
+ add_steps(find_checks(:default))
89
+ add_steps(find_checks(:post_upgrade))
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,92 @@
1
+ module Scenarios::Capsule_6_14_z
2
+ class Abstract < ForemanMaintain::Scenario
3
+ def self.upgrade_metadata(&block)
4
+ metadata do
5
+ tags :upgrade_scenario
6
+ confine do
7
+ feature(:capsule) &&
8
+ (feature(:capsule).current_minor_version == '6.14' || \
9
+ ForemanMaintain.upgrade_in_progress == '6.14.z')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '6.14.z'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Capsule 6.14.z'
23
+ tags :pre_upgrade_checks
24
+ run_strategy :fail_slow
25
+ end
26
+
27
+ def compose
28
+ add_steps(find_checks(:default))
29
+ add_steps(find_checks(:pre_upgrade))
30
+ add_step(Checks::Foreman::CheckpointSegments)
31
+ add_step(Checks::Repositories::Validate.new(:version => '6.14'))
32
+ end
33
+ end
34
+
35
+ class PreMigrations < Abstract
36
+ upgrade_metadata do
37
+ description 'Procedures before migrating to Capsule 6.14.z'
38
+ tags :pre_migrations
39
+ end
40
+
41
+ def compose
42
+ add_steps(find_procedures(:pre_migrations))
43
+ add_step(Procedures::Service::Stop.new)
44
+ end
45
+ end
46
+
47
+ class Migrations < Abstract
48
+ upgrade_metadata do
49
+ description 'Migration scripts to Capsule 6.14.z'
50
+ tags :migrations
51
+ end
52
+
53
+ def set_context_mapping
54
+ context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
55
+ end
56
+
57
+ def compose
58
+ add_step(Procedures::Repositories::Setup.new(:version => '6.14'))
59
+ modules_to_enable = ["satellite-capsule:#{el_short_name}"]
60
+ add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
61
+ add_step(Procedures::Packages::UnlockVersions.new)
62
+ add_step(Procedures::Packages::Update.new(:assumeyes => true))
63
+ add_step_with_context(Procedures::Installer::Upgrade)
64
+ end
65
+ end
66
+
67
+ class PostMigrations < Abstract
68
+ upgrade_metadata do
69
+ description 'Procedures after migrating to Capsule 6.14.z'
70
+ tags :post_migrations
71
+ end
72
+
73
+ def compose
74
+ add_step(Procedures::RefreshFeatures)
75
+ add_step(Procedures::Service::Start.new)
76
+ add_steps(find_procedures(:post_migrations))
77
+ end
78
+ end
79
+
80
+ class PostUpgradeChecks < Abstract
81
+ upgrade_metadata do
82
+ description 'Checks after upgrading to Capsule 6.14.z'
83
+ tags :post_upgrade_checks
84
+ run_strategy :fail_slow
85
+ end
86
+
87
+ def compose
88
+ add_steps(find_checks(:default))
89
+ add_steps(find_checks(:post_upgrade))
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,94 @@
1
+ module Scenarios::Satellite_6_14
2
+ class Abstract < ForemanMaintain::Scenario
3
+ def self.upgrade_metadata(&block)
4
+ metadata do
5
+ tags :upgrade_scenario
6
+ confine do
7
+ feature(:satellite) &&
8
+ (feature(:satellite).current_minor_version == '6.13' || \
9
+ ForemanMaintain.upgrade_in_progress == '6.14')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '6.14'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Satellite 6.14'
23
+ tags :pre_upgrade_checks
24
+ run_strategy :fail_slow
25
+ end
26
+
27
+ def compose
28
+ add_steps(find_checks(:default))
29
+ add_steps(find_checks(:pre_upgrade))
30
+ add_step(Checks::Foreman::CheckpointSegments)
31
+ add_step(Checks::Repositories::Validate.new(:version => '6.14'))
32
+ end
33
+ end
34
+
35
+ class PreMigrations < Abstract
36
+ upgrade_metadata do
37
+ description 'Procedures before migrating to Satellite 6.14'
38
+ tags :pre_migrations
39
+ end
40
+
41
+ def compose
42
+ add_steps(find_procedures(:pre_migrations))
43
+ add_step(Procedures::Service::Stop.new)
44
+ end
45
+ end
46
+
47
+ class Migrations < Abstract
48
+ upgrade_metadata do
49
+ description 'Migration scripts to Satellite 6.14'
50
+ tags :migrations
51
+ run_strategy :fail_fast
52
+ end
53
+
54
+ def set_context_mapping
55
+ context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
56
+ end
57
+
58
+ def compose
59
+ add_step(Procedures::Repositories::Setup.new(:version => '6.14'))
60
+ modules_to_enable = ["satellite:#{el_short_name}"]
61
+ add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
62
+ add_step(Procedures::Packages::UnlockVersions.new)
63
+ add_step(Procedures::Packages::Update.new(:assumeyes => true))
64
+ add_step_with_context(Procedures::Installer::Upgrade)
65
+ add_step(Procedures::Installer::UpgradeRakeTask)
66
+ end
67
+ end
68
+
69
+ class PostMigrations < Abstract
70
+ upgrade_metadata do
71
+ description 'Procedures after migrating to Satellite 6.14'
72
+ tags :post_migrations
73
+ end
74
+
75
+ def compose
76
+ add_step(Procedures::RefreshFeatures)
77
+ add_step(Procedures::Service::Start.new)
78
+ add_steps(find_procedures(:post_migrations))
79
+ end
80
+ end
81
+
82
+ class PostUpgradeChecks < Abstract
83
+ upgrade_metadata do
84
+ description 'Checks after upgrading to Satellite 6.14'
85
+ tags :post_upgrade_checks
86
+ run_strategy :fail_slow
87
+ end
88
+
89
+ def compose
90
+ add_steps(find_checks(:default))
91
+ add_steps(find_checks(:post_upgrade))
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,93 @@
1
+ module Scenarios::Satellite_6_14_z
2
+ class Abstract < ForemanMaintain::Scenario
3
+ def self.upgrade_metadata(&block)
4
+ metadata do
5
+ tags :upgrade_scenario
6
+ confine do
7
+ feature(:satellite) &&
8
+ (feature(:satellite).current_minor_version == '6.14' || \
9
+ ForemanMaintain.upgrade_in_progress == '6.14.z')
10
+ end
11
+ instance_eval(&block)
12
+ end
13
+ end
14
+
15
+ def target_version
16
+ '6.14.z'
17
+ end
18
+ end
19
+
20
+ class PreUpgradeCheck < Abstract
21
+ upgrade_metadata do
22
+ description 'Checks before upgrading to Satellite 6.14.z'
23
+ tags :pre_upgrade_checks
24
+ run_strategy :fail_slow
25
+ end
26
+
27
+ def compose
28
+ add_steps(find_checks(:default))
29
+ add_steps(find_checks(:pre_upgrade))
30
+ add_step(Checks::Foreman::CheckpointSegments)
31
+ add_step(Checks::Repositories::Validate.new(:version => '6.14'))
32
+ end
33
+ end
34
+
35
+ class PreMigrations < Abstract
36
+ upgrade_metadata do
37
+ description 'Procedures before migrating to Satellite 6.14.z'
38
+ tags :pre_migrations
39
+ end
40
+
41
+ def compose
42
+ add_steps(find_procedures(:pre_migrations))
43
+ add_step(Procedures::Service::Stop.new)
44
+ end
45
+ end
46
+
47
+ class Migrations < Abstract
48
+ upgrade_metadata do
49
+ description 'Migration scripts to Satellite 6.14.z'
50
+ tags :migrations
51
+ end
52
+
53
+ def set_context_mapping
54
+ context.map(:assumeyes, Procedures::Installer::Upgrade => :assumeyes)
55
+ end
56
+
57
+ def compose
58
+ add_step(Procedures::Repositories::Setup.new(:version => '6.14'))
59
+ modules_to_enable = ["satellite:#{el_short_name}"]
60
+ add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
61
+ add_step(Procedures::Packages::UnlockVersions.new)
62
+ add_step(Procedures::Packages::Update.new(:assumeyes => true))
63
+ add_step_with_context(Procedures::Installer::Upgrade)
64
+ add_step(Procedures::Installer::UpgradeRakeTask)
65
+ end
66
+ end
67
+
68
+ class PostMigrations < Abstract
69
+ upgrade_metadata do
70
+ description 'Procedures after migrating to Satellite 6.14.z'
71
+ tags :post_migrations
72
+ end
73
+
74
+ def compose
75
+ add_step(Procedures::RefreshFeatures)
76
+ add_step(Procedures::Service::Start.new)
77
+ add_steps(find_procedures(:post_migrations))
78
+ end
79
+ end
80
+
81
+ class PostUpgradeChecks < Abstract
82
+ upgrade_metadata do
83
+ description 'Checks after upgrading to Satellite 6.14.z'
84
+ tags :post_upgrade_checks
85
+ run_strategy :fail_slow
86
+ end
87
+
88
+ def compose
89
+ add_steps(find_checks(:default))
90
+ add_steps(find_checks(:post_upgrade))
91
+ end
92
+ end
93
+ end
@@ -108,11 +108,6 @@ module ForemanMaintain
108
108
  end
109
109
  end
110
110
 
111
- def restore_pg_globals(pg_globals, config = configuration)
112
- execute!(base_command(config, 'psql') + " -f #{pg_globals} postgres 2>/dev/null",
113
- :hidden_patterns => [config['password']])
114
- end
115
-
116
111
  def backup_local(backup_file, extra_tar_options = {})
117
112
  dir = extra_tar_options.fetch(:data_dir, data_dir)
118
113
  command = extra_tar_options.fetch(:command, 'create')
@@ -139,10 +134,6 @@ module ForemanMaintain
139
134
  @backup_dir ||= File.expand_path(ForemanMaintain.config.db_backup_dir)
140
135
  end
141
136
 
142
- def backup_global_objects(file)
143
- execute!("runuser - postgres -c 'pg_dumpall -g > #{file}'")
144
- end
145
-
146
137
  def perform_backup(config = configuration)
147
138
  file_path = backup_file_path(config)
148
139
  backup_cmd = backup_db_command(file_path, config)
@@ -9,6 +9,24 @@ module ForemanMaintain::PackageManager
9
9
  true
10
10
  end
11
11
 
12
+ def module_enabled?(name)
13
+ _status, result = info(name)
14
+ result.match?(/Stream.+\[e\].+/)
15
+ end
16
+
17
+ def enable_module(name)
18
+ dnf_action('module enable', name, assumeyes: true)
19
+ end
20
+
21
+ def module_exists?(name)
22
+ status, _result = info(name)
23
+ status == 0
24
+ end
25
+
26
+ def info(name)
27
+ dnf_action('module info', name, with_status: true, assumeyes: true)
28
+ end
29
+
12
30
  private
13
31
 
14
32
  def dnf_action(action, packages, with_status: false, assumeyes: false)
@@ -42,7 +42,6 @@ module ForemanMaintain
42
42
  :candlepin_dump => map_file(@backup_dir, 'candlepin.dump'),
43
43
  :mongo_dump => map_file(@backup_dir, 'mongo_dump'),
44
44
  :config_files => map_file(@backup_dir, 'config_files.tar.gz'),
45
- :pg_globals => map_file(@backup_dir, 'pg_globals.dump'),
46
45
  :metadata => map_file(@backup_dir, 'metadata.yml'),
47
46
  :pulpcore_dump => map_file(@backup_dir, 'pulpcore.dump')
48
47
  }
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.2.6'.freeze
2
+ VERSION = '1.2.7'.freeze
3
3
  end
@@ -178,6 +178,9 @@ module ForemanMaintain
178
178
  package_name, command = pkg_and_cmd_name
179
179
 
180
180
  puts "Checking for new version of #{package_name}..."
181
+
182
+ enable_maintenance_module
183
+
181
184
  if ForemanMaintain.package_manager.update_available?(main_package_name)
182
185
  puts "\nUpdating #{package_name} package."
183
186
  ForemanMaintain.package_manager.update(main_package_name, :assumeyes => true)
@@ -188,6 +191,19 @@ module ForemanMaintain
188
191
  puts "Nothing to update, can't find new version of #{package_name}."
189
192
  end
190
193
 
194
+ def enable_maintenance_module
195
+ return unless el? && !el7?
196
+
197
+ maintenance_module = 'satellite-maintenance:el8'
198
+ package_manager = ForemanMaintain.package_manager
199
+
200
+ if package_manager.module_exists?(maintenance_module) &&
201
+ !package_manager.module_enabled?(maintenance_module)
202
+ puts "\nEnabling #{maintenance_module} module"
203
+ package_manager.enable_module(maintenance_module)
204
+ end
205
+ end
206
+
191
207
  def main_package_name
192
208
  'rubygem-foreman_maintain'
193
209
  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.2.6
4
+ version: 1.2.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: 2023-02-23 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -241,7 +241,6 @@ files:
241
241
  - definitions/procedures/backup/online/candlepin_db.rb
242
242
  - definitions/procedures/backup/online/foreman_db.rb
243
243
  - definitions/procedures/backup/online/mongo.rb
244
- - definitions/procedures/backup/online/pg_global_objects.rb
245
244
  - definitions/procedures/backup/online/pulpcore_db.rb
246
245
  - definitions/procedures/backup/online/safety_confirmation.rb
247
246
  - definitions/procedures/backup/prepare_directory.rb
@@ -321,7 +320,6 @@ files:
321
320
  - definitions/procedures/restore/foreman_dump.rb
322
321
  - definitions/procedures/restore/installer_reset.rb
323
322
  - definitions/procedures/restore/mongo_dump.rb
324
- - definitions/procedures/restore/pg_global_objects.rb
325
323
  - definitions/procedures/restore/postgres_owner.rb
326
324
  - definitions/procedures/restore/pulpcore_dump.rb
327
325
  - definitions/procedures/restore/regenerate_queues.rb
@@ -355,6 +353,8 @@ files:
355
353
  - definitions/scenarios/upgrade_to_capsule_6_12_z.rb
356
354
  - definitions/scenarios/upgrade_to_capsule_6_13.rb
357
355
  - definitions/scenarios/upgrade_to_capsule_6_13_z.rb
356
+ - definitions/scenarios/upgrade_to_capsule_6_14.rb
357
+ - definitions/scenarios/upgrade_to_capsule_6_14_z.rb
358
358
  - definitions/scenarios/upgrade_to_capsule_6_8.rb
359
359
  - definitions/scenarios/upgrade_to_capsule_6_8_z.rb
360
360
  - definitions/scenarios/upgrade_to_capsule_6_9.rb
@@ -369,6 +369,8 @@ files:
369
369
  - definitions/scenarios/upgrade_to_satellite_6_12_z.rb
370
370
  - definitions/scenarios/upgrade_to_satellite_6_13.rb
371
371
  - definitions/scenarios/upgrade_to_satellite_6_13_z.rb
372
+ - definitions/scenarios/upgrade_to_satellite_6_14.rb
373
+ - definitions/scenarios/upgrade_to_satellite_6_14_z.rb
372
374
  - definitions/scenarios/upgrade_to_satellite_6_2.rb
373
375
  - definitions/scenarios/upgrade_to_satellite_6_2_z.rb
374
376
  - definitions/scenarios/upgrade_to_satellite_6_3.rb
@@ -1,29 +0,0 @@
1
- module Procedures::Backup
2
- module Online
3
- class PgGlobalObjects < ForemanMaintain::Procedure
4
- include ForemanMaintain::Concerns::SystemHelpers
5
-
6
- metadata do
7
- description 'Backup Postgres global objects online'
8
- tags :backup
9
- param :backup_dir, 'Directory where to backup to', :required => true
10
- confine do
11
- feature(:foreman_database) || feature(:candlepin_database)
12
- end
13
- end
14
-
15
- def run
16
- if feature(:instance).postgresql_local?
17
- local_db = if feature(:instance).database_local?(:foreman_database)
18
- :foreman_database
19
- else
20
- :candlepin_database
21
- end
22
- feature(local_db).backup_global_objects(File.join(@backup_dir, 'pg_globals.dump'))
23
- else
24
- skip 'Backup of global objects is not supported for remote databases.'
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,36 +0,0 @@
1
- module Procedures::Restore
2
- class PgGlobalObjects < ForemanMaintain::Procedure
3
- include ForemanMaintain::Concerns::SystemHelpers
4
-
5
- metadata do
6
- description 'Restore any existing postgresql global objects from backup'
7
-
8
- param :backup_dir,
9
- 'Path to backup directory',
10
- :required => true
11
-
12
- confine do
13
- feature(:foreman_database) || feature(:candlepin_database)
14
- end
15
- end
16
-
17
- def run
18
- backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
19
- restore_global_objects(backup.file_map[:pg_globals][:path])
20
- end
21
-
22
- def restore_global_objects(pg_global_file)
23
- if feature(:instance).postgresql_local?
24
- with_spinner('') do |spinner|
25
- feature(:service).handle_services(spinner, 'start', :only => ['postgresql'])
26
-
27
- spinner.update('Restoring postgresql global objects')
28
- local_db = feature(:foreman_database).local? ? :foreman_database : :candlepin_database
29
- feature(local_db).restore_pg_globals(pg_global_file)
30
- end
31
- else
32
- skip 'Restore of global objects is not supported for remote databases.'
33
- end
34
- end
35
- end
36
- end