foreman_maintain 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +48 -10
- data/bin/foreman-maintain-rotate-tar +18 -0
- data/definitions/checks/backup/certs_tar_exist.rb +24 -0
- data/definitions/checks/backup/directory_ready.rb +21 -0
- data/definitions/checks/candlepin/db_up.rb +29 -0
- data/definitions/checks/check_epel_repository.rb +21 -0
- data/definitions/checks/foreman/db_up.rb +29 -0
- data/definitions/checks/hammer_ping.rb +3 -1
- data/definitions/checks/mongo/db_up.rb +29 -0
- data/definitions/checks/mongo/tools_installed.rb +31 -0
- data/definitions/checks/repositories/validate.rb +0 -3
- data/definitions/checks/root_user.rb +12 -0
- data/definitions/features/candlepin.rb +16 -0
- data/definitions/features/candlepin_database.rb +3 -1
- data/definitions/features/downstream.rb +21 -22
- data/definitions/features/foreman_database.rb +2 -0
- data/definitions/features/foreman_proxy.rb +70 -7
- data/definitions/features/foreman_server.rb +29 -0
- data/definitions/features/foreman_tasks.rb +5 -1
- data/definitions/features/hammer.rb +158 -3
- data/definitions/features/installer.rb +106 -0
- data/definitions/features/instance.rb +39 -0
- data/definitions/features/katello.rb +43 -0
- data/definitions/features/mongo.rb +159 -0
- data/definitions/features/pulp.rb +30 -0
- data/definitions/features/puppet.rb +21 -0
- data/definitions/features/puppet_server.rb +2 -6
- data/definitions/features/service.rb +134 -0
- data/definitions/features/sync_plans.rb +1 -1
- data/definitions/features/tar.rb +69 -0
- data/definitions/procedures/backup/accessibility_confirmation.rb +14 -0
- data/definitions/procedures/backup/clean.rb +16 -0
- data/definitions/procedures/backup/compress_data.rb +26 -0
- data/definitions/procedures/backup/config_files.rb +36 -0
- data/definitions/procedures/backup/metadata.rb +56 -0
- data/definitions/procedures/backup/offline/candlepin_db.rb +57 -0
- data/definitions/procedures/backup/offline/foreman_db.rb +57 -0
- data/definitions/procedures/backup/offline/mongo.rb +56 -0
- data/definitions/procedures/backup/online/candlepin_db.rb +20 -0
- data/definitions/procedures/backup/online/foreman_db.rb +20 -0
- data/definitions/procedures/backup/online/mongo.rb +21 -0
- data/definitions/procedures/backup/online/pg_global_objects.rb +23 -0
- data/definitions/procedures/backup/online/safety_confirmation.rb +25 -0
- data/definitions/procedures/backup/prepare_directory.rb +29 -0
- data/definitions/procedures/backup/pulp.rb +68 -0
- data/definitions/procedures/backup/snapshot/clean_mount.rb +24 -0
- data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +47 -0
- data/definitions/procedures/backup/snapshot/mount_base.rb +27 -0
- data/definitions/procedures/backup/snapshot/mount_candlepin_db.rb +48 -0
- data/definitions/procedures/backup/snapshot/mount_foreman_db.rb +48 -0
- data/definitions/procedures/backup/snapshot/mount_mongo.rb +35 -0
- data/definitions/procedures/backup/snapshot/mount_pulp.rb +24 -0
- data/definitions/procedures/backup/snapshot/prepare_mount.rb +16 -0
- data/definitions/procedures/foreman_tasks/fetch_tasks_status.rb +1 -0
- data/definitions/procedures/hammer_setup.rb +4 -39
- data/definitions/procedures/installer/upgrade.rb +1 -21
- data/definitions/procedures/repositories/setup.rb +0 -4
- data/definitions/procedures/service/base.rb +31 -0
- data/definitions/procedures/service/disable.rb +14 -0
- data/definitions/procedures/service/enable.rb +14 -0
- data/definitions/procedures/service/list.rb +26 -0
- data/definitions/procedures/service/restart.rb +49 -0
- data/definitions/procedures/service/start.rb +14 -0
- data/definitions/procedures/service/status.rb +14 -0
- data/definitions/procedures/service/stop.rb +14 -0
- data/definitions/scenarios/backup.rb +242 -0
- data/definitions/scenarios/services.rb +156 -0
- data/definitions/scenarios/upgrade_to_satellite_6_2.rb +2 -2
- data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +2 -2
- data/definitions/scenarios/upgrade_to_satellite_6_3.rb +2 -2
- data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +2 -2
- data/definitions/scenarios/upgrade_to_satellite_6_4.rb +79 -0
- data/definitions/scenarios/upgrade_to_satellite_6_4_z.rb +79 -0
- data/lib/foreman_maintain.rb +5 -0
- data/lib/foreman_maintain/cli.rb +4 -0
- data/lib/foreman_maintain/cli/backup_command.rb +157 -0
- data/lib/foreman_maintain/cli/base.rb +18 -8
- data/lib/foreman_maintain/cli/service_command.rb +112 -0
- data/lib/foreman_maintain/cli/transform_clamp_options.rb +1 -1
- data/lib/foreman_maintain/concerns/base_database.rb +57 -5
- data/lib/foreman_maintain/concerns/hammer.rb +0 -9
- data/lib/foreman_maintain/concerns/metadata.rb +3 -1
- data/lib/foreman_maintain/concerns/reporter.rb +12 -0
- data/lib/foreman_maintain/concerns/system_helpers.rb +45 -2
- data/lib/foreman_maintain/detector.rb +3 -3
- data/lib/foreman_maintain/error.rb +12 -0
- data/lib/foreman_maintain/executable.rb +29 -6
- data/lib/foreman_maintain/feature.rb +15 -0
- data/lib/foreman_maintain/param.rb +4 -3
- data/lib/foreman_maintain/reporter.rb +6 -2
- data/lib/foreman_maintain/reporter/cli_reporter.rb +26 -10
- data/lib/foreman_maintain/runner.rb +26 -15
- data/lib/foreman_maintain/runner/execution.rb +5 -1
- data/lib/foreman_maintain/scenario.rb +11 -3
- data/lib/foreman_maintain/upgrade_runner.rb +0 -2
- data/lib/foreman_maintain/utils.rb +2 -2
- data/lib/foreman_maintain/utils/command_runner.rb +0 -2
- data/lib/foreman_maintain/utils/hash_tools.rb +21 -0
- data/lib/foreman_maintain/utils/mongo_core.rb +37 -0
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +58 -8
- data/definitions/features/katello_service.rb +0 -118
- data/definitions/procedures/katello_service/restart.rb +0 -24
- data/definitions/procedures/katello_service/start.rb +0 -19
- data/definitions/procedures/katello_service/stop.rb +0 -17
- data/lib/foreman_maintain/utils/facter.rb +0 -21
- data/lib/foreman_maintain/utils/hammer.rb +0 -79
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'foreman_maintain/utils/command_runner'
|
2
2
|
require 'foreman_maintain/utils/disk'
|
3
|
-
require 'foreman_maintain/utils/
|
3
|
+
require 'foreman_maintain/utils/hash_tools'
|
4
4
|
require 'foreman_maintain/utils/curl_response'
|
5
|
-
require 'foreman_maintain/utils/
|
5
|
+
require 'foreman_maintain/utils/mongo_core'
|
@@ -55,7 +55,6 @@ module ForemanMaintain
|
|
55
55
|
|
56
56
|
private
|
57
57
|
|
58
|
-
# rubocop:disable Metrics/AbcSize
|
59
58
|
def run_interactively
|
60
59
|
# use tmp files to capture output and exit status of the command when
|
61
60
|
# running interactively
|
@@ -75,7 +74,6 @@ module ForemanMaintain
|
|
75
74
|
log_file.close
|
76
75
|
exit_file.close
|
77
76
|
end
|
78
|
-
# rubocop:enable Metrics/AbcSize
|
79
77
|
|
80
78
|
def run_non_interactively
|
81
79
|
IO.popen(full_command, 'r+') do |f|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ForemanMaintain::Utils
|
2
|
+
module HashTools
|
3
|
+
def self.deep_merge!(h, other_h)
|
4
|
+
other_h = symbolize_hash(other_h)
|
5
|
+
|
6
|
+
h.merge!(other_h) do |_key, old_val, new_val|
|
7
|
+
if old_val.is_a?(Hash) && new_val.is_a?(Hash)
|
8
|
+
deep_merge!(old_val, new_val)
|
9
|
+
elsif old_val.is_a?(Array) && new_val.is_a?(Array)
|
10
|
+
old_val + new_val
|
11
|
+
else
|
12
|
+
new_val
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.symbolize_hash(h)
|
18
|
+
h.inject({}) { |sym_hash, (k, v)| sym_hash.update(k.to_sym => v) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ForemanMaintain::Utils
|
2
|
+
class MongoCore
|
3
|
+
def services
|
4
|
+
{ 'mongod' => 5 }
|
5
|
+
end
|
6
|
+
|
7
|
+
def server_config_files
|
8
|
+
['/etc/mongod.conf']
|
9
|
+
end
|
10
|
+
|
11
|
+
def client_command
|
12
|
+
'mongo'
|
13
|
+
end
|
14
|
+
|
15
|
+
def dump_command
|
16
|
+
'mongodump'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class MongoCore34 < MongoCore
|
21
|
+
def services
|
22
|
+
{ 'rh-mongodb34-mongod' => 5 }
|
23
|
+
end
|
24
|
+
|
25
|
+
def server_config_files
|
26
|
+
['/etc/opt/rh/rh-mongodb34/mongod.conf']
|
27
|
+
end
|
28
|
+
|
29
|
+
def client_command
|
30
|
+
'scl enable rh-mongodb34 -- mongo'
|
31
|
+
end
|
32
|
+
|
33
|
+
def dump_command
|
34
|
+
'scl enable rh-mongodb34 -- mongodump'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
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: 0.
|
4
|
+
version: 0.2.0
|
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: 2018-
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -108,11 +108,17 @@ files:
|
|
108
108
|
- LICENSE
|
109
109
|
- README.md
|
110
110
|
- bin/foreman-maintain
|
111
|
+
- bin/foreman-maintain-rotate-tar
|
111
112
|
- bin/passenger-recycler
|
112
113
|
- config/foreman_maintain.yml.example
|
113
114
|
- config/foreman_maintain.yml.packaging
|
115
|
+
- definitions/checks/backup/certs_tar_exist.rb
|
116
|
+
- definitions/checks/backup/directory_ready.rb
|
117
|
+
- definitions/checks/candlepin/db_up.rb
|
114
118
|
- definitions/checks/candlepin/validate_db.rb
|
119
|
+
- definitions/checks/check_epel_repository.rb
|
115
120
|
- definitions/checks/disk/performance.rb
|
121
|
+
- definitions/checks/foreman/db_up.rb
|
116
122
|
- definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb
|
117
123
|
- definitions/checks/foreman_tasks/invalid/check_old.rb
|
118
124
|
- definitions/checks/foreman_tasks/invalid/check_pending_state.rb
|
@@ -120,9 +126,13 @@ files:
|
|
120
126
|
- definitions/checks/foreman_tasks/not_paused.rb
|
121
127
|
- definitions/checks/foreman_tasks/not_running.rb
|
122
128
|
- definitions/checks/hammer_ping.rb
|
129
|
+
- definitions/checks/mongo/db_up.rb
|
130
|
+
- definitions/checks/mongo/tools_installed.rb
|
123
131
|
- definitions/checks/remote_execution/verify_settings_file_already_exists.rb
|
124
132
|
- definitions/checks/repositories/validate.rb
|
133
|
+
- definitions/checks/root_user.rb
|
125
134
|
- definitions/checks/system_registration.rb
|
135
|
+
- definitions/features/candlepin.rb
|
126
136
|
- definitions/features/candlepin_database.rb
|
127
137
|
- definitions/features/downstream.rb
|
128
138
|
- definitions/features/foreman_1_11_x.rb
|
@@ -132,12 +142,40 @@ files:
|
|
132
142
|
- definitions/features/foreman_server.rb
|
133
143
|
- definitions/features/foreman_tasks.rb
|
134
144
|
- definitions/features/hammer.rb
|
145
|
+
- definitions/features/installer.rb
|
146
|
+
- definitions/features/instance.rb
|
135
147
|
- definitions/features/katello.rb
|
136
|
-
- definitions/features/
|
148
|
+
- definitions/features/mongo.rb
|
137
149
|
- definitions/features/pulp.rb
|
150
|
+
- definitions/features/puppet.rb
|
138
151
|
- definitions/features/puppet_server.rb
|
152
|
+
- definitions/features/service.rb
|
139
153
|
- definitions/features/sync_plans.rb
|
154
|
+
- definitions/features/tar.rb
|
140
155
|
- definitions/features/upstream.rb
|
156
|
+
- definitions/procedures/backup/accessibility_confirmation.rb
|
157
|
+
- definitions/procedures/backup/clean.rb
|
158
|
+
- definitions/procedures/backup/compress_data.rb
|
159
|
+
- definitions/procedures/backup/config_files.rb
|
160
|
+
- definitions/procedures/backup/metadata.rb
|
161
|
+
- definitions/procedures/backup/offline/candlepin_db.rb
|
162
|
+
- definitions/procedures/backup/offline/foreman_db.rb
|
163
|
+
- definitions/procedures/backup/offline/mongo.rb
|
164
|
+
- definitions/procedures/backup/online/candlepin_db.rb
|
165
|
+
- definitions/procedures/backup/online/foreman_db.rb
|
166
|
+
- definitions/procedures/backup/online/mongo.rb
|
167
|
+
- definitions/procedures/backup/online/pg_global_objects.rb
|
168
|
+
- definitions/procedures/backup/online/safety_confirmation.rb
|
169
|
+
- definitions/procedures/backup/prepare_directory.rb
|
170
|
+
- definitions/procedures/backup/pulp.rb
|
171
|
+
- definitions/procedures/backup/snapshot/clean_mount.rb
|
172
|
+
- definitions/procedures/backup/snapshot/logical_volume_confirmation.rb
|
173
|
+
- definitions/procedures/backup/snapshot/mount_base.rb
|
174
|
+
- definitions/procedures/backup/snapshot/mount_candlepin_db.rb
|
175
|
+
- definitions/procedures/backup/snapshot/mount_foreman_db.rb
|
176
|
+
- definitions/procedures/backup/snapshot/mount_mongo.rb
|
177
|
+
- definitions/procedures/backup/snapshot/mount_pulp.rb
|
178
|
+
- definitions/procedures/backup/snapshot/prepare_mount.rb
|
141
179
|
- definitions/procedures/candlepin/delete_orphaned_records_from_env_content.rb
|
142
180
|
- definitions/procedures/foreman_tasks/delete.rb
|
143
181
|
- definitions/procedures/foreman_tasks/fetch_tasks_status.rb
|
@@ -145,9 +183,6 @@ files:
|
|
145
183
|
- definitions/procedures/foreman_tasks/ui_investigate.rb
|
146
184
|
- definitions/procedures/hammer_setup.rb
|
147
185
|
- definitions/procedures/installer/upgrade.rb
|
148
|
-
- definitions/procedures/katello_service/restart.rb
|
149
|
-
- definitions/procedures/katello_service/start.rb
|
150
|
-
- definitions/procedures/katello_service/stop.rb
|
151
186
|
- definitions/procedures/knowledge_base_article.rb
|
152
187
|
- definitions/procedures/maintenance_mode/disable.rb
|
153
188
|
- definitions/procedures/maintenance_mode/enable.rb
|
@@ -156,12 +191,24 @@ files:
|
|
156
191
|
- definitions/procedures/passenger_recycler.rb
|
157
192
|
- definitions/procedures/remote_execution/remove_existing_settingsd.rb
|
158
193
|
- definitions/procedures/repositories/setup.rb
|
194
|
+
- definitions/procedures/service/base.rb
|
195
|
+
- definitions/procedures/service/disable.rb
|
196
|
+
- definitions/procedures/service/enable.rb
|
197
|
+
- definitions/procedures/service/list.rb
|
198
|
+
- definitions/procedures/service/restart.rb
|
199
|
+
- definitions/procedures/service/start.rb
|
200
|
+
- definitions/procedures/service/status.rb
|
201
|
+
- definitions/procedures/service/stop.rb
|
159
202
|
- definitions/procedures/sync_plans/disable.rb
|
160
203
|
- definitions/procedures/sync_plans/enable.rb
|
204
|
+
- definitions/scenarios/backup.rb
|
205
|
+
- definitions/scenarios/services.rb
|
161
206
|
- definitions/scenarios/upgrade_to_satellite_6_2.rb
|
162
207
|
- definitions/scenarios/upgrade_to_satellite_6_2_z.rb
|
163
208
|
- definitions/scenarios/upgrade_to_satellite_6_3.rb
|
164
209
|
- definitions/scenarios/upgrade_to_satellite_6_3_z.rb
|
210
|
+
- definitions/scenarios/upgrade_to_satellite_6_4.rb
|
211
|
+
- definitions/scenarios/upgrade_to_satellite_6_4_z.rb
|
165
212
|
- lib/foreman_maintain.rb
|
166
213
|
- lib/foreman_maintain/check.rb
|
167
214
|
- lib/foreman_maintain/cli.rb
|
@@ -171,8 +218,10 @@ files:
|
|
171
218
|
- lib/foreman_maintain/cli/advanced/procedure/run_command.rb
|
172
219
|
- lib/foreman_maintain/cli/advanced/procedure_command.rb
|
173
220
|
- lib/foreman_maintain/cli/advanced_command.rb
|
221
|
+
- lib/foreman_maintain/cli/backup_command.rb
|
174
222
|
- lib/foreman_maintain/cli/base.rb
|
175
223
|
- lib/foreman_maintain/cli/health_command.rb
|
224
|
+
- lib/foreman_maintain/cli/service_command.rb
|
176
225
|
- lib/foreman_maintain/cli/transform_clamp_options.rb
|
177
226
|
- lib/foreman_maintain/cli/upgrade_command.rb
|
178
227
|
- lib/foreman_maintain/concerns/base_database.rb
|
@@ -180,6 +229,7 @@ files:
|
|
180
229
|
- lib/foreman_maintain/concerns/hammer.rb
|
181
230
|
- lib/foreman_maintain/concerns/logger.rb
|
182
231
|
- lib/foreman_maintain/concerns/metadata.rb
|
232
|
+
- lib/foreman_maintain/concerns/reporter.rb
|
183
233
|
- lib/foreman_maintain/concerns/scenario_metadata.rb
|
184
234
|
- lib/foreman_maintain/concerns/system_helpers.rb
|
185
235
|
- lib/foreman_maintain/config.rb
|
@@ -211,8 +261,8 @@ files:
|
|
211
261
|
- lib/foreman_maintain/utils/disk/io/file_system.rb
|
212
262
|
- lib/foreman_maintain/utils/disk/nil_device.rb
|
213
263
|
- lib/foreman_maintain/utils/disk/stats.rb
|
214
|
-
- lib/foreman_maintain/utils/
|
215
|
-
- lib/foreman_maintain/utils/
|
264
|
+
- lib/foreman_maintain/utils/hash_tools.rb
|
265
|
+
- lib/foreman_maintain/utils/mongo_core.rb
|
216
266
|
- lib/foreman_maintain/version.rb
|
217
267
|
- lib/foreman_maintain/yaml_storage.rb
|
218
268
|
homepage: https://github.com/theforeman/foreman_maintain
|
@@ -1,118 +0,0 @@
|
|
1
|
-
class Features::KatelloService < ForemanMaintain::Feature
|
2
|
-
metadata do
|
3
|
-
label :katello_service
|
4
|
-
end
|
5
|
-
|
6
|
-
RETRIES_FOR_SERVICES_RESTART = 5
|
7
|
-
PING_RETRY_INTERVAL = 30
|
8
|
-
|
9
|
-
def make_stop(spinner, options = {})
|
10
|
-
services = find_services_for_only_filter(running_services, options)
|
11
|
-
if services.empty?
|
12
|
-
spinner.update 'No katello service running'
|
13
|
-
yield if block_given?
|
14
|
-
else
|
15
|
-
begin
|
16
|
-
filters = construct_filters(services)
|
17
|
-
spinner.update 'Stopping katello running services..'
|
18
|
-
execute!("katello-service stop #{filters}")
|
19
|
-
yield if block_given?
|
20
|
-
ensure
|
21
|
-
start_stopped_services_using_filters(spinner, filters) if block_given?
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def make_start(spinner, options = {})
|
27
|
-
services = find_services_for_only_filter(stopped_services, options)
|
28
|
-
if services.empty?
|
29
|
-
spinner.update 'No katello service to start'
|
30
|
-
else
|
31
|
-
filters = construct_filters(services)
|
32
|
-
spinner.update 'Starting katello services..'
|
33
|
-
execute!("katello-service start #{filters}")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def restart(options = {})
|
38
|
-
if options[:only] || options[:exclude]
|
39
|
-
filters = construct_filters(options[:only], options[:exclude])
|
40
|
-
execute!("katello-service restart #{filters}")
|
41
|
-
else
|
42
|
-
execute!('katello-service restart')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def hammer_ping_retry(spinner)
|
47
|
-
RETRIES_FOR_SERVICES_RESTART.times do |retry_count|
|
48
|
-
msg = "Try #{retry_count + 1}/#{RETRIES_FOR_SERVICES_RESTART}: checking status by hammer ping"
|
49
|
-
spinner.update msg
|
50
|
-
result = feature(:hammer).hammer_ping_cmd
|
51
|
-
if result[:success]
|
52
|
-
spinner.update 'All services are running.'
|
53
|
-
break
|
54
|
-
elsif retry_count < (RETRIES_FOR_SERVICES_RESTART - 1)
|
55
|
-
apply_sleep_before_retry(spinner, result)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
rescue StandardError => e
|
59
|
-
logger.error e.message
|
60
|
-
end
|
61
|
-
|
62
|
-
def service_list
|
63
|
-
@service_list ||= katello_service_names.map { |s| s.gsub('.service', '') }
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def apply_sleep_before_retry(spinner, result)
|
69
|
-
puts "\n#{result[:message]}"
|
70
|
-
spinner.update "Waiting #{PING_RETRY_INTERVAL} seconds before retry."
|
71
|
-
sleep PING_RETRY_INTERVAL
|
72
|
-
end
|
73
|
-
|
74
|
-
def construct_filters(only_services, exclude_services = [])
|
75
|
-
filters = ''
|
76
|
-
unless only_services.empty?
|
77
|
-
if feature(:downstream) && feature(:downstream).current_minor_version <= '6.1'
|
78
|
-
exclude_services.concat(service_list - only_services)
|
79
|
-
exclude_services.uniq!
|
80
|
-
else
|
81
|
-
filters += "--only #{only_services.join(',')}"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
unless exclude_services.empty?
|
85
|
-
filters += "--exclude #{exclude_services.join(',')}"
|
86
|
-
end
|
87
|
-
filters
|
88
|
-
end
|
89
|
-
|
90
|
-
def start_stopped_services_using_filters(spinner, filters)
|
91
|
-
spinner.update 'Starting katello services..'
|
92
|
-
execute("katello-service start #{filters}")
|
93
|
-
end
|
94
|
-
|
95
|
-
def find_services_for_only_filter(curr_services, options)
|
96
|
-
defaults = { :only => [], :exclude => [] }
|
97
|
-
options = defaults.merge(options)
|
98
|
-
curr_services &= options[:only] unless options[:only].empty?
|
99
|
-
curr_services - options[:exclude]
|
100
|
-
end
|
101
|
-
|
102
|
-
def running_services
|
103
|
-
find_services_by_state(" -w 'running'")
|
104
|
-
end
|
105
|
-
|
106
|
-
def stopped_services
|
107
|
-
find_services_by_state(" -w 'dead'")
|
108
|
-
end
|
109
|
-
|
110
|
-
def katello_service_names
|
111
|
-
@katello_service_names ||= execute("katello-service list|awk '{print $1}'").split(/\n/)
|
112
|
-
end
|
113
|
-
|
114
|
-
def find_services_by_state(state)
|
115
|
-
services_by_state = execute("systemctl --all |grep #{state}|awk '{print $1}'").split(/\n/)
|
116
|
-
(katello_service_names & services_by_state).map { |s| s.gsub('.service', '') }
|
117
|
-
end
|
118
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Procedures::KatelloService
|
2
|
-
class Restart < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'katello-service restart'
|
5
|
-
param :only, 'A comma-separated list of services to include', :array => true
|
6
|
-
param :exclude, 'A comma-separated list of services to skip', :array => true
|
7
|
-
end
|
8
|
-
|
9
|
-
def run
|
10
|
-
with_spinner('restarting katello service(s)') do |spinner|
|
11
|
-
spinner.update('Restarting services')
|
12
|
-
feature(:katello_service).restart(:only => @only, :exclude => @exclude)
|
13
|
-
feature(:katello_service).hammer_ping_retry(spinner)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def runtime_message
|
18
|
-
msg = 'katello-service restart'
|
19
|
-
msg += " --only #{@only.join(',')}" unless @only.empty?
|
20
|
-
msg += " --exclude #{@exclude.join(',')}" unless @exclude.empty?
|
21
|
-
msg
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Procedures::KatelloService
|
2
|
-
class Start < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'katello-service start'
|
5
|
-
param :only, 'A comma-separated list of services to include', :array => true
|
6
|
-
param :exclude, 'A comma-separated list of services to skip', :array => true
|
7
|
-
for_feature :katello_service
|
8
|
-
tags :katello_service_start
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
with_spinner('stopping katello service(s)') do |spinner|
|
13
|
-
feature(:katello_service).make_start(
|
14
|
-
spinner, :only => @only, :exclude => @exclude
|
15
|
-
)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Procedures::KatelloService
|
2
|
-
class Stop < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
description 'katello-service stop'
|
5
|
-
param :only, 'A comma-separated list of services to include', :array => true
|
6
|
-
param :exclude, 'A comma-separated list of services to skip', :array => true
|
7
|
-
for_feature :katello_service
|
8
|
-
tags :katello_service_stop
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
with_spinner('stopping katello service(s)') do |spinner|
|
13
|
-
feature(:katello_service).make_stop(spinner, :only => @only, :exclude => @exclude)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ForemanMaintain::Utils
|
2
|
-
module Facter
|
3
|
-
include ForemanMaintain::Concerns::SystemHelpers
|
4
|
-
|
5
|
-
FACTER_FILES = %w[/usr/bin/facter /opt/puppetlabs/bin/facter].freeze
|
6
|
-
|
7
|
-
def self.package
|
8
|
-
puppet_version = version(execute!('puppet --version'))
|
9
|
-
|
10
|
-
puppet_version.major >= 4 ? 'puppet-agent' : 'facter'
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.path
|
14
|
-
FACTER_FILES.find { |path| File.exist?(path) }
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.os_major_release
|
18
|
-
execute!("#{path} operatingsystemmajrelease")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|