manageiq-appliance_console 5.3.2 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,199 @@
1
+ require 'active_support/core_ext/module/delegation'
2
+ require 'pathname'
3
+
4
+ module ManageIQ
5
+ module ApplianceConsole
6
+ class MessageConfiguration
7
+ attr_reader :message_keystore_username, :message_keystore_password,
8
+ :message_server_host, :message_server_port,
9
+ :miq_config_dir_path, :config_dir_path, :sample_config_dir_path,
10
+ :client_properties_path,
11
+ :keystore_dir_path, :truststore_path, :keystore_path,
12
+ :messaging_yaml_sample_path, :messaging_yaml_path,
13
+ :ca_cert_path
14
+
15
+ BASE_DIR = "/opt/kafka".freeze
16
+ LOGS_DIR = "#{BASE_DIR}/logs".freeze
17
+ CONFIG_DIR = "#{BASE_DIR}/config".freeze
18
+ SAMPLE_CONFIG_DIR = "#{BASE_DIR}/config-sample".freeze
19
+ MIQ_CONFIG_DIR = ManageIQ::ApplianceConsole::RAILS_ROOT.join("config").freeze
20
+
21
+ def initialize(options = {})
22
+ @message_server_port = options[:message_server_port] || 9093
23
+ @message_keystore_username = options[:message_keystore_username] || "admin"
24
+ @message_keystore_password = options[:message_keystore_password]
25
+
26
+ @miq_config_dir_path = Pathname.new(MIQ_CONFIG_DIR)
27
+ @config_dir_path = Pathname.new(CONFIG_DIR)
28
+ @sample_config_dir_path = Pathname.new(SAMPLE_CONFIG_DIR)
29
+
30
+ @client_properties_path = config_dir_path.join("client.properties")
31
+ @keystore_dir_path = config_dir_path.join("keystore")
32
+ @truststore_path = keystore_dir_path.join("truststore.jks")
33
+ @keystore_path = keystore_dir_path.join("keystore.jks")
34
+
35
+ @messaging_yaml_sample_path = miq_config_dir_path.join("messaging.kafka.yml")
36
+ @messaging_yaml_path = miq_config_dir_path.join("messaging.yml")
37
+ @ca_cert_path = keystore_dir_path.join("ca-cert")
38
+ end
39
+
40
+ def already_configured?
41
+ installed_file_found = false
42
+ installed_files.each do |f|
43
+ if File.exist?(f)
44
+ installed_file_found = true
45
+ say("Installed file #{f} found.")
46
+ end
47
+ end
48
+ installed_file_found
49
+ end
50
+
51
+ def ask_questions
52
+ return false unless valid_environment?
53
+
54
+ ask_for_parameters
55
+ show_parameters
56
+ return false unless agree("\nProceed? (Y/N): ")
57
+
58
+ return false unless host_reachable?(message_server_host, "Message Server Host:")
59
+
60
+ true
61
+ end
62
+
63
+ def create_client_properties
64
+ say(__method__.to_s.tr("_", " ").titleize)
65
+
66
+ return if file_found?(client_properties_path)
67
+
68
+ algorithm = message_server_host.ipaddress? ? "" : "HTTPS"
69
+ protocol = secure? ? "SASL_SSL" : "PLAINTEXT"
70
+ content = secure? ? secure_client_properties_content(algorithm, protocol) : unsecure_client_properties_content(algorithm, protocol)
71
+
72
+ File.write(client_properties_path, content)
73
+ end
74
+
75
+ def secure_client_properties_content(algorithm, protocol)
76
+ secure_content = <<~CLIENT_PROPERTIES
77
+ ssl.truststore.location=#{truststore_path}
78
+ ssl.truststore.password=#{message_keystore_password}
79
+ CLIENT_PROPERTIES
80
+
81
+ unsecure_client_properties_content(algorithm, protocol) + secure_content
82
+ end
83
+
84
+ def unsecure_client_properties_content(algorithm, protocol)
85
+ <<~CLIENT_PROPERTIES
86
+ ssl.endpoint.identification.algorithm=#{algorithm}
87
+
88
+ sasl.mechanism=PLAIN
89
+ security.protocol=#{protocol}
90
+ sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \\
91
+ username=#{message_keystore_username} \\
92
+ password=#{message_keystore_password} ;
93
+ CLIENT_PROPERTIES
94
+ end
95
+
96
+ def configure_messaging_yaml
97
+ say(__method__.to_s.tr("_", " ").titleize)
98
+
99
+ return if file_found?(messaging_yaml_path)
100
+
101
+ messaging_yaml = YAML.load_file(messaging_yaml_sample_path)
102
+
103
+ messaging_yaml["production"].delete("username")
104
+ messaging_yaml["production"].delete("password")
105
+
106
+ messaging_yaml["production"]["hostname"] = message_server_host
107
+ messaging_yaml["production"]["port"] = message_server_port
108
+ messaging_yaml["production"]["sasl.mechanism"] = "PLAIN"
109
+ messaging_yaml["production"]["sasl.username"] = message_keystore_username
110
+ messaging_yaml["production"]["sasl.password"] = ManageIQ::Password.try_encrypt(message_keystore_password)
111
+
112
+ if secure?
113
+ messaging_yaml["production"]["security.protocol"] = "SASL_SSL"
114
+ messaging_yaml["production"]["ssl.ca.location"] = ca_cert_path.to_path
115
+ else
116
+ messaging_yaml["production"]["security.protocol"] = "PLAINTEXT"
117
+ end
118
+
119
+ File.write(messaging_yaml_path, messaging_yaml.to_yaml)
120
+ end
121
+
122
+ def remove_installed_files
123
+ say(__method__.to_s.tr("_", " ").titleize)
124
+
125
+ installed_files.each { |f| FileUtils.rm_rf(f) }
126
+ end
127
+
128
+ def valid_environment?
129
+ if already_configured?
130
+ unconfigure if agree("\nAlready configured on this Appliance, Un-Configure first? (Y/N): ")
131
+ return false unless agree("\nProceed with Configuration? (Y/N): ")
132
+ end
133
+ true
134
+ end
135
+
136
+ def file_found?(path)
137
+ return false unless File.exist?(path)
138
+
139
+ say("\tWARNING: #{path} already exists. Taking no action.")
140
+ true
141
+ end
142
+
143
+ def files_found?(path_list)
144
+ return false unless path_list.all? { |path| File.exist?(path) }
145
+
146
+ path_list.each { |path| file_found?(path) }
147
+ true
148
+ end
149
+
150
+ def file_contains?(path, content)
151
+ return false unless File.exist?(path)
152
+
153
+ content.split("\n").each do |l|
154
+ l.gsub!("/", "\\/")
155
+ l.gsub!(/password=.*$/, "password=") # Remove the password as it can have special characters that grep can not match.
156
+ return false unless File.foreach(path).grep(/#{l}/).any?
157
+ end
158
+
159
+ say("Content already exists in #{path}. Taking no action.")
160
+ true
161
+ end
162
+
163
+ def host_reachable?(host, what)
164
+ require 'net/ping'
165
+ say("Checking connectivity to #{host} ... ")
166
+ unless Net::Ping::External.new(host).ping
167
+ say("Failed.\nCould not connect to #{host},")
168
+ say("the #{what} must be reachable by name.")
169
+ return false
170
+ end
171
+ say("Succeeded.")
172
+ true
173
+ end
174
+
175
+ def configure_messaging_type(value)
176
+ say(__method__.to_s.tr("_", " ").titleize)
177
+
178
+ result = ManageIQ::ApplianceConsole::Utilities.rake_run("evm:settings:set", ["/prototype/messaging_type=#{value}"])
179
+ raise parse_errors(result).join(', ') if result.failure?
180
+ end
181
+
182
+ def restart_evmserverd
183
+ say("Restart evmserverd if it is running...")
184
+ evmserverd_service = LinuxAdmin::Service.new("evmserverd")
185
+ evmserverd_service.restart if evmserverd_service.running?
186
+ end
187
+
188
+ def unconfigure
189
+ configure_messaging_type("miq_queue") # Settings.prototype.messaging_type = 'miq_queue'
190
+ restart_evmserverd
191
+ remove_installed_files
192
+ end
193
+
194
+ def secure?
195
+ message_server_port == 9_093
196
+ end
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,96 @@
1
+ require "awesome_spawn"
2
+ require "fileutils"
3
+ require "linux_admin"
4
+ require 'net/scp'
5
+ require "manageiq/appliance_console/message_configuration"
6
+
7
+ module ManageIQ
8
+ module ApplianceConsole
9
+ class MessageClientConfiguration < MessageConfiguration
10
+ attr_reader :message_server_password, :message_server_username, :installed_files,
11
+ :message_truststore_path_src, :message_ca_cert_path_src
12
+
13
+ def initialize(options = {})
14
+ super(options)
15
+
16
+ @message_server_host = options[:message_server_host]
17
+ @message_server_username = options[:message_server_usernamed] || "root"
18
+ @message_server_password = options[:message_server_password]
19
+
20
+ @message_truststore_path_src = options[:message_truststore_path_src] || truststore_path
21
+ @message_ca_cert_path_src = options[:message_ca_cert_path_src] || ca_cert_path
22
+
23
+ @installed_files = [client_properties_path, messaging_yaml_path, truststore_path]
24
+ end
25
+
26
+ def configure
27
+ begin
28
+ MessageServerConfiguration.new.unconfigure if MessageServerConfiguration.configured?
29
+ configure_messaging_yaml # Set up the local message client in case EVM is actually running on this, Message Server
30
+ create_client_properties # Create the client.properties configuration fle
31
+ fetch_truststore_from_server # Fetch the Java Keystore from the Kafka Server
32
+ configure_messaging_type("kafka") # Settings.prototype.messaging_type = 'kafka'
33
+ restart_evmserverd
34
+ rescue AwesomeSpawn::CommandResultError => e
35
+ say(e.result.output)
36
+ say(e.result.error)
37
+ say("")
38
+ say("Failed to Configure the Message Client- #{e}")
39
+ return false
40
+ rescue => e
41
+ say("Failed to Configure the Message Client- #{e}")
42
+ return false
43
+ end
44
+ true
45
+ end
46
+
47
+ def ask_for_parameters
48
+ say("\nMessage Client Parameters:\n\n")
49
+
50
+ @message_server_host = ask_for_string("Message Server Hostname or IP address")
51
+ @message_server_port = ask_for_integer("Message Server Port number", (1..65_535), 9_093).to_i
52
+ @message_server_username = ask_for_string("Message Server Username", message_server_username)
53
+ @message_server_password = ask_for_password("Message Server Password")
54
+ @message_truststore_path_src = ask_for_string("Message Server Truststore Path", truststore_path)
55
+ @message_ca_cert_path_src = ask_for_string("Message Server CA Cert Path", ca_cert_path)
56
+ @message_keystore_username = ask_for_string("Message Keystore Username", message_keystore_username) if secure?
57
+ @message_keystore_password = ask_for_password("Message Keystore Password") if secure?
58
+ end
59
+
60
+ def show_parameters
61
+ say("\nMessage Client Configuration:\n")
62
+ say("Message Client Details:\n")
63
+ say(" Message Server Hostname: #{message_server_host}\n")
64
+ say(" Message Server Username: #{message_server_username}\n")
65
+ say(" Message Keystore Username: #{message_keystore_username}\n")
66
+ end
67
+
68
+ def fetch_truststore_from_server
69
+ say(__method__.to_s.tr("_", " ").titleize)
70
+
71
+ fetch_from_server(message_truststore_path_src, truststore_path)
72
+ end
73
+
74
+ def fetch_ca_cert_from_server
75
+ say(__method__.to_s.tr("_", " ").titleize)
76
+
77
+ fetch_from_server(message_ca_cert_path_src, ca_cert_path)
78
+ end
79
+
80
+ private
81
+
82
+ def fetch_from_server(src_file, dst_file)
83
+ return if file_found?(dst_file)
84
+
85
+ Net::SCP.start(message_server_host, message_server_username, :password => message_server_password) do |scp|
86
+ scp.download!(src_file, dst_file)
87
+ end
88
+
89
+ File.exist?(dst_file)
90
+ rescue => e
91
+ say("Failed to fetch #{src_file} from server: #{e.message}")
92
+ false
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,319 @@
1
+ require "awesome_spawn"
2
+ require "fileutils"
3
+ require "linux_admin"
4
+ require "manageiq/appliance_console/message_configuration"
5
+
6
+ module ManageIQ
7
+ module ApplianceConsole
8
+ class MessageServerConfiguration < MessageConfiguration
9
+ attr_reader :jaas_config_path,
10
+ :server_properties_path, :server_properties_sample_path,
11
+ :ca_cert_srl_path, :ca_key_path, :cert_file_path, :cert_signed_path,
12
+ :keystore_files, :installed_files, :message_persistent_disk
13
+
14
+ PERSISTENT_DIRECTORY = Pathname.new("/var/lib/kafka/persistent_data").freeze
15
+ PERSISTENT_NAME = "kafka_messages".freeze
16
+
17
+ def initialize(options = {})
18
+ super(options)
19
+
20
+ @message_server_host = options[:message_server_use_ipaddr] == true ? my_ipaddr : options[:message_server_host] || my_hostname
21
+ @message_persistent_disk = LinuxAdmin::Disk.new(:path => options[:message_persistent_disk]) unless options[:message_persistent_disk].nil?
22
+
23
+ @jaas_config_path = config_dir_path.join("kafka_server_jaas.conf")
24
+ @server_properties_path = config_dir_path.join("server.properties")
25
+ @server_properties_sample_path = sample_config_dir_path.join("server.properties")
26
+
27
+ @ca_cert_srl_path = keystore_dir_path.join("ca-cert.srl")
28
+ @ca_key_path = keystore_dir_path.join("ca-key")
29
+ @cert_file_path = keystore_dir_path.join("cert-file")
30
+ @cert_signed_path = keystore_dir_path.join("cert-signed")
31
+
32
+ @keystore_files = [ca_cert_path, ca_cert_srl_path, ca_key_path, cert_file_path, cert_signed_path, truststore_path, keystore_path]
33
+ @installed_files = [jaas_config_path, client_properties_path, server_properties_path, messaging_yaml_path, LOGS_DIR] + keystore_files
34
+ end
35
+
36
+ def configure
37
+ begin
38
+ configure_persistent_disk # Configure the persistent message store on a different disk
39
+ create_jaas_config # Create the message server jaas config file
40
+ create_client_properties # Create the client.properties config
41
+ create_logs_directory # Create the logs directory:
42
+ configure_firewall # Open the firewall for message port 9093
43
+ configure_keystore # Populate the Java Keystore
44
+ create_server_properties # Update the /opt/message/config/server.properties
45
+ configure_messaging_yaml # Set up the local message client in case EVM is actually running on this, Message Server
46
+ configure_messaging_type("kafka") # Settings.prototype.messaging_type = 'kafka'
47
+ restart_services
48
+ rescue AwesomeSpawn::CommandResultError => e
49
+ say(e.result.output)
50
+ say(e.result.error)
51
+ say("")
52
+ say("Failed to Configure the Message Server- #{e}")
53
+ return false
54
+ rescue => e
55
+ say("Failed to Configure the Message Server- #{e}")
56
+ return false
57
+ end
58
+ true
59
+ end
60
+
61
+ def restart_services
62
+ say("Starting zookeeper and configure it to start on reboots ...")
63
+ LinuxAdmin::Service.new("zookeeper").start.enable
64
+
65
+ say("Starting kafka and configure it to start on reboots ...")
66
+ LinuxAdmin::Service.new("kafka").start.enable
67
+
68
+ restart_evmserverd
69
+ end
70
+
71
+ def ask_for_parameters
72
+ say("\nMessage Server Parameters:\n\n")
73
+
74
+ @message_server_host = ask_for_string("Message Server Hostname or IP address", message_server_host)
75
+ @message_keystore_username = ask_for_string("Message Keystore Username", message_keystore_username)
76
+ @message_keystore_password = ask_for_password("Message Keystore Password")
77
+ @message_persistent_disk = ask_for_persistent_disk
78
+ end
79
+
80
+ def ask_for_persistent_disk
81
+ choose_disk if use_new_disk
82
+ end
83
+
84
+ def use_new_disk
85
+ agree("Configure a new persistent disk volume? (Y/N): ")
86
+ end
87
+
88
+ def choose_disk
89
+ ask_for_disk("Persistent disk")
90
+ end
91
+
92
+ def show_parameters
93
+ say("\nMessage Server Configuration:\n")
94
+ say("Message Server Details:\n")
95
+ say(" Message Server Hostname: #{message_server_host}\n")
96
+ say(" Message Keystore Username: #{message_keystore_username}\n")
97
+ say(" Persistent message disk: #{message_persistent_disk.path}\n") if message_persistent_disk
98
+ end
99
+
100
+ def unconfigure
101
+ super
102
+
103
+ unconfigure_firewall
104
+ deactivate_services
105
+ end
106
+
107
+ def self.configured?
108
+ LinuxAdmin::Service.new("kafka").running? ||
109
+ LinuxAdmin::Service.new("zookeeper").running?
110
+ end
111
+
112
+ private
113
+
114
+ def my_ipaddr
115
+ LinuxAdmin::IpAddress.new.address
116
+ end
117
+
118
+ def my_hostname
119
+ LinuxAdmin::Hosts.new.hostname
120
+ end
121
+
122
+ def configure_persistent_disk
123
+ return true unless message_persistent_disk
124
+
125
+ say(__method__.to_s.tr("_", " ").titleize)
126
+
127
+ deactivate_services # Just in case they are running.
128
+
129
+ FileUtils.mkdir_p(PERSISTENT_DIRECTORY)
130
+ LogicalVolumeManagement.new(:disk => message_persistent_disk, :mount_point => PERSISTENT_DIRECTORY, :name => PERSISTENT_NAME).setup
131
+ FileUtils.chmod(0o755, PERSISTENT_DIRECTORY)
132
+ FileUtils.chown("kafka", "kafka", PERSISTENT_DIRECTORY)
133
+
134
+ true
135
+ end
136
+
137
+ def activate_new_persistent_disk
138
+ return true unless message_persistent_disk
139
+
140
+ say(__method__.to_s.tr("_", " ").titleize)
141
+
142
+ data = File.read(server_properties_path)
143
+ data.gsub!(/^log.dirs=.*$/, "log.dirs=#{PERSISTENT_DIRECTORY}")
144
+ File.write(server_properties_path, data)
145
+
146
+ true
147
+ end
148
+
149
+ def create_jaas_config
150
+ say(__method__.to_s.tr("_", " ").titleize)
151
+
152
+ content = <<~JAAS
153
+ KafkaServer {
154
+ org.apache.kafka.common.security.plain.PlainLoginModule required
155
+ username=#{message_keystore_username}
156
+ password=#{message_keystore_password}
157
+ user_admin=#{message_keystore_password} ;
158
+ };
159
+ JAAS
160
+
161
+ File.write(jaas_config_path, content) unless file_found?(jaas_config_path)
162
+ end
163
+
164
+ def create_logs_directory
165
+ say(__method__.to_s.tr("_", " ").titleize)
166
+
167
+ return if file_found?(LOGS_DIR)
168
+
169
+ FileUtils.mkdir_p(LOGS_DIR)
170
+ FileUtils.chmod(0o755, LOGS_DIR)
171
+ FileUtils.chown("kafka", "kafka", LOGS_DIR)
172
+ end
173
+
174
+ def configure_firewall
175
+ say(__method__.to_s.tr("_", " ").titleize)
176
+
177
+ modify_firewall(:add_port)
178
+ end
179
+
180
+ def configure_keystore
181
+ say(__method__.to_s.tr("_", " ").titleize)
182
+
183
+ return if files_found?(keystore_files)
184
+
185
+ keystore_params = assemble_keystore_params
186
+
187
+ # Generte a Java keystore and key pair, creating keystore.jks
188
+ # :stdin_data provides the -storepass twice to confirm and an extra CR to accept the same password for -keypass
189
+ AwesomeSpawn.run!("keytool", :params => keystore_params, :stdin_data => "#{message_keystore_password}\n#{message_keystore_password}\n\n")
190
+
191
+ # Use openssl to create a new CA cert, creating ca-cert and ca-key
192
+ AwesomeSpawn.run!("openssl", :env => {"PASSWORD" => message_keystore_password},
193
+ :params => ["req", "-new", "-x509", {"-keyout" => ca_key_path,
194
+ "-out" => ca_cert_path,
195
+ "-days" => 10_000,
196
+ "-passout" => "env:PASSWORD",
197
+ "-subj" => '/CN=something'}])
198
+
199
+ # Import the CA cert into the trust store, creating truststore.jks
200
+ # :stdin_data provides the -storepass argument and yes to confirm
201
+ AwesomeSpawn.run!("keytool", :params => {"-keystore" => truststore_path,
202
+ "-alias" => "CARoot",
203
+ "-import" => nil,
204
+ "-file" => ca_cert_path},
205
+ :stdin_data => "#{message_keystore_password}\n#{message_keystore_password}\nyes\n")
206
+
207
+ # Generate a certificate signing request (CSR) for an existing Java keystore, creating cert-file
208
+ # :stdin_data provides the -storepass argument
209
+ AwesomeSpawn.run!("keytool", :params => {"-keystore" => keystore_path,
210
+ "-alias" => keystore_params["-alias"],
211
+ "-certreq" => nil,
212
+ "-file" => cert_file_path},
213
+ :stdin_data => "#{message_keystore_password}\n")
214
+
215
+ # Use openssl to sign the certificate with the "CA" certificate, creating ca-cert.srl and cert-signed
216
+ AwesomeSpawn.run!("openssl", :env => {"PASSWORD" => message_keystore_password},
217
+ :params => ["x509", "-req", {"-CA" => ca_cert_path,
218
+ "-CAkey" => ca_key_path,
219
+ "-in" => cert_file_path,
220
+ "-out" => cert_signed_path,
221
+ "-days" => 10_000,
222
+ "-CAcreateserial" => nil,
223
+ "-passin" => "env:PASSWORD"}])
224
+
225
+ # Import a root or intermediate CA certificate to an existing Java keystore, updating keystore.jks
226
+ # :stdin_data provides the -storepass argument and yes to confirm
227
+ AwesomeSpawn.run!("keytool", :params => {"-keystore" => keystore_path,
228
+ "-alias" => "CARoot",
229
+ "-import" => nil,
230
+ "-file" => ca_cert_path},
231
+ :stdin_data => "#{message_keystore_password}\nyes\n")
232
+
233
+ # Import a signed primary certificate to an existing Java keystore, updating keystore.jks
234
+ # :stdin_data provides the -storepass argument
235
+ AwesomeSpawn.run!("keytool", :params => {"-keystore" => keystore_path,
236
+ "-alias" => keystore_params["-alias"],
237
+ "-import" => nil,
238
+ "-file" => cert_signed_path},
239
+ :stdin_data => "#{message_keystore_password}\n")
240
+ end
241
+
242
+ def create_server_properties
243
+ say(__method__.to_s.tr("_", " ").titleize)
244
+
245
+ if message_server_host.ipaddress?
246
+ ident_algorithm = ""
247
+ client_auth = "none"
248
+ else
249
+ ident_algorithm = "HTTPS"
250
+ client_auth = "required"
251
+ end
252
+
253
+ content = <<~SERVER_PROPERTIES
254
+
255
+ listeners=SASL_SSL://:#{message_server_port}
256
+
257
+ ssl.endpoint.identification.algorithm=#{ident_algorithm}
258
+ ssl.keystore.location=#{keystore_path}
259
+ ssl.keystore.password=#{message_keystore_password}
260
+ ssl.key.password=#{message_keystore_password}
261
+
262
+ ssl.truststore.location=#{truststore_path}
263
+ ssl.truststore.password=#{message_keystore_password}
264
+
265
+ ssl.client.auth=#{client_auth}
266
+
267
+ sasl.enabled.mechanisms=PLAIN
268
+ sasl.mechanism.inter.broker.protocol=PLAIN
269
+
270
+ security.inter.broker.protocol=SASL_SSL
271
+ SERVER_PROPERTIES
272
+
273
+ return if file_contains?(server_properties_path, content)
274
+
275
+ FileUtils.cp(server_properties_sample_path, server_properties_path)
276
+ File.write(server_properties_path, content, :mode => "a")
277
+
278
+ activate_new_persistent_disk
279
+ end
280
+
281
+ def unconfigure_firewall
282
+ say(__method__.to_s.tr("_", " ").titleize)
283
+
284
+ modify_firewall(:remove_port)
285
+ end
286
+
287
+ def deactivate_services
288
+ say(__method__.to_s.tr("_", " ").titleize)
289
+
290
+ LinuxAdmin::Service.new("zookeeper").stop
291
+ LinuxAdmin::Service.new("kafka").stop
292
+ end
293
+
294
+ def assemble_keystore_params
295
+ keystore_params = {"-keystore" => keystore_path,
296
+ "-validity" => 10_000,
297
+ "-genkey" => nil,
298
+ "-keyalg" => "RSA"}
299
+
300
+ if message_server_host.ipaddress?
301
+ keystore_params["-alias"] = "localhost"
302
+ keystore_params["-ext"] = "san=ip:#{message_server_host}"
303
+ else
304
+ keystore_params["-alias"] = message_server_host
305
+ keystore_params["-ext"] = "san=dns:#{message_server_host}"
306
+ end
307
+
308
+ keystore_params["-dname"] = "cn=#{keystore_params["-alias"]}"
309
+
310
+ keystore_params
311
+ end
312
+
313
+ def modify_firewall(action)
314
+ AwesomeSpawn.run!("firewall-cmd", :params => {action => "#{message_server_port}/tcp", :permanent => nil})
315
+ AwesomeSpawn.run!("firewall-cmd --reload")
316
+ end
317
+ end
318
+ end
319
+ end