Skip to content

Commit

Permalink
Update the service HWRP and remove the _service recipe.
Browse files Browse the repository at this point in the history
This building block takes away the need to have a _service recipe.
  • Loading branch information
johnbellone committed Feb 8, 2015
1 parent 41eee88 commit ad41f68
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 253 deletions.
35 changes: 35 additions & 0 deletions libraries/provider_consul_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,39 @@ class Chef::Provider::ConsulClient < Chef::Provider::LWRPBase
def whyrun_supported?
true
end

action :create do
user node['consul']['user'] do

This comment has been minimized.

Copy link
@someara

someara Feb 9, 2015

This should be new_resource.run_user instead of being driven from node attributes

system true
comment 'consul service user'
home '/dev/null'
shell '/bin/false'
not_if { username == 'root' }
end

group node['consul']['group'] do
system true
append true
members node['consul']['user']
not_if { group_name == 'root' }
end

directory node['consul']['data_dir'] do
user node['consul']['user']
group node['consul']['group']
mode 0755
end

directory node['consul']['config_dir'] do
user node['consul']['user']
group node['consul']['group']
mode 0755
end
end

action :delete do
directory node['consul']['data_dir'] do
action :delete
end
end
end
1 change: 1 addition & 0 deletions libraries/provider_consul_client_binary.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Chef::Provider::ConsulClientBinary < Chef::Provider::ConsulClient
action :create do
super
include_recipe 'libarchive::default'

archive = remote_file Chef::Consul.cached_archive(node) do
Expand Down
1 change: 1 addition & 0 deletions libraries/provider_consul_client_source.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Chef::Provider::ConsulServiceSource < Chef::Provider::ConsulService
action :create do
super
include_recipe 'golang::default'

directory File.join(node['go']['gopath'], 'src/github.com/hashicorp') do
Expand Down
24 changes: 8 additions & 16 deletions libraries/provider_consul_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@ def whyrun_supported?
true
end

action :delete do

action :create do
consul_client 'consul' do
action :create
end
end

action :enable do

end

action :start do

end

action :stop do

end

action :restart do

action :delete do
consul_client 'consul' do
action :delete
end
end
end
30 changes: 30 additions & 0 deletions libraries/provider_consul_service_runit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Chef::Provider::ConsulServiceSystemd < Chef::Provider::ConsulService
action :start do
runit_service 'consul' do
supports status: true, restart: true, reload: true
action :start
end
end

action :stop do
runit_service 'consul' do
supports status: true, restart: true, reload: true
action :stop
end
end

action :restart do
runit_service 'consul' do
supports status: true, restart: true, reload: true
action :restart
end
end

action :reload do
runit_service 'consul' do
supports status: true, restart: true, reload: true
action :reload
reload_command %Q(#{node['runit']['sv_bin']} hup #{service_name})
end
end
end
31 changes: 30 additions & 1 deletion libraries/provider_consul_service_systemd.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
class Chef::Provider::ConsulServiceSystemd < Chef::Provider::ConsulService
action :create do
action :start do
service 'consul' do
supports status: true, restart: true, reload: true
provider Chef::Provider::Service::Init::Systemd
action [:start, :enable]
end
end

action :stop do
service 'consul' do
supports status: true, restart: true, reload: true
provider Chef::Provider::Service::Init::Systemd
action :stop
end
end

action :restart do
service 'consul' do
supports status: true, restart: true, reload: true
provider Chef::Provider::Service::Init::Systemd
action :restart
end
end

action :reload do
service 'consul' do
supports status: true, restart: true, reload: true
provider Chef::Provider::Service::Init::Systemd
action :reload
end
end
end
2 changes: 0 additions & 2 deletions libraries/provider_consul_service_sysvinit.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
class Chef::Provider::ConsulServiceSysvinit < Chef::Provider::ConsulService
action :create do
end
end
2 changes: 0 additions & 2 deletions libraries/provider_consul_service_upstart.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
class Chef::Provider::ConsulServiceUpstart < Chef::Provider::ConsulService
action :create do
end
end
232 changes: 0 additions & 232 deletions recipes/_service.rb

This file was deleted.

0 comments on commit ad41f68

Please sign in to comment.