-
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CentOS 7 support with systemd configs
- Loading branch information
Showing
15 changed files
with
131 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,25 +34,37 @@ | |
base_piddir redis['base_piddir'] | ||
end | ||
|
||
template '/usr/lib/systemd/system/[email protected]' do | ||
source '[email protected]' | ||
variables({ :bin_path => node['redisio']['bin_path'] }) | ||
only_if { node['redisio']['job_control'] == 'systemd' } | ||
end | ||
|
||
# Create a service resource for each redis instance, named for the port it runs on. | ||
redis_instances.each do |current_server| | ||
server_name = current_server['name'] || current_server['port'] | ||
job_control = node['redisio']['job_control'] | ||
|
||
if job_control == 'initd' | ||
case node['redisio']['job_control'] | ||
when 'initd' | ||
service "redis#{server_name}" do | ||
# don't supply start/stop/restart commands, Chef::Provider::Service::* | ||
# do a fine job on it's own, and support systemd correctly | ||
supports :start => true, :stop => true, :restart => false, :status => true | ||
end | ||
elsif job_control == 'upstart' | ||
when 'upstart' | ||
service "redis#{server_name}" do | ||
provider Chef::Provider::Service::Upstart | ||
provider Chef::Provider::Service::Upstart | ||
start_command "start redis#{server_name}" | ||
stop_command "stop redis#{server_name}" | ||
restart_command "restart redis#{server_name}" | ||
supports :start => true, :stop => true, :restart => true, :status => false | ||
end | ||
when 'systemd' | ||
service "redis@#{server_name}" do | ||
provider Chef::Provider::Service::Systemd | ||
supports :start => true, :stop => true, :restart => true, :status => true | ||
end | ||
else | ||
Chef::Log.error("Unknown job control type, no service resource created!") | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,28 @@ | |
|
||
redis = node['redisio'] | ||
|
||
execute 'reload-systemd' do | ||
command '/usr/bin/systemctl daemon-reload' | ||
only_if { node['redisio']['job_control'] == 'systemd'} | ||
action :nothing | ||
end | ||
|
||
redis['servers'].each do |current_server| | ||
server_name = current_server["name"] || current_server["port"] | ||
resource = resources("service[redis#{server_name}]") | ||
resource_name = if node['redisio']['job_control'] == 'systemd' | ||
"service[redis@#{server_name}]" | ||
else | ||
"service[redis#{server_name}]" | ||
end | ||
resource = resources(resource_name) | ||
resource.action Array(resource.action) | ||
resource.action << :start | ||
resource.action << :enable | ||
if node['redisio']['job_control'] != 'systemd' | ||
resource.action << :enable | ||
else | ||
link "/etc/systemd/system/multi-user.target.wants/redis@#{server_name}.service" do | ||
to '/usr/lib/systemd/system/[email protected]' | ||
notifies :run, 'execute[reload-systemd]', :immediately | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,25 +42,36 @@ | |
base_piddir redis['base_piddir'] | ||
end | ||
|
||
template '/usr/lib/systemd/system/[email protected]' do | ||
source '[email protected]' | ||
variables({ :bin_path => node['redisio']['bin_path'] }) | ||
only_if { node['redisio']['job_control'] == 'systemd' } | ||
end | ||
|
||
# Create a service resource for each sentinel instance, named for the port it runs on. | ||
sentinel_instances.each do |current_sentinel| | ||
sentinel_name = current_sentinel['name'] | ||
job_control = node['redisio']['job_control'] | ||
|
||
if job_control == 'initd' | ||
case node['redisio']['job_control'] | ||
when 'initd' | ||
service "redis_sentinel_#{sentinel_name}" do | ||
# don't supply start/stop/restart commands, Chef::Provider::Service::* | ||
# do a fine job on it's own, and support systemd correctly | ||
supports :start => true, :stop => true, :restart => true, :status => false | ||
end | ||
elsif job_control == 'upstart' | ||
when 'upstart' | ||
service "redis_sentinel_#{sentinel_name}" do | ||
provider Chef::Provider::Service::Upstart | ||
start_command "start redis_sentinel_#{sentinel_name}" | ||
stop_command "stop redis_sentinel_#{sentinel_name}" | ||
restart_command "restart redis_sentinel_#{sentinel_name}" | ||
supports :start => true, :stop => true, :restart => true, :status => false | ||
end | ||
when 'systemd' | ||
service "redis-sentinel@#{sentinel_name}" do | ||
provider Chef::Provider::Service::Systemd | ||
supports :start => true, :stop => true, :restart => true, :status => true | ||
end | ||
else | ||
Chef::Log.error("Unknown job control type, no service resource created!") | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,28 @@ | |
sentinel_instances = [{'sentinel_port' => '26379', 'name' => 'mycluster', 'master_ip' => '127.0.0.1', 'master_port' => '6379'}] | ||
end | ||
|
||
execute 'reload-systemd' do | ||
command '/usr/bin/systemctl daemon-reload' | ||
only_if { node['redisio']['job_control'] == 'systemd'} | ||
action :nothing | ||
end | ||
|
||
sentinel_instances.each do |current_sentinel| | ||
sentinel_name = current_sentinel['name'] | ||
resource = resources("service[redis_sentinel_#{sentinel_name}]") | ||
resource_name = if node['redisio']['job_control'] == 'systemd' | ||
"service[redis-sentinel@#{sentinel_name}]" | ||
else | ||
"service[redis_sentinel_#{sentinel_name}]" | ||
end | ||
resource = resources(resource_name) | ||
resource.action Array(resource.action) | ||
resource.action << :start | ||
resource.action << :enable | ||
if node['redisio']['job_control'] != 'systemd' | ||
resource.action << :enable | ||
else | ||
link "/etc/systemd/system/multi-user.target.wants/redis@#{sentinel_name}.service" do | ||
to '/usr/lib/systemd/system/[email protected]' | ||
notifies :run, 'execute[reload-systemd]', :immediately | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=Redis persistent key-value database | ||
After=network.target | ||
|
||
[Service] | ||
ExecStart=<%= @bin_path %>/redis-server /etc/redis/sentinel_%i.conf --sentinel --daemonize no | ||
User=redis | ||
Group=redis | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Redis persistent key-value database | ||
After=network.target | ||
|
||
[Service] | ||
ExecStart=<%= @bin_path %>/redis-server /etc/redis/%i.conf --daemonize no | ||
ExecStop=/usr/bin/redis-shutdown | ||
User=redis | ||
Group=redis | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters