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
@@ -0,0 +1,39 @@
|
|
1
|
+
class Features::Instance < ForemanMaintain::Feature
|
2
|
+
metadata do
|
3
|
+
label :instance
|
4
|
+
end
|
5
|
+
|
6
|
+
def foreman_proxy_product_name
|
7
|
+
feature(:downstream) ? 'Capsule' : 'Foreman Proxy'
|
8
|
+
end
|
9
|
+
|
10
|
+
def server_product_name
|
11
|
+
if feature(:downstream)
|
12
|
+
'Satellite'
|
13
|
+
elsif feature(:katello)
|
14
|
+
'Katello'
|
15
|
+
else
|
16
|
+
'Foreman'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def external_proxy?
|
21
|
+
!!(feature(:foreman_proxy) && !feature(:foreman_server))
|
22
|
+
end
|
23
|
+
|
24
|
+
def product_name
|
25
|
+
if external_proxy?
|
26
|
+
foreman_proxy_product_name
|
27
|
+
else
|
28
|
+
server_product_name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def database_local?(feature)
|
33
|
+
!!feature(feature) && feature(feature).local?
|
34
|
+
end
|
35
|
+
|
36
|
+
def postgresql_local?
|
37
|
+
database_local?(:candlepin_database) || database_local?(:foreman_database)
|
38
|
+
end
|
39
|
+
end
|
@@ -7,6 +7,7 @@ class Features::Katello < ForemanMaintain::Feature
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
# TODO: refactor to new features?
|
10
11
|
def data_dirs
|
11
12
|
@dirs ||= ['/var/lib/pulp', '/var/lib/mongodb', '/var/lib/pgsql']
|
12
13
|
end
|
@@ -14,4 +15,46 @@ class Features::Katello < ForemanMaintain::Feature
|
|
14
15
|
def current_version
|
15
16
|
@current_version ||= rpm_version('katello')
|
16
17
|
end
|
18
|
+
|
19
|
+
def services
|
20
|
+
{
|
21
|
+
'qpidd' => 10,
|
22
|
+
'qdrouterd' => 10,
|
23
|
+
'goferd' => 30,
|
24
|
+
'elasticsearch' => 30
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# rubocop:disable Metrics/MethodLength
|
29
|
+
def config_files
|
30
|
+
configs = [
|
31
|
+
'/etc/pki/katello',
|
32
|
+
'/etc/pki/katello-certs-tools',
|
33
|
+
'/etc/pki/ca-trust',
|
34
|
+
'/root/ssl-build',
|
35
|
+
'/etc/candlepin',
|
36
|
+
'/etc/sysconfig/tomcat*',
|
37
|
+
'/etc/tomcat*',
|
38
|
+
'/var/lib/candlepin',
|
39
|
+
'/usr/share/foreman/bundler.d/katello.rb'
|
40
|
+
]
|
41
|
+
|
42
|
+
if installer_scenario_answers['certs']
|
43
|
+
configs += [
|
44
|
+
installer_scenario_answers['certs']['server_cert'],
|
45
|
+
installer_scenario_answers['certs']['server_key'],
|
46
|
+
installer_scenario_answers['certs']['server_cert_req'],
|
47
|
+
installer_scenario_answers['certs']['server_ca_cert']
|
48
|
+
].compact
|
49
|
+
end
|
50
|
+
|
51
|
+
configs
|
52
|
+
end
|
53
|
+
# rubocop:enable Metrics/MethodLength
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def installer_scenario_answers
|
58
|
+
feature(:installer).answers
|
59
|
+
end
|
17
60
|
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
class Features::Mongo < ForemanMaintain::Feature
|
2
|
+
# assume mongo is installed when there is Pulp
|
3
|
+
PULP_DB_CONFIG = '/etc/pulp/server.conf'.freeze
|
4
|
+
|
5
|
+
attr_reader :configuration
|
6
|
+
metadata do
|
7
|
+
label :mongo
|
8
|
+
|
9
|
+
confine do
|
10
|
+
feature(:pulp)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def services
|
15
|
+
core.services
|
16
|
+
end
|
17
|
+
|
18
|
+
def data_dir
|
19
|
+
'/var/lib/mongodb'
|
20
|
+
end
|
21
|
+
|
22
|
+
def config_files
|
23
|
+
[config_file] + (local? ? core.server_config_files : [])
|
24
|
+
end
|
25
|
+
|
26
|
+
def config_file
|
27
|
+
PULP_DB_CONFIG
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
@configuration = load_db_config(config_file)
|
32
|
+
end
|
33
|
+
|
34
|
+
def core
|
35
|
+
if @core.nil?
|
36
|
+
version = server_version
|
37
|
+
@core = if version =~ /^3\.4/
|
38
|
+
logger.debug("Mongo #{version} detected, using commands from rh-mongodb34 SCL")
|
39
|
+
ForemanMaintain::Utils::MongoCore34.new
|
40
|
+
else
|
41
|
+
logger.debug("Mongo #{version} detected, using default commands")
|
42
|
+
ForemanMaintain::Utils::MongoCore.new
|
43
|
+
end
|
44
|
+
end
|
45
|
+
@core
|
46
|
+
end
|
47
|
+
|
48
|
+
def local?
|
49
|
+
['localhost', '127.0.0.1', hostname].include?(configuration['host'])
|
50
|
+
end
|
51
|
+
|
52
|
+
def base_command(command, config = configuration, args = '')
|
53
|
+
if config['ssl']
|
54
|
+
ssl = ' --ssl'
|
55
|
+
if config['ca_path']
|
56
|
+
ca_cert = " --sslCAFile #{config['ca_path']}"
|
57
|
+
client_cert = " --sslPEMKeyFile #{config['ssl_certfile']}" if config['ssl_certfile']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
username = " -u #{config['username']}" if config['username']
|
61
|
+
password = " -p #{config['password']}" if config['password']
|
62
|
+
host = "--host #{config['host']} --port #{config['port']}"
|
63
|
+
"#{command}#{username}#{password} #{host}#{ssl}#{ca_cert}#{client_cert} #{args}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def mongo_command(args, config = configuration)
|
67
|
+
base_command(core.client_command, config, "#{args} #{config['name']}")
|
68
|
+
end
|
69
|
+
|
70
|
+
def dump(target, config = configuration)
|
71
|
+
execute!(base_command(core.dump_command, config, "-d #{config['name']} --out #{target}"),
|
72
|
+
:hidden_patterns => [config['password']].compact)
|
73
|
+
end
|
74
|
+
|
75
|
+
def dropdb(config = configuration)
|
76
|
+
execute!(mongo_command("--eval 'db.dropDatabase()'", config),
|
77
|
+
:hidden_patterns => [config['password']].compact)
|
78
|
+
end
|
79
|
+
|
80
|
+
def ping(config = configuration)
|
81
|
+
execute?(mongo_command("--eval 'ping:1'"),
|
82
|
+
:hidden_patterns => [config['password']].compact)
|
83
|
+
end
|
84
|
+
|
85
|
+
def server_version(config = configuration)
|
86
|
+
# do not use any core methods as we need this prior the core is created
|
87
|
+
version = execute(base_command('mongo', config, "--eval 'db.version()' #{config['name']}"),
|
88
|
+
:hidden_patterns => [config['password']].compact)
|
89
|
+
version.split("\n").last
|
90
|
+
end
|
91
|
+
|
92
|
+
def backup_local(backup_file, extra_tar_options = {})
|
93
|
+
dir = extra_tar_options.fetch(:data_dir, nil) || data_dir
|
94
|
+
logger.info("Backup of Mongo DB at #{dir} into #{backup_file}")
|
95
|
+
logger.debug(extra_tar_options.inspect)
|
96
|
+
FileUtils.cd(dir) do
|
97
|
+
tar_options = {
|
98
|
+
:archive => backup_file,
|
99
|
+
:command => 'create',
|
100
|
+
:exclude => ['mongod.lock'],
|
101
|
+
:transform => 's,^,var/lib/mongodb/,S'
|
102
|
+
}.merge(extra_tar_options)
|
103
|
+
feature(:tar).run(tar_options)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def find_base_directory(directory)
|
108
|
+
find_dir_containing_file(directory, 'mongod.lock')
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def norm_value(value)
|
114
|
+
value = value.strip
|
115
|
+
case value
|
116
|
+
when 'true'
|
117
|
+
true
|
118
|
+
when 'false'
|
119
|
+
false
|
120
|
+
else
|
121
|
+
value
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def load_db_config(config)
|
126
|
+
cfg = read_db_section(config)
|
127
|
+
if cfg['seeds']
|
128
|
+
seed = cfg['seeds'].split(',').first
|
129
|
+
host, port = seed.split(':')
|
130
|
+
end
|
131
|
+
cfg['host'] = host || 'localhost'
|
132
|
+
cfg['port'] = port || '27017'
|
133
|
+
cfg
|
134
|
+
end
|
135
|
+
|
136
|
+
# rubocop:disable Metrics/MethodLength
|
137
|
+
def read_db_section(config)
|
138
|
+
cfg = {}
|
139
|
+
section = nil
|
140
|
+
File.readlines(config).each do |line|
|
141
|
+
case line
|
142
|
+
when /^\s*#/
|
143
|
+
next # skip comments
|
144
|
+
when /^\s*$/
|
145
|
+
next # skip empty lines
|
146
|
+
when /\[([^\]]+)\]/
|
147
|
+
section = Regexp.last_match(1)
|
148
|
+
next
|
149
|
+
else
|
150
|
+
if section == 'database'
|
151
|
+
key, value = line.split(':', 2)
|
152
|
+
cfg[key.strip] = norm_value(value)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
cfg
|
157
|
+
end
|
158
|
+
# rubocop:enable Metrics/MethodLength
|
159
|
+
end
|
@@ -6,4 +6,34 @@ class Features::Pulp < ForemanMaintain::Feature
|
|
6
6
|
find_package('pulp-server')
|
7
7
|
end
|
8
8
|
end
|
9
|
+
|
10
|
+
def services
|
11
|
+
{
|
12
|
+
'squid' => 10,
|
13
|
+
'pulp_workers' => 20,
|
14
|
+
'pulp_celerybeat' => 20,
|
15
|
+
'pulp_resource_manager' => 20,
|
16
|
+
'pulp_streamer' => 20
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def data_dir
|
21
|
+
'/var/lib/pulp'
|
22
|
+
end
|
23
|
+
|
24
|
+
def config_files
|
25
|
+
[
|
26
|
+
'/etc/pki/pulp',
|
27
|
+
'/etc/pulp',
|
28
|
+
'/etc/qpid',
|
29
|
+
'/etc/qpid-dispatch',
|
30
|
+
'/etc/crane.conf',
|
31
|
+
'/etc/default/pulp_workers',
|
32
|
+
'/var/lib/qpidd'
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_base_directory(directory)
|
37
|
+
find_dir_containing_file(directory, '0005_puppet_module_name_change.txt')
|
38
|
+
end
|
9
39
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Features::Puppet < ForemanMaintain::Feature
|
2
|
+
metadata do
|
3
|
+
label :puppet
|
4
|
+
|
5
|
+
confine do
|
6
|
+
find_package('puppetserver')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def config_files
|
11
|
+
[
|
12
|
+
'/etc/puppet',
|
13
|
+
'/etc/puppetlabs',
|
14
|
+
'/opt/puppetlabs/puppet/cache/foreman_cache_data',
|
15
|
+
'/var/lib/puppet/foreman_cache_data',
|
16
|
+
'/opt/puppetlabs/puppet/ssl/',
|
17
|
+
'/var/lib/puppet/ssl',
|
18
|
+
'/var/lib/puppet'
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
@@ -6,15 +6,11 @@ class Features::PuppetServer < ForemanMaintain::Feature
|
|
6
6
|
# is a part of httpd and relies on httpd service to restart, therefore
|
7
7
|
# not requiring a separate service to restart
|
8
8
|
confine do
|
9
|
-
find_package('puppetserver')
|
9
|
+
find_package('puppetserver')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def services
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def puppet_version
|
18
|
-
version(execute!('puppet --version'))
|
14
|
+
{ 'puppetserver' => 30 }
|
19
15
|
end
|
20
16
|
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
class Features::Service < ForemanMaintain::Feature
|
2
|
+
metadata do
|
3
|
+
label :service
|
4
|
+
end
|
5
|
+
|
6
|
+
def handle_services(spinner, action, options = {})
|
7
|
+
# options is used to handle "exclude" and "only" i.e.
|
8
|
+
# { :only => ["httpd"] }
|
9
|
+
# { :exclude => ["pulp-workers", "tomcat"] }
|
10
|
+
if feature(:downstream) && feature(:downstream).less_than_version?('6.3')
|
11
|
+
use_katello_service(action, options)
|
12
|
+
else
|
13
|
+
options[:reverse] = action == 'stop'
|
14
|
+
|
15
|
+
filtered_services(options).each do |service|
|
16
|
+
spinner.update("#{action_noun(action)} #{service}")
|
17
|
+
perform_action_on_service(action, service)
|
18
|
+
end
|
19
|
+
|
20
|
+
spinner.update("All services #{action_past_tense(action)}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def list_services(service_list)
|
25
|
+
service_list = service_list.join(', ')
|
26
|
+
puts "#{service_list}\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_services_from_features(features)
|
30
|
+
features.map(&:services).
|
31
|
+
inject(&:merge).
|
32
|
+
sort_by { |_, value| value }.
|
33
|
+
map { |service| service[0] }
|
34
|
+
end
|
35
|
+
|
36
|
+
def existing_services
|
37
|
+
service_list = get_services_from_features(available_features)
|
38
|
+
service_list.select { |service| service_exists?(service) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def filtered_services(options)
|
42
|
+
service_list = existing_services
|
43
|
+
service_list = filter_services(service_list, options)
|
44
|
+
raise 'No services found matching your parameters' unless service_list.any?
|
45
|
+
options[:reverse] ? service_list.reverse : service_list
|
46
|
+
end
|
47
|
+
|
48
|
+
def action_noun(action)
|
49
|
+
action_word_modified(action) + 'ing'
|
50
|
+
end
|
51
|
+
|
52
|
+
def action_past_tense(action)
|
53
|
+
action_word_modified(action) + 'ed'
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def available_features
|
59
|
+
@available_features || ForemanMaintain.available_features
|
60
|
+
end
|
61
|
+
|
62
|
+
def filter_services(service_list, options)
|
63
|
+
service_list &= options[:only] if options[:only] && options[:only].any?
|
64
|
+
service_list -= options[:exclude] if options[:exclude] && options[:exclude].any?
|
65
|
+
service_list
|
66
|
+
end
|
67
|
+
|
68
|
+
def perform_action_on_service(action, service)
|
69
|
+
command = service_command(action, service)
|
70
|
+
if action == 'status'
|
71
|
+
status = execute(command)
|
72
|
+
puts "\n\n#{status}\n\n"
|
73
|
+
else
|
74
|
+
execute!(command)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def service_command(action, service)
|
79
|
+
if File.exist?('/usr/sbin/service-wait') &&
|
80
|
+
!%w[enable disable].include?(action)
|
81
|
+
"service-wait #{service} #{action}"
|
82
|
+
else
|
83
|
+
"systemctl #{action} #{service}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def action_word_modified(action)
|
88
|
+
case action
|
89
|
+
when 'status'
|
90
|
+
'display'
|
91
|
+
when 'enable', 'disable'
|
92
|
+
action.chomp('e')
|
93
|
+
when 'stop'
|
94
|
+
action + 'p'
|
95
|
+
else
|
96
|
+
action
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def use_katello_service(action, options)
|
101
|
+
if %w[enable disable].include?(action)
|
102
|
+
raise 'Service enable and disable are only supported in Satellite 6.3+'
|
103
|
+
end
|
104
|
+
|
105
|
+
command = "katello-service #{action} "
|
106
|
+
|
107
|
+
# katello-service in 6.1 does not support --only
|
108
|
+
if feature(:downstream).less_than_version?('6.2')
|
109
|
+
excluded_services = exclude_services_only(options)
|
110
|
+
command += "--exclude #{excluded_services.join(',')}" if excluded_services.any?
|
111
|
+
else
|
112
|
+
command += katello_service_filters(options)
|
113
|
+
end
|
114
|
+
|
115
|
+
run_katello_service(command)
|
116
|
+
end
|
117
|
+
|
118
|
+
def run_katello_service(command)
|
119
|
+
puts 'Services are handled by katello-service in Satellite versions 6.2 and earlier. ' \
|
120
|
+
"Redirecting to: \n#{command}\n"
|
121
|
+
puts execute(command)
|
122
|
+
end
|
123
|
+
|
124
|
+
def exclude_services_only(options)
|
125
|
+
existing_services - filtered_services(options)
|
126
|
+
end
|
127
|
+
|
128
|
+
def katello_service_filters(options)
|
129
|
+
filters = ''
|
130
|
+
filters += "--exclude #{options[:exclude]}" if options[:exclude] && options[:exclude].any?
|
131
|
+
filters += "--only #{options[:only]}" if options[:only] && options[:only].any?
|
132
|
+
filters
|
133
|
+
end
|
134
|
+
end
|