@@ -296,61 +296,93 @@ def configure
296
296
node [ 'redisio' ] [ 'bin_path' ]
297
297
end
298
298
299
- template "/etc/init.d/redis#{ server_name } " do
300
- source 'redis.init.erb'
301
- cookbook 'redisio'
302
- owner 'root'
303
- group 'root'
304
- mode '0755'
305
- variables (
306
- name : server_name ,
307
- bin_path : bin_path ,
308
- port : current [ 'port' ] ,
309
- address : current [ 'address' ] ,
310
- user : current [ 'user' ] ,
311
- configdir : current [ 'configdir' ] ,
312
- piddir : piddir ,
313
- requirepass : current [ 'requirepass' ] ,
314
- shutdown_save : current [ 'shutdown_save' ] ,
315
- platform : node [ 'platform' ] ,
316
- unixsocket : current [ 'unixsocket' ] ,
317
- ulimit : descriptors ,
318
- required_start : node [ 'redisio' ] [ 'init.d' ] [ 'required_start' ] . join ( ' ' ) ,
319
- required_stop : node [ 'redisio' ] [ 'init.d' ] [ 'required_stop' ] . join ( ' ' )
320
- )
321
- only_if { node [ 'redisio' ] [ 'job_control' ] == 'initd' }
322
- end
323
- template "/etc/init/redis#{ server_name } .conf" do
324
- source 'redis.upstart.conf.erb'
325
- cookbook 'redisio'
326
- owner current [ 'user' ]
327
- group current [ 'group' ]
328
- mode '0644'
329
- variables (
330
- name : server_name ,
331
- bin_path : bin_path ,
332
- port : current [ 'port' ] ,
333
- user : current [ 'user' ] ,
334
- group : current [ 'group' ] ,
335
- configdir : current [ 'configdir' ] ,
336
- piddir : piddir
337
- )
338
- only_if { node [ 'redisio' ] [ 'job_control' ] == 'upstart' }
339
- end
340
- template "/usr/local/etc/rc.d/redis#{ server_name } " do
341
- source 'redis.rcinit.erb'
342
- cookbook 'redisio'
343
- owner current [ 'user' ]
344
- group current [ 'group' ]
345
- mode '0755'
346
- variables (
347
- name : server_name ,
348
- bin_path : bin_path ,
349
- user : current [ 'user' ] ,
350
- configdir : current [ 'configdir' ] ,
351
- piddir : piddir
352
- )
353
- only_if { node [ 'redisio' ] [ 'job_control' ] == 'rcinit' }
299
+ case node [ 'redisio' ] [ 'job_control' ]
300
+ when 'initd'
301
+ template "/etc/init.d/redis#{ server_name } " do
302
+ source 'redis.init.erb'
303
+ cookbook 'redisio'
304
+ owner 'root'
305
+ group 'root'
306
+ mode '0755'
307
+ variables (
308
+ name : server_name ,
309
+ bin_path : bin_path ,
310
+ port : current [ 'port' ] ,
311
+ address : current [ 'address' ] ,
312
+ user : current [ 'user' ] ,
313
+ configdir : current [ 'configdir' ] ,
314
+ piddir : piddir ,
315
+ requirepass : current [ 'requirepass' ] ,
316
+ shutdown_save : current [ 'shutdown_save' ] ,
317
+ platform : node [ 'platform' ] ,
318
+ unixsocket : current [ 'unixsocket' ] ,
319
+ ulimit : descriptors ,
320
+ required_start : node [ 'redisio' ] [ 'init.d' ] [ 'required_start' ] . join ( ' ' ) ,
321
+ required_stop : node [ 'redisio' ] [ 'init.d' ] [ 'required_stop' ] . join ( ' ' )
322
+ )
323
+ end
324
+ when 'upstart'
325
+ template "/etc/init/redis#{ server_name } .conf" do
326
+ source 'redis.upstart.conf.erb'
327
+ cookbook 'redisio'
328
+ owner current [ 'user' ]
329
+ group current [ 'group' ]
330
+ mode '0644'
331
+ variables (
332
+ name : server_name ,
333
+ bin_path : bin_path ,
334
+ port : current [ 'port' ] ,
335
+ user : current [ 'user' ] ,
336
+ group : current [ 'group' ] ,
337
+ configdir : current [ 'configdir' ] ,
338
+ piddir : piddir
339
+ )
340
+ end
341
+ when 'rcinit'
342
+ template "/usr/local/etc/rc.d/redis#{ server_name } " do
343
+ source 'redis.rcinit.erb'
344
+ cookbook 'redisio'
345
+ owner current [ 'user' ]
346
+ group current [ 'group' ]
347
+ mode '0755'
348
+ variables (
349
+ name : server_name ,
350
+ bin_path : bin_path ,
351
+ user : current [ 'user' ] ,
352
+ configdir : current [ 'configdir' ] ,
353
+ piddir : piddir
354
+ )
355
+ end
356
+ when 'systemd'
357
+ service_name = "redis@#{ server_name } "
358
+ reload_name = "#{ service_name } systemd reload"
359
+
360
+ file "/etc/tmpfiles.d/#{ service_name } .conf" do
361
+ content "d #{ piddir } 0755 #{ current [ 'user' ] } #{ current [ 'group' ] } \n "
362
+ owner 'root'
363
+ group 'root'
364
+ mode '0644'
365
+ end
366
+
367
+ execute reload_name do
368
+ command 'systemctl daemon-reload'
369
+ action :nothing
370
+ end
371
+
372
+ template "/lib/systemd/system/#{ service_name } .service" do
373
+ source 'redis@.service.erb'
374
+ cookbook 'redisio'
375
+ owner 'root'
376
+ group 'root'
377
+ mode '0644'
378
+ variables (
379
+ bin_path : bin_path ,
380
+ user : current [ 'user' ] ,
381
+ group : current [ 'group' ] ,
382
+ limit_nofile : current [ 'maxclients' ] + 32
383
+ )
384
+ notifies :run , "execute[#{ reload_name } ]" , :immediately
385
+ end
354
386
end
355
387
end
356
388
end # servers each loop
0 commit comments