Skip to content

Commit

Permalink
massive reorg; not complete
Browse files Browse the repository at this point in the history
  • Loading branch information
dearing committed Jul 27, 2015
1 parent 7684cdc commit 91d80d7
Show file tree
Hide file tree
Showing 32 changed files with 277 additions and 708 deletions.
4 changes: 2 additions & 2 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
driver:
name: docker
#driver:
# name: docker
# dockerfile: test/Dockerfile-centos66
# provision_command: curl -L http://www.chef.io/chef/install.sh | bash

Expand Down
21 changes: 0 additions & 21 deletions libraries/helpers.rb

This file was deleted.

8 changes: 4 additions & 4 deletions libraries/provider_elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class Elasticsearch < Chef::Provider::LWRPBase
use_inline_resources if defined?(use_inline_resources)

provides :elasticsearch

service_name = 'elasticsearch'

action :install do
Expand All @@ -16,6 +15,7 @@ class Elasticsearch < Chef::Provider::LWRPBase
group new_resource.group
has_binaries new_resource.has_binaries
owner new_resource.user
prefix_bin new_resource.prefix_bin
prefix_root new_resource.path
url new_resource.url
version new_resource.version
Expand All @@ -24,7 +24,7 @@ class Elasticsearch < Chef::Provider::LWRPBase
runit_service service_name do
default_logger true
owner new_resource.user
group new_resource.user
group new_resource.group
cookbook new_resource.source
action [:create, :enable]
end
Expand All @@ -36,7 +36,7 @@ class Elasticsearch < Chef::Provider::LWRPBase
end
end

# SERVICES
## SERVICES

action :enable do
service service_name do
Expand Down Expand Up @@ -64,7 +64,7 @@ class Elasticsearch < Chef::Provider::LWRPBase

action :restart do
service service_name do
action [:stop, :start]
action :restart
end
end
end
Expand Down
17 changes: 10 additions & 7 deletions libraries/provider_elasticsearch_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ class ElasticsearchConfig < Chef::Provider::LWRPBase
provides :elasticsearch_config

action :create do
template '/etc/sysconfig/elasticsearch' do
source 'elasticsearch/elasticsearch.sysconfig.erb'
owner 'root'
group 'root'
directory '/etc/elasticsearch' do
mode '0755'
action :create
recursive true
end

template '/etc/elasticsearch/elasticsearch.yml' do
source 'elasticsearch/elasticsearch.yml.erb'
owner 'elasticsearch'
group 'elasticsearch'
mode '0644'
cookbook new_resource.source
variables options: {
Expand All @@ -34,9 +40,6 @@ class ElasticsearchConfig < Chef::Provider::LWRPBase
end
end
action :delete do
file '/etc/sysconfig/elasticsearc' do
action :delete
end
end
end
end
Expand Down
15 changes: 8 additions & 7 deletions libraries/provider_kibana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Kibana < Chef::Provider::LWRPBase
version new_resource.version
end

runit_service 'kibana' do
runit_service service_name do
default_logger true
owner new_resource.user
group new_resource.group
Expand All @@ -36,6 +36,7 @@ class Kibana < Chef::Provider::LWRPBase
end
end

## SERVICES
action :enable do
runit_service service_name do
action :enable
Expand All @@ -48,12 +49,6 @@ class Kibana < Chef::Provider::LWRPBase
end
end

action :restart do
runit_service service_name do
action :restart
end
end

action :start do
runit_service service_name do
action :start
Expand All @@ -65,6 +60,12 @@ class Kibana < Chef::Provider::LWRPBase
action :stop
end
end

action :restart do
runit_service service_name do
action :restart
end
end
end
end
end
8 changes: 7 additions & 1 deletion libraries/provider_kibana_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ class KibanaConfig < Chef::Provider::LWRPBase
provides :kibana_config

action :create do
template '/etc/kibana.yml' do
directory '/etc/kibana' do
mode '0755'
action :create
recursive true
end

template '/etc/kibana/kibana.yml' do
source 'kibana/kibana.yml.erb'
owner new_resource.user
owner new_resource.group
Expand Down
65 changes: 65 additions & 0 deletions libraries/provider_logstash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class Chef
class Provider
class Logstash < Chef::Provider::LWRPBase
use_inline_resources if defined?(use_inline_resources)

provides :logstash

service_name = 'logstash'

action :install do
user new_resource.user
group new_resource.group

ark service_name do
checksum new_resource.checksum
group new_resource.group
has_binaries new_resource.has_binaries
owner new_resource.user
prefix_root new_resource.path
url new_resource.url
version new_resource.version
end

runit_service service_name do
default_logger true
owner new_resource.user
group new_resource.user
cookbook new_resource.source
action [:create, :enable]
end
end

action :remove do
runit_service service_name do
action :stop
end
end
## SERVICE

action :enable do
service service_name do
action :enable
end
end

action :restart do
service service_name do
action :restart
end
end

action :start do
service service_name do
action :start
end
end

action :stop do
service service_name do
action :stop
end
end
end
end
end
36 changes: 13 additions & 23 deletions libraries/provider_logstash_config.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ class LogstashConfig < Chef::Provider::LWRPBase
provides :logstash_config

action :create do
template '/etc/sysconfig/logstash' do
[new_resource.ls_conf_dir,
new_resource.ls_home,
'/var/log/logstash/',
'/etc/logstash'
].each do |dir|
directory dir do
mode '0755'
action :create
recursive true
end
end

template '/etc/logstash/config' do
source 'logstash/logstash.sysconfig.erb'
owner 'root'
group 'root'
Expand All @@ -28,28 +40,6 @@ class LogstashConfig < Chef::Provider::LWRPBase
'ls_nice' => new_resource.ls_nice
}
end
template '/etc/init.d/logstash' do
source 'logstash/logstash.initd.erb'
owner 'root'
group 'root'
mode '0755'
cookbook new_resource.source
variables options: {
'javacmd' => new_resource.javacmd,
'ls_home' => new_resource.ls_home,
'ls_opts' => new_resource.ls_opts,
'ls_heap_size' => new_resource.ls_heap_size,
'ls_java_opts' => new_resource.ls_java_opts,
'ls_pidfile' => new_resource.ls_pidfile,
'ls_user' => new_resource.ls_user,
'ls_group' => new_resource.ls_group,
'ls_log_file' => new_resource.ls_log_file,
'ls_use_gc_logging' => new_resource.ls_use_gc_logging,
'ls_conf_dir' => new_resource.ls_conf_dir,
'ls_open_files' => new_resource.ls_open_files,
'ls_nice' => new_resource.ls_nice
}
end

template "#{new_resource.ls_conf_dir}/00-input.conf" do
source 'logstash/conf.d/00-input.conf.erb'
Expand Down
70 changes: 70 additions & 0 deletions libraries/provider_logstash_forwarder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class Chef
class Provider
class LogstashForwarder < Chef::Provider::LWRPBase
use_inline_resources if defined?(use_inline_resources)

provides :logstash_forwarder
service_name = 'logstash_forwarder'

action :install do
user new_resource.user
group new_resource.group

# TODO: react to os/arch
remote_file '/opt/bin/logstash-forwarder' do
owner new_resource.user
group new_resource.group
mode '0755'
source 'https://download.elastic.co/logstash-forwarder/binaries/logstash-forwarder_linux_amd64'
checksum '5f49c5be671fff981b5ad1f8c5557a7e9973b24e8c73dbf0648326d400e6a4a1'
end

runit_service service_name do
default_logger true
owner new_resource.user
group new_resource.user
cookbook new_resource.source
action [:create, :enable]
end
end

action :remove do
runit_service service_name do
action :stop
end
end

## SERVICE

action :enable do
service service_name do
action :enable
end
end

action :disable do
service service_name do
action :disable
end
end

action :restart do
service service_name do
action :restart
end
end

action :start do
service service_name do
action :start
end
end

action :stop do
service service_name do
action :stop
end
end
end
end
end
Loading

0 comments on commit 91d80d7

Please sign in to comment.