diff --git a/.kitchen.yml b/.kitchen.yml old mode 100755 new mode 100644 index 2e992eb..d020f8a --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,16 +1,21 @@ --- -driver_plugin: vagrant +#driver: +# name: docker +# dockerfile: test/Dockerfile-centos66 +# provision_command: curl -L http://www.chef.io/chef/install.sh | bash +driver_config: + publish_all: true platforms: - name: centos-6.6 provisioner: name: chef_zero - require_chef_omnibus: '12.4.0' + require_chef_omnibus: '12.4.1' data_bags_path: 'test/integration/data_bags' suites: - name: default run_list: - - recipe[elktest] \ No newline at end of file + - recipe[elktest] diff --git a/Gemfile b/Gemfile index 3017623..c209eb8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,8 @@ source 'https://rubygems.org' gem 'berkshelf' + +group :integration do + gem 'test-kitchen' + gem 'kitchen-docker' +end diff --git a/libraries/helpers.rb b/libraries/helpers.rb old mode 100755 new mode 100644 index ace9957..53cc90c --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -1,21 +1,6 @@ require 'chef' -module Elasticsearch - module Helpers - end -end - -module Logstash - module Helpers - end -end - -module LogstashForwarder - module Helpers - end -end - -module Kibana +module ELK module Helpers end end diff --git a/libraries/provider_elasticsearch.rb b/libraries/provider_elasticsearch.rb new file mode 100644 index 0000000..b825776 --- /dev/null +++ b/libraries/provider_elasticsearch.rb @@ -0,0 +1,82 @@ +class Chef + class Provider + class Elasticsearch < Chef::Provider::LWRPBase + include ELK::Helpers + + use_inline_resources if defined?(use_inline_resources) + + provides :elasticsearch + + service_name = 'elasticsearch' + + action :install do + home_dir = "#{new_resource.path}/elasticsearch-#{new_resource.version}" + + 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.group + cookbook new_resource.source + env new_resource.runit_env + options new_resource.runit_options.merge( + 'home_dir' => home_dir, + 'user' => new_resource.user, + 'group' => new_resource.group + ) + action [:create, :enable] + end + end + + action :remove do + service service_name do + action :stop + end + end + + ## SERVICES + + action :enable do + service service_name do + action :enable + end + end + + action :disable do + service service_name do + action :disable + end + end + + action :start do + service service_name do + action :start + end + end + + action :stop do + service service_name do + action :stop + end + end + + action :restart do + service service_name do + action :restart + end + end + end + end +end diff --git a/libraries/provider_elasticsearch_config.rb b/libraries/provider_elasticsearch_config.rb deleted file mode 100755 index 5f560e7..0000000 --- a/libraries/provider_elasticsearch_config.rb +++ /dev/null @@ -1,76 +0,0 @@ -class Chef - class Provider - class ElasticsearchConfig < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - provides :elasticsearch_config - - action :create do - template '/etc/sysconfig/elasticsearch' do - source 'elasticsearch/elasticsearch.sysconfig.erb' - owner 'root' - group 'root' - mode '0644' - cookbook new_resource.source - variables options: { - 'conf_dir' => new_resource.conf_dir, - 'conf_file' => new_resource.conf_file, - 'data_dir' => new_resource.data_dir, - 'es_direct_size' => new_resource.es_direct_size, - 'es_group' => new_resource.es_group, - 'es_heap_newsize' => new_resource.es_heap_newsize, - 'es_heap_size' => new_resource.es_heap_size, - 'es_home' => new_resource.es_home, - 'es_java_opts' => new_resource.es_java_opts, - 'es_user' => new_resource.es_user, - 'log_dir' => new_resource.log_dir, - 'max_locked_memory' => new_resource.max_locked_memory, - 'max_map_count' => new_resource.max_map_count, - 'max_open_files' => new_resource.max_open_files, - 'pid_dir' => new_resource.pid_dir, - 'restart_on_upgrade' => new_resource.restart_on_upgrade, - 'work_dir' => new_resource.work_dir - } - end - - # TODO: probably better to let it source the sysconfig template instead - template '/etc/init.d/elasticsearch' do - source 'elasticsearch/elasticsearch.initd.erb' - owner 'root' - group 'root' - mode '0755' - cookbook new_resource.source - variables options: { - 'conf_dir' => new_resource.conf_dir, - 'conf_file' => new_resource.conf_file, - 'data_dir' => new_resource.data_dir, - 'es_direct_size' => new_resource.es_direct_size, - 'es_group' => new_resource.es_group, - 'es_heap_newsize' => new_resource.es_heap_newsize, - 'es_heap_size' => new_resource.es_heap_size, - 'es_home' => new_resource.es_home, - 'es_java_opts' => new_resource.es_java_opts, - 'es_user' => new_resource.es_user, - 'log_dir' => new_resource.log_dir, - 'max_locked_memory' => new_resource.max_locked_memory, - 'max_map_count' => new_resource.max_map_count, - 'max_open_files' => new_resource.max_open_files, - 'pid_dir' => new_resource.pid_dir, - 'restart_on_upgrade' => new_resource.restart_on_upgrade, - 'work_dir' => new_resource.work_dir - } - end - end - - action :delete do - file '/etc/sysconfig/elasticsearc' do - action :delete - end - - file '/etc/init.d/elasticsearch' do - action :delete - end - end - end - end -end diff --git a/libraries/provider_elasticsearch_service.rb b/libraries/provider_elasticsearch_service.rb deleted file mode 100755 index 04159a2..0000000 --- a/libraries/provider_elasticsearch_service.rb +++ /dev/null @@ -1,73 +0,0 @@ -class Chef - class Provider - class ElasticsearchService < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - provides :elasticsearch_service - - service_name = 'elasticsearch' - - action :create do - install_repository - package service_name do - action :install - end - end - - action :delete do - service service_name do - action :stop - end - package service_name do - action :remove - end - remove_repository - end - - 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 - - def install_repository - yum_repository 'elasticsearch-1.6' do - description 'Elasticsearch repository for 1.6.x packages' - baseurl 'http://packages.elastic.co/elasticsearch/1.6/centos' - gpgkey 'https://packages.elastic.co/GPG-KEY-elasticsearch' - action :create - end - end - - def remove_repository - yum_repository 'elasticsearch-1.6' do - action :delete - end - end - end - end -end diff --git a/libraries/provider_kibana.rb b/libraries/provider_kibana.rb new file mode 100644 index 0000000..8b6c7b8 --- /dev/null +++ b/libraries/provider_kibana.rb @@ -0,0 +1,113 @@ +class Chef + class Provider + class Kibana < Chef::Provider::LWRPBase + use_inline_resources if defined?(use_inline_resources) + + provides :kibana + + service_name = 'kibana' + + action :install do + user new_resource.user + group new_resource.group + + # ARK + ark service_name do + checksum new_resource.checksum + group new_resource.group + has_binaries ['bin/kibana'] + owner new_resource.user + prefix_root new_resource.path + url new_resource.url + version new_resource.version + end + + home_dir = "#{new_resource.path}/kibana-#{new_resource.version}" + + template "#{home_dir}/config/kibana.yml" do + source 'kibana/kibana.yml.erb' + owner new_resource.user + owner new_resource.group + mode '0644' + cookbook new_resource.source + variables options: { + 'default_app_id' => new_resource.default_app_id, + 'elasticsearch_preserve_host' => new_resource.elasticsearch_preserve_host, + 'elasticsearch_url' => new_resource.elasticsearch_url, + 'group' => new_resource.group, + 'host' => new_resource.host, + 'kibana_elasticsearch_client_crt' => new_resource.kibana_elasticsearch_client_crt, + 'kibana_elasticsearch_client_key' => new_resource.kibana_elasticsearch_client_key, + 'kibana_elasticsearch_password' => new_resource.kibana_elasticsearch_password, + 'kibana_elasticsearch_username' => new_resource.kibana_elasticsearch_username, + 'kibana_index' => new_resource.kibana_index, + 'log_file' => new_resource.log_file, + 'pid_file' => new_resource.pid_file, + 'ping_timeout' => new_resource.ping_timeout, + 'port' => new_resource.port, + 'request_timeout' => new_resource.request_timeout, + 'shard_timeout' => new_resource.shard_timeout, + 'ssl_cert_file' => new_resource.ssl_cert_file, + 'ssl_key_file' => new_resource.ssl_key_file, + 'startup_timeout' => new_resource.startup_timeout, + 'user' => new_resource.user, + 'verify_ssl' => new_resource.verify_ssl + } + end + + # RUNIT + runit_service service_name do + default_logger true + owner new_resource.user + group new_resource.group + cookbook new_resource.source + env new_resource.runit_env + options new_resource.runit_options.merge( + 'home_dir' => home_dir, + 'user' => new_resource.user, + 'group' => new_resource.group, + 'config_file' => "#{home_dir}/config/kibana.yml" + ) + action [:create, :enable] + end + end + + action :remove do + runit_service service_name do + action :stop + end + end + + ## SERVICES + action :enable do + runit_service service_name do + action :enable + end + end + + action :disable do + runit_service service_name do + action :disable + end + end + + action :start do + runit_service service_name do + action :start + end + end + + action :stop do + runit_service service_name do + action :stop + end + end + + action :restart do + runit_service service_name do + action :restart + end + end + end + end +end diff --git a/libraries/provider_kibana_config.rb b/libraries/provider_kibana_config.rb deleted file mode 100644 index faed7b0..0000000 --- a/libraries/provider_kibana_config.rb +++ /dev/null @@ -1,42 +0,0 @@ -class Chef - class Provider - class KibanaConfig < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - provides :kibana_config - - action :create do - template '/etc/kibana.yml' do - source 'kibana/kibana.yml.erb' - owner new_resource.user - owner new_resource.group - mode '0644' - cookbook new_resource.source - variables options: { - 'default_app_id' => new_resource.default_app_id, - 'elasticsearch_preserve_host' => new_resource.elasticsearch_preserve_host, - 'elasticsearch_url' => new_resource.elasticsearch_url, - 'group' => new_resource.group, - 'host' => new_resource.host, - 'kibana_elasticsearch_client_crt' => new_resource.kibana_elasticsearch_client_crt, - 'kibana_elasticsearch_client_key' => new_resource.kibana_elasticsearch_client_key, - 'kibana_elasticsearch_password' => new_resource.kibana_elasticsearch_password, - 'kibana_elasticsearch_username' => new_resource.kibana_elasticsearch_username, - 'kibana_index' => new_resource.kibana_index, - 'log_file' => new_resource.log_file, - 'pid_file' => new_resource.pid_file, - 'ping_timeout' => new_resource.ping_timeout, - 'port' => new_resource.port, - 'request_timeout' => new_resource.request_timeout, - 'shard_timeout' => new_resource.shard_timeout, - 'ssl_cert_file' => new_resource.ssl_cert_file, - 'ssl_key_file' => new_resource.ssl_key_file, - 'startup_timeout' => new_resource.startup_timeout, - 'user' => new_resource.user, - 'verify_ssl' => new_resource.verify_ssl - } - end - end - end - end -end diff --git a/libraries/provider_kibana_service.rb b/libraries/provider_kibana_service.rb deleted file mode 100644 index 8eee5b6..0000000 --- a/libraries/provider_kibana_service.rb +++ /dev/null @@ -1,68 +0,0 @@ -class Chef - class Provider - class KibanaService < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - provides :kibana_service - - action :create do - user new_resource.user - group new_resource.group - - ark 'kibana' do - checksum new_resource.checksum - group new_resource.group - has_binaries ['bin/kibana'] - owner new_resource.user - prefix_root new_resource.path - url new_resource.url - version new_resource.version - end - - runit_service 'kibana' do - default_logger true - owner "kibana" - group "kibana" - cookbook new_resource.source - action [:create, :enable] - end - end - - action :delete do - runit_service 'kibana' do - action :stop - end - end - - action :enable do - runit_service 'kibana' do - action :enable - end - end - - action :disable do - runit_service 'kibana' do - action :disable - end - end - - action :restart do - runit_service 'kibana' do - action [:stop, :start] - end - end - - action :start do - runit_service 'kibana' do - action :start - end - end - - action :stop do - runit_service 'kibana' do - action :stop - end - end - end - end -end diff --git a/libraries/provider_logstash.rb b/libraries/provider_logstash.rb new file mode 100644 index 0000000..8b14a77 --- /dev/null +++ b/libraries/provider_logstash.rb @@ -0,0 +1,103 @@ +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 + home_dir = "/opt/logstash/logstash-#{new_resource.version}" + + user new_resource.user + group new_resource.group + + directory "#{home_dir}/config" do + owner new_resource.user + group new_resource.group + mode '0755' + recursive true + action :create + end + + 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 + + template "#{home_dir}/config/logging.yml" do + source 'logstash/logging.yml.erb' + owner 'root' + group 'root' + mode '0644' + cookbook new_resource.source + end + + template "#{home_dir}/config/logstash.conf" do + source 'logstash/logstash.conf.erb' + owner 'root' + group 'root' + mode '0644' + cookbook new_resource.source + variables options: { + 'port' => new_resource.port, + 'key' => new_resource.key, + 'crt' => new_resource.crt, + 'key_location' => new_resource.key_location, + 'crt_location' => new_resource.crt_location + } + end + + runit_service service_name do + default_logger true + owner new_resource.user + group new_resource.user + cookbook new_resource.source + options new_resource.runit_options.merge( + 'home_dir' => home_dir, + 'user' => new_resource.user, + 'group' => new_resource.group, + 'config_file' => 'config/logstash.conf' + ) + 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 diff --git a/libraries/provider_logstash_config.rb b/libraries/provider_logstash_config.rb deleted file mode 100755 index 505b429..0000000 --- a/libraries/provider_logstash_config.rb +++ /dev/null @@ -1,89 +0,0 @@ -class Chef - class Provider - class LogstashConfig < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - provides :logstash_config - - action :create do - template '/etc/sysconfig/logstash' do - source 'logstash/logstash.sysconfig.erb' - owner 'root' - group 'root' - mode '0644' - 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 '/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' - owner 'root' - group 'root' - mode '0644' - cookbook new_resource.source - variables options: { - 'port' => new_resource.port, - 'key' => new_resource.key, - 'crt' => new_resource.crt, - 'key_location' => new_resource.key_location, - 'crt_location' => new_resource.crt_location - } - end - - template "#{new_resource.ls_conf_dir}/99-input.conf" do - source 'logstash/conf.d/99-output.conf.erb' - owner 'root' - group 'root' - mode '0644' - cookbook new_resource.source - end - - template "#{new_resource.ls_conf_dir}/10-syslog.conf" do - source 'logstash/conf.d/10-syslog.conf.erb' - owner 'root' - group 'root' - mode '0644' - cookbook new_resource.source - end - end - action :delete do - end - end - end -end diff --git a/libraries/provider_logstash_forwarder.rb b/libraries/provider_logstash_forwarder.rb new file mode 100644 index 0000000..8630cfb --- /dev/null +++ b/libraries/provider_logstash_forwarder.rb @@ -0,0 +1,100 @@ +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 + # TODO: make home folder working dir + user new_resource.user + group new_resource.group + + home_dir = "/opt/logstash-forwarder/logstash-forwarder-#{new_resource.version}" + + # TODO: sloppy + directory home_dir do + owner new_resource.user + group new_resource.group + mode '0755' + recursive true + action :create + end + + # TODO: react to os/arch + remote_file "#{home_dir}/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 + + template "#{home_dir}/logstash-forwarder.conf" do + source 'logstash-forwarder/logstash-forwarder.conf.erb' + owner 'logstash' + group 'logstash' + mode '0644' + cookbook new_resource.source + variables options: { + 'crt_location' => new_resource.crt_location, + 'key_location' => new_resource.key_location + } + end + + runit_service service_name do + default_logger true + owner new_resource.user + group new_resource.group + cookbook new_resource.source + options new_resource.runit_options.merge( + 'home_dir' => home_dir, + 'user' => new_resource.user, + 'group' => new_resource.group, + 'config_file' => 'logstash-forwarder.conf' + ) + 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 diff --git a/libraries/provider_logstash_forwarder_config.rb b/libraries/provider_logstash_forwarder_config.rb deleted file mode 100755 index d20844f..0000000 --- a/libraries/provider_logstash_forwarder_config.rb +++ /dev/null @@ -1,56 +0,0 @@ -class Chef - class Provider - class LogstashForwarderConfig < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - provides :logstash_forwarder_config - - action :create do - template '/etc/init.d/logstash-forwarder' do - source 'logstash-forwarder/logstash-forwarder.initd.erb' - owner 'root' - group 'root' - mode '0755' - cookbook new_resource.source - variables options: { - 'user' => new_resource.user, - 'group' => new_resource.group, - 'chroot' => new_resource.chroot, - 'chdir' => new_resource.chdir, - 'nice' => new_resource.nice - } - end - - template '/etc/default/logstash-forwarder' do - source 'logstash-forwarder/logstash-forwarder.erb' - owner 'root' - group 'root' - mode '0644' - cookbook new_resource.source - variables options: { - 'user' => new_resource.user, - 'group' => new_resource.group, - 'chroot' => new_resource.chroot, - 'chdir' => new_resource.chdir, - 'nice' => new_resource.nice - } - end - - template '/etc/logstash-forwarder.conf' do - source 'logstash-forwarder/logstash-forwarder.conf.erb' - owner 'root' - group 'root' - mode '0644' - cookbook new_resource.source - variables options: { - 'crt_location' => new_resource.crt_location, - 'key_location' => new_resource.key_location - } - end - end - - action :delete do - end - end - end -end diff --git a/libraries/provider_logstash_forwarder_service.rb b/libraries/provider_logstash_forwarder_service.rb deleted file mode 100755 index 8a083cd..0000000 --- a/libraries/provider_logstash_forwarder_service.rb +++ /dev/null @@ -1,73 +0,0 @@ -class Chef - class Provider - class LogstashForwarderService < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - provides :logstash_forwarder_service - - service_name = 'logstash-forwarder' - - action :create do - install_repository - package service_name do - action :install - end - end - - action :delete do - service service_name do - action :stop - end - package service_name do - action :remove - end - remove_repository - end - - 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 - - def install_repository - yum_repository 'logstash-forwarder' do - description 'logstash repository for 1.5.x packages' - baseurl 'http://packages.elasticsearch.org/logstashforwarder/centos' - gpgkey 'https://packages.elastic.co/GPG-KEY-elasticsearch' - action :create - end - end - - def remove_repository - yum_repository 'logstash-forwarder' do - action :delete - end - end - end - end -end diff --git a/libraries/provider_logstash_service.rb b/libraries/provider_logstash_service.rb deleted file mode 100755 index e918fdd..0000000 --- a/libraries/provider_logstash_service.rb +++ /dev/null @@ -1,67 +0,0 @@ -class Chef - class Provider - class LogstashService < Chef::Provider::LWRPBase - use_inline_resources if defined?(use_inline_resources) - - provides :logstash_service - - service_name = 'logstash' - - action :create do - install_repository - package service_name do - action :install - end - end - - action :delete do - service service_name do - action :stop - end - package service_name do - action :remove - end - remove_repository - end - - 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 - - def install_repository - yum_repository 'logstash-1.5' do - description 'logstash repository for 1.5.x packages' - baseurl 'http://packages.elasticsearch.org/logstash/1.5/centos' - gpgkey 'https://packages.elastic.co/GPG-KEY-elasticsearch' - action :create - end - end - - def remove_repository - yum_repository 'logstash-1.5' do - action :delete - end - end - end - end -end diff --git a/libraries/resource_elasticsearch.rb b/libraries/resource_elasticsearch.rb new file mode 100644 index 0000000..de21cae --- /dev/null +++ b/libraries/resource_elasticsearch.rb @@ -0,0 +1,59 @@ +require 'chef/resource' + +class Chef + class Resource + class Elasticsearch < Chef::Resource::LWRPBase + resource_name :elasticsearch + default_action :install + actions [:install, :remove, :enable, :disable, :restart, :start, :stop] + + require 'chef/resource' + + # used to target any files/templates; default to self + attribute :source, kind_of: String, default: 'elk' + + # ARK + # url and sha256 of the archive to download and unpack + attribute :url, kind_of: String, default: 'https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.0.tar.gz' + attribute :checksum, kind_of: String, default: '6fabed2db09e1b88587df15269df328ecef33e155b3c675a2a6d2299bda09c95' + attribute :version, kind_of: String, default: '1.7.0' + attribute :has_binaries, kind_of: Array, default: ['bin/elasticsearch'] + # attribute :append_env_path, kind_of: [TrueClass, FalseClass], default: false + + attribute :name, kind_of: String, default: 'elasticsearch' + attribute :user, kind_of: String, default: 'elasticsearch' + attribute :group, kind_of: String, default: 'elasticsearch' + attribute :owner, kind_of: String, default: 'elasticsearch' + attribute :path, kind_of: String, default: '/opt/elasticsearch' + + # RUNIT + attribute :runit_args, kind_of: Hash, default: { + + } + + attribute :runit_options, kind_of: Hash, default: { + + } + attribute :runit_env, kind_of: Hash, default: { + 'CONF_DIR' => '/etc/elasticsearch', + 'CONF_FILE' => '$CONF_DIR/elasticsearch.yml', + 'DATA_DIR' => '/var/lib/elasticsearch', + 'ES_DIRECT_SIZE' => '', + 'ES_GC_LOG_FILE' => '/var/log/elasticsearch/gc.log', + 'ES_GROUP' => 'elasticsearch', + 'ES_HEAP_NEWSIZE' => '', + 'ES_HEAP_SIZE' => '2g', + 'ES_HOME' => '/usr/share/elasticsearch', + 'ES_JAVA_OPTS' => '', + 'ES_RESTART_ON_UPGRADE' => 'true', + 'ES_USER' => 'elasticsearch', + 'LOG_DIR' => '/var/log/elasticsearch', + 'MAX_LOCKED_MEMORY' => 'unlimited', + 'MAX_MAP_COUNT' => '262144', + 'MAX_OPEN_FILES' => '65535', + 'PID_DIR' => '/var/run/elasticsearch', + 'WORK_DIR' => '/tmp/elasticsearch' + } + end + end +end diff --git a/libraries/resource_elasticsearch_config.rb b/libraries/resource_elasticsearch_config.rb deleted file mode 100755 index 859afd4..0000000 --- a/libraries/resource_elasticsearch_config.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'chef/resource' - -class Chef - class Resource - class ElasticsearchConfig < Chef::Resource::LWRPBase - resource_name :elasticsearch_config - default_action :create - actions [:create, :delete] - - attribute :conf_dir, kind_of: String, default: '/etc/elasticsearch' - attribute :conf_file, kind_of: String, default: '/etc/elasticsearch/elasticsearch.yml' - attribute :data_dir, kind_of: String, default: '/var/lib/elasticsearch' - attribute :es_direct_size, kind_of: String, default: nil - attribute :es_group, kind_of: String, default: 'elasticsearch' - attribute :es_heap_newsize, kind_of: String, default: nil - attribute :es_heap_size, kind_of: String, default: '1g' - attribute :es_home, kind_of: String, default: '/usr/share/elasticsearch' - attribute :es_java_opts, kind_of: String, default: nil - attribute :es_user, kind_of: String, default: 'elasticsearch' - attribute :log_dir, kind_of: String, default: '/var/log/elasticsearch' - attribute :max_locked_memory, kind_of: String, default: 'unlimited' - attribute :max_map_count, kind_of: Integer, default: 65_535 - attribute :max_open_files, kind_of: Integer, default: 65_535 - attribute :pid_dir, kind_of: String, default: '/var/run/elasticsearch' - attribute :restart_on_upgrade, kind_of: [TrueClass, FalseClass], default: false - attribute :source, kind_of: String, default: 'elk' - attribute :work_dir, kind_of: String, default: '/tmp/elasticsearch' - end - end -end diff --git a/libraries/resource_elasticsearch_service.rb b/libraries/resource_elasticsearch_service.rb deleted file mode 100755 index 76cbb6b..0000000 --- a/libraries/resource_elasticsearch_service.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'chef/resource' - -class Chef - class Resource - class ElasticsearchService < Chef::Resource::LWRPBase - resource_name :elasticsearch_service - default_action :create - actions [:create, :delete, :enable, :disable, :restart, :start, :stop] - end - end -end diff --git a/libraries/resource_kibana_config.rb b/libraries/resource_kibana.rb old mode 100755 new mode 100644 similarity index 62% rename from libraries/resource_kibana_config.rb rename to libraries/resource_kibana.rb index 39dddc4..73cb3f6 --- a/libraries/resource_kibana_config.rb +++ b/libraries/resource_kibana.rb @@ -2,33 +2,44 @@ class Chef class Resource - class KibanaConfig < Chef::Resource::LWRPBase - resource_name :kibana_config - default_action :create - actions [:create, :delete] + class Kibana < Chef::Resource::LWRPBase + resource_name :kibana + default_action :install + actions [:install, :remove, :enable, :disable, :restart, :start, :stop] - attribute :group, kind_of: String, default: 'kibana' - attribute :kibana_elasticsearch_password, kind_of: String, default: nil - attribute :user, kind_of: String, default: 'kibana' + attribute :checksum, kind_of: String, default: '6f42d25f337fd49f38e2af81b9ab6e0c987a199a8c0b2e1410d072f812cb4520' attribute :default_app_id, kind_of: String, default: 'discover' + attribute :elasticsearch_host, kind_of: String, default: '127.0.0.1' + attribute :elasticsearch_port, kind_of: Integer, default: 5601 attribute :elasticsearch_preserve_host, kind_of: [TrueClass, FalseClass], default: true attribute :elasticsearch_url, kind_of: String, default: 'http://localhost:9200' + attribute :group, kind_of: String, default: 'kibana' attribute :host, kind_of: String, default: '0.0.0.0' attribute :kibana_elasticsearch_client_crt, kind_of: String, default: nil attribute :kibana_elasticsearch_client_key, kind_of: String, default: nil + attribute :kibana_elasticsearch_password, kind_of: String, default: nil attribute :kibana_elasticsearch_username, kind_of: String, default: nil attribute :kibana_index, kind_of: String, default: '.kibana' attribute :log_file, kind_of: Integer, default: './kibana.log' + attribute :path, kind_of: String, default: '/opt/kibana' attribute :pid_file, kind_of: String, default: '/var/run/kibana.pid' attribute :ping_timeout, kind_of: Integer, default: 1500 - attribute :port, kind_of: Integer, default: 5601 + attribute :port, kind_of: [String, Integer], default: 3000 attribute :request_timeout, kind_of: Integer, default: 30_000 attribute :shard_timeout, kind_of: Integer, default: 0 + attribute :source, kind_of: String, default: 'elk' attribute :ssl_cert_file, kind_of: String, default: nil attribute :ssl_key_file, kind_of: String, default: nil - attribute :source, kind_of: String, default: 'elk' attribute :startup_timeout, kind_of: Integer, default: 5000 + attribute :url, kind_of: String, default: 'https://download.elastic.co/kibana/kibana/kibana-4.1.1-linux-x64.tar.gz' + attribute :user, kind_of: String, default: 'kibana' attribute :verify_ssl, kind_of: [TrueClass, FalseClass], default: true + attribute :version, kind_of: String, default: '4.1.1' + + # RUNIT + attribute :runit_args, kind_of: Hash, default: {} + attribute :runit_options, kind_of: Hash, default: {} + attribute :runit_env, kind_of: Hash, default: {} end end end diff --git a/libraries/resource_kibana_service.rb b/libraries/resource_kibana_service.rb deleted file mode 100755 index 185974e..0000000 --- a/libraries/resource_kibana_service.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'chef/resource' - -class Chef - class Resource - class KibanaService < Chef::Resource::LWRPBase - resource_name :kibana_service - default_action :create - actions [:create, :delete, :enable, :disable, :restart, :start, :stop] - - attribute :checksum, kind_of: String, default: '6f42d25f337fd49f38e2af81b9ab6e0c987a199a8c0b2e1410d072f812cb4520' - attribute :group, kind_of: String, default: 'kibana' - attribute :host, kind_of: String, default: '127.0.0.1' - attribute :path, kind_of: String, default: '/opt/kibana' - attribute :port, kind_of: [String, Integer], default: 3000 - attribute :url, kind_of: String, default: 'https://download.elastic.co/kibana/kibana/kibana-4.1.1-linux-x64.tar.gz' - attribute :user, kind_of: String, default: 'kibana' - attribute :version, kind_of: String, default: '4.1.1' - - attribute :source, kind_of: String, default: 'elk' - end - end -end diff --git a/libraries/resource_logstash.rb b/libraries/resource_logstash.rb new file mode 100644 index 0000000..43e556c --- /dev/null +++ b/libraries/resource_logstash.rb @@ -0,0 +1,54 @@ +require 'chef/resource' + +class Chef + class Resource + class Logstash < Chef::Resource::LWRPBase + resource_name :logstash + default_action :install + actions [:install, :remove, :enable, :disable, :restart, :start, :stop] + + # used to target any files/templates; default to self + attribute :source, kind_of: String, default: 'elk' + + # url and sha256 of the archive to download and unpack + attribute :url, kind_of: String, default: 'https://download.elastic.co/logstash/logstash/logstash-1.5.3.tar.gz' + attribute :checksum, kind_of: String, default: 'eb3c366074e561d777348bfe9db3d4d1cccbf2fa8e7406776f500b4ca639c4aa' + + # ARK tracks verioning by appending the :name with this for symlinking to a path + attribute :version, kind_of: String, default: '1.5.3' + attribute :has_binaries, kind_of: Array, default: ['bin/logstash'] + attribute :append_env_path, kind_of: [TrueClass, FalseClass], default: false + + # USER/GROUP to install by, also creates users on the OS for them + attribute :user, kind_of: String, default: 'logstash' + attribute :group, kind_of: String, default: 'logstash' + attribute :owner, kind_of: String, default: 'logstash' + + attribute :path, kind_of: String, default: '/opt/logstash' + + attribute :crt, kind_of: String, default: '' + attribute :crt_location, kind_of: String, default: '/etc/logstash/logstash.crt' + attribute :javacmd, kind_of: String, default: '/usr/bin/java' + attribute :key, kind_of: String, default: '' + attribute :key_location, kind_of: String, default: '/etc/logstash/logstash.key' + attribute :ls_conf_dir, kind_of: String, default: '/etc/logstash/conf.d' + attribute :ls_group, kind_of: String, default: 'logstash' + attribute :ls_heap_size, kind_of: String, default: '500m' + attribute :ls_home, kind_of: String, default: '/var/lib/logstash' + attribute :ls_java_opts, kind_of: String, default: '-Djava.io.tmpdir=$HOME' + attribute :ls_log_file, kind_of: String, default: '/var/log/logstash/logstash.log' + attribute :ls_nice, kind_of: Integer, default: 19 + attribute :ls_open_files, kind_of: Integer, default: 16_384 + attribute :ls_opts, kind_of: String, default: '' + attribute :ls_pidfile, kind_of: String, default: '/var/run/logstash.pid' + attribute :ls_use_gc_logging, kind_of: [TrueClass, FalseClass], default: true + attribute :ls_user, kind_of: String, default: 'logstash' + attribute :port, kind_of: Integer, default: 5043 + + # RUNIT + attribute :runit_args, kind_of: Hash, default: {} + attribute :runit_options, kind_of: Hash, default: {} + attribute :runit_env, kind_of: Hash, default: {} + end + end +end diff --git a/libraries/resource_logstash_config.rb b/libraries/resource_logstash_config.rb deleted file mode 100755 index 443d819..0000000 --- a/libraries/resource_logstash_config.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'chef/resource' - -class Chef - class Resource - class LogstashConfig < Chef::Resource::LWRPBase - resource_name :logstash_config - default_action :create - actions [:create, :delete] - - attribute :crt, kind_of: String, default: '' - attribute :crt_location, kind_of: String, default: '/opt/logstash/logstash.crt' - attribute :javacmd, kind_of: String, default: '/usr/bin/java' - attribute :key, kind_of: String, default: '' - attribute :key_location, kind_of: String, default: '/opt/logstash/logstash.key' - attribute :ls_conf_dir, kind_of: String, default: '/etc/logstash/conf.d' - attribute :ls_group, kind_of: String, default: 'logstash' - attribute :ls_heap_size, kind_of: String, default: '500m' - attribute :ls_home, kind_of: String, default: '/var/lib/logstash' - attribute :ls_java_opts, kind_of: String, default: '-Djava.io.tmpdir=$HOME' - attribute :ls_log_file, kind_of: String, default: '/var/log/logstash/logstash.log' - attribute :ls_nice, kind_of: Integer, default: 19 - attribute :ls_open_files, kind_of: Integer, default: 16_384 - attribute :ls_opts, kind_of: String, default: '' - attribute :ls_pidfile, kind_of: String, default: '/var/run/logstash.pid' - attribute :ls_use_gc_logging, kind_of: [TrueClass, FalseClass], default: true - attribute :ls_user, kind_of: String, default: 'logstash' - attribute :port, kind_of: Integer, default: 5043 - attribute :source, kind_of: String, default: 'elk' - end - end -end diff --git a/libraries/resource_logstash_forwarder.rb b/libraries/resource_logstash_forwarder.rb new file mode 100644 index 0000000..fce1fe5 --- /dev/null +++ b/libraries/resource_logstash_forwarder.rb @@ -0,0 +1,32 @@ +require 'chef/resource' + +class Chef + class Resource + class LogstashForwarder < Chef::Resource::LWRPBase + resource_name :logstash_forwarder + default_action :install + actions [:install, :remove, :enable, :disable, :restart, :start, :stop] + + # used to target any files/templates; default to self + attribute :source, kind_of: String, default: 'elk' + attribute :group, kind_of: String, default: 'logstash' + attribute :user, kind_of: String, default: 'logstash' + attribute :version, kind_of: String, default: '0.4.0' + + # CONFIGURATION; HASH IT UP + attribute :crt, kind_of: String, default: '' + attribute :crt_location, kind_of: String, default: '/etc/logstash-forwarder/logstash.crt' + attribute :key, kind_of: String, default: '' + attribute :key_location, kind_of: String, default: '/etc/logstash-forwarder/logstash.key' + attribute :chdir, kind_of: String, default: '/var/lib/logstash-forwarder' + attribute :chroot, kind_of: String, default: '/' + attribute :nice, kind_of: String, default: '' + attribute :port, kind_of: Integer, default: 5043 + + # RUNIT + attribute :runit_args, kind_of: Hash, default: {} + attribute :runit_options, kind_of: Hash, default: {} + attribute :runit_env, kind_of: Hash, default: {} + end + end +end diff --git a/libraries/resource_logstash_forwarder_config.rb b/libraries/resource_logstash_forwarder_config.rb deleted file mode 100755 index c9a9049..0000000 --- a/libraries/resource_logstash_forwarder_config.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'chef/resource' - -class Chef - class Resource - class LogstashForwarder < Chef::Resource::LWRPBase - resource_name :logstash_forwarder_config - default_action :create - actions [:create, :delete] - - attribute :chdir, kind_of: String, default: '/var/lib/logstash-forwarder' - attribute :chroot, kind_of: String, default: '/' - attribute :crt, kind_of: String, default: '' - attribute :crt_location, kind_of: String, default: '/opt/logstash-forwarder/logstash.crt' - attribute :group, kind_of: String, default: 'root' - attribute :key, kind_of: String, default: '' - attribute :key_location, kind_of: String, default: '/opt/logstash-forwarder/logstash.key' - attribute :nice, kind_of: String, default: '' - attribute :port, kind_of: Integer, default: 5043 - attribute :source, kind_of: String, default: 'elk' - attribute :user, kind_of: String, default: 'root' - end - end -end diff --git a/libraries/resource_logstash_forwarder_service.rb b/libraries/resource_logstash_forwarder_service.rb deleted file mode 100755 index 7ad8047..0000000 --- a/libraries/resource_logstash_forwarder_service.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'chef/resource' - -class Chef - class Resource - class LogstashForwarderService < Chef::Resource::LWRPBase - resource_name :logstash_forwarder_service - default_action :create - actions [:create, :delete, :enable, :disable, :restart, :start, :stop] - end - end -end diff --git a/libraries/resource_logstash_service.rb b/libraries/resource_logstash_service.rb deleted file mode 100755 index 7995466..0000000 --- a/libraries/resource_logstash_service.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'chef/resource' - -class Chef - class Resource - class LogstashService < Chef::Resource::LWRPBase - resource_name :logstash_service - default_action :create - actions [:create, :delete, :enable, :disable, :restart, :start, :stop] - end - end -end diff --git a/templates/centos/elasticsearch/elasticsearch.initd.erb b/templates/centos/elasticsearch/elasticsearch.initd.erb deleted file mode 100644 index 7cac7bf..0000000 --- a/templates/centos/elasticsearch/elasticsearch.initd.erb +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/sh -# -# elasticsearch -# -# chkconfig: 2345 80 20 -# description: Starts and stops a single elasticsearch instance on this system -# - -### BEGIN INIT INFO -# Provides: Elasticsearch -# Required-Start: $network $named -# Required-Stop: $network $named -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: This service manages the elasticsearch daemon -# Description: Elasticsearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search. -### END INIT INFO - -# -# init.d / servicectl compatibility (openSUSE) -# -if [ -f /etc/rc.status ]; then - . /etc/rc.status - rc_reset -fi - -# -# Source function library. -# -if [ -f /etc/rc.d/init.d/functions ]; then - . /etc/rc.d/init.d/functions -fi - -# Sets the default values for elasticsearch variables used in this script -ES_USER=<%= @options['es_user'] %> -ES_GROUP=<%= @options['es_group'] %> -ES_HOME=<%= @options['es_home'] %> -MAX_OPEN_FILES=<%= @options['max_open_files'] %> -MAX_MAP_COUNT=<%= @options['max_map_count'] %> -LOG_DIR=<%= @options['log_dir'] %> -DATA_DIR=<%= @options['data_dir'] %> -WORK_DIR=<%= @options['work_dir'] %> -CONF_DIR=<%= @options['conf_dir'] %> -CONF_FILE=<%= @options['conf_file'] %> -PID_DIR=<%= @options['pid_dir'] %> - -# Source the default env file -ES_ENV_FILE="/etc/sysconfig/elasticsearch" -if [ -f "$ES_ENV_FILE" ]; then - . "$ES_ENV_FILE" -fi - -exec="$ES_HOME/bin/elasticsearch" -prog="elasticsearch" -pidfile="$PID_DIR/${prog}.pid" - -export ES_HEAP_SIZE -export ES_HEAP_NEWSIZE -export ES_DIRECT_SIZE -export ES_JAVA_OPTS -export JAVA_HOME - -lockfile=/var/lock/subsys/$prog - -# backwards compatibility for old config sysconfig files, pre 0.90.1 -if [ -n $USER ] && [ -z $ES_USER ] ; then - ES_USER=$USER -fi - -checkJava() { - if [ -x "$JAVA_HOME/bin/java" ]; then - JAVA="$JAVA_HOME/bin/java" - else - JAVA=`which java` - fi - - if [ ! -x "$JAVA" ]; then - echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" - exit 1 - fi -} - -start() { - checkJava - [ -x $exec ] || exit 5 - [ -f $CONF_FILE ] || exit 6 - if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then - echo "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set" - return 7 - fi - if [ -n "$MAX_OPEN_FILES" ]; then - ulimit -n $MAX_OPEN_FILES - fi - if [ -n "$MAX_LOCKED_MEMORY" ]; then - ulimit -l $MAX_LOCKED_MEMORY - fi - if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then - sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT - fi - if [ -n "$WORK_DIR" ]; then - mkdir -p "$WORK_DIR" - chown "$ES_USER":"$ES_GROUP" "$WORK_DIR" - fi - echo -n $"Starting $prog: " - # if not running, start it up here, usually something like "daemon $exec" - daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - echo -n $"Stopping $prog: " - # stop it here, often "killproc $prog" - killproc -p $pidfile -d 20 $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - # run checks to determine if the service is running or use generic status - status -p $pidfile $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - - -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 -esac -exit $? diff --git a/templates/centos/elasticsearch/elasticsearch.sysconfig.erb b/templates/centos/elasticsearch/elasticsearch.sysconfig.erb deleted file mode 100755 index 5694c36..0000000 --- a/templates/centos/elasticsearch/elasticsearch.sysconfig.erb +++ /dev/null @@ -1,76 +0,0 @@ -# This file was generated by Chef -# Do NOT modify this file by hand. - -################################ -# Elasticsearch -################################ - -# Elasticsearch home directory -ES_HOME=<%= @options['es_home'] %> - -# Elasticsearch configuration directory -CONF_DIR=<%= @options['conf_dir'] %> - -# Elasticsearch configuration file -CONF_FILE=<%= @options['conf_file'] %> - -# Elasticsearch data directory -DATA_DIR=<%= @options['data_dir'] %> - -# Elasticsearch logs directory -LOG_DIR=<%= @options['log_dir'] %> - -# Elasticsearch work directory -WORK_DIR=<%= @options['work_dir'] %> - -# Elasticsearch PID directory -PID_DIR=<%= @options['pid_dir'] %> - -# Heap size defaults to 256m min, 1g max -# Set ES_HEAP_SIZE to 50% of available RAM, but no more than 31g -ES_HEAP_SIZE=<%= @options['es_heap_size'] %> - -<%= "ES_DIRECT_SIZE=#{@options['es_direct_size']}" if @options['es_direct_size'] -%> -<%= "ES_HEAP_NEWSIZE=#{@options['es_heap_newsize']}" if @options['es_heap_newsize'] -%> -<%= "ES_JAVA_OPTS=#{@options['es_java_opts']}" if @options['es_java_opts'] -%> - -# Configure restart on package upgrade (true, every other setting will lead to not restarting) -ES_RESTART_ON_UPGRADE=<%= @options['restart_on_upgrade'] %> - -# Path to the GC log file -#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log - -################################ -# Elasticsearch service -################################ - -# SysV init.d -# -# When executing the init script, this user will be used to run the elasticsearch service. -# The default value is 'elasticsearch' and is declared in the init.d file. -# Note that this setting is only used by the init script. If changed, make sure that -# the configured user can read and write into the data, work, plugins and log directories. -# For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service -ES_USER=<%= @options['es_user'] %> -ES_GROUP=<%= @options['es_group'] %> - -################################ -# System properties -################################ - -# Specifies the maximum file descriptor number that can be opened by this process -# When using Systemd, this setting is ignored and the LimitNOFILE defined in -# /usr/lib/systemd/system/elasticsearch.service takes precedence -MAX_OPEN_FILES=<%= @options['max_open_files'] %> - -# The maximum number of bytes of memory that may be locked into RAM -# Set to "unlimited" if you use the 'bootstrap.mlockall: true' option -# in elasticsearch.yml (ES_HEAP_SIZE must also be set). -# When using Systemd, the LimitMEMLOCK property must be set -# in /usr/lib/systemd/system/elasticsearch.service -MAX_LOCKED_MEMORY=<%= @options['max_locked_memory'] %> - -# Maximum number of VMA (Virtual Memory Areas) a process can own -# When using Systemd, this setting is ignored and the 'vm.max_map_count' -# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -MAX_MAP_COUNT=<%= @options['max_map_count'] %> diff --git a/templates/centos/elasticsearch/elasticsearch.yml.erb b/templates/centos/elasticsearch/elasticsearch.yml.erb deleted file mode 100755 index 8f15f14..0000000 --- a/templates/centos/elasticsearch/elasticsearch.yml.erb +++ /dev/null @@ -1,387 +0,0 @@ -# This file was generated by Chef -# Do NOT modify this file by hand. -##################### Elasticsearch Configuration Example ##################### - -# This file contains an overview of various configuration settings, -# targeted at operations staff. Application developers should -# consult the guide at . -# -# The installation procedure is covered at -# . -# -# Elasticsearch comes with reasonable defaults for most settings, -# so you can try it out without bothering with configuration. -# -# Most of the time, these defaults are just fine for running a production -# cluster. If you're fine-tuning your cluster, or wondering about the -# effect of certain configuration option, please _do ask_ on the -# mailing list or IRC channel [http://elasticsearch.org/community]. - -# Any element in the configuration can be replaced with environment variables -# by placing them in ${...} notation. For example: -# -#node.rack: ${RACK_ENV_VAR} - -# For information on supported formats and syntax for the config file, see -# - - -################################### Cluster ################################### - -# Cluster name identifies your cluster for auto-discovery. If you're running -# multiple clusters on the same network, make sure you're using unique names. -# -#cluster.name: elasticsearch - - -#################################### Node ##################################### - -# Node names are generated dynamically on startup, so you're relieved -# from configuring them manually. You can tie this node to a specific name: -# -#node.name: "Franz Kafka" - -# Every node can be configured to allow or deny being eligible as the master, -# and to allow or deny to store the data. -# -# Allow this node to be eligible as a master node (enabled by default): -# -#node.master: true -# -# Allow this node to store data (enabled by default): -# -#node.data: true - -# You can exploit these settings to design advanced cluster topologies. -# -# 1. You want this node to never become a master node, only to hold data. -# This will be the "workhorse" of your cluster. -# -#node.master: false -#node.data: true -# -# 2. You want this node to only serve as a master: to not store any data and -# to have free resources. This will be the "coordinator" of your cluster. -# -#node.master: true -#node.data: false -# -# 3. You want this node to be neither master nor data node, but -# to act as a "search load balancer" (fetching data from nodes, -# aggregating results, etc.) -# -#node.master: false -#node.data: false - -# Use the Cluster Health API [http://localhost:9200/_cluster/health], the -# Node Info API [http://localhost:9200/_nodes] or GUI tools -# such as , -# , -# and -# to inspect the cluster state. - -# A node can have generic attributes associated with it, which can later be used -# for customized shard allocation filtering, or allocation awareness. An attribute -# is a simple key value pair, similar to node.key: value, here is an example: -# -#node.rack: rack314 - -# By default, multiple nodes are allowed to start from the same installation location -# to disable it, set the following: -#node.max_local_storage_nodes: 1 - - -#################################### Index #################################### - -# You can set a number of options (such as shard/replica options, mapping -# or analyzer definitions, translog settings, ...) for indices globally, -# in this file. -# -# Note, that it makes more sense to configure index settings specifically for -# a certain index, either when creating it or by using the index templates API. -# -# See and -# -# for more information. - -# Set the number of shards (splits) of an index (5 by default): -# -#index.number_of_shards: 5 - -# Set the number of replicas (additional copies) of an index (1 by default): -# -#index.number_of_replicas: 1 - -# Note, that for development on a local machine, with small indices, it usually -# makes sense to "disable" the distributed features: -# -#index.number_of_shards: 1 -#index.number_of_replicas: 0 - -# These settings directly affect the performance of index and search operations -# in your cluster. Assuming you have enough machines to hold shards and -# replicas, the rule of thumb is: -# -# 1. Having more *shards* enhances the _indexing_ performance and allows to -# _distribute_ a big index across machines. -# 2. Having more *replicas* enhances the _search_ performance and improves the -# cluster _availability_. -# -# The "number_of_shards" is a one-time setting for an index. -# -# The "number_of_replicas" can be increased or decreased anytime, -# by using the Index Update Settings API. -# -# Elasticsearch takes care about load balancing, relocating, gathering the -# results from nodes, etc. Experiment with different settings to fine-tune -# your setup. - -# Use the Index Status API () to inspect -# the index status. - - -#################################### Paths #################################### - -# Path to directory containing configuration (this file and logging.yml): -# -#path.conf: /path/to/conf - -# Path to directory where to store index data allocated for this node. -# -#path.data: /path/to/data -# -# Can optionally include more than one location, causing data to be striped across -# the locations (a la RAID 0) on a file level, favouring locations with most free -# space on creation. For example: -# -#path.data: /path/to/data1,/path/to/data2 - -# Path to temporary files: -# -#path.work: /path/to/work - -# Path to log files: -# -#path.logs: /path/to/logs - -# Path to where plugins are installed: -# -#path.plugins: /path/to/plugins - - -#################################### Plugin ################################### - -# If a plugin listed here is not installed for current node, the node will not start. -# -#plugin.mandatory: mapper-attachments,lang-groovy - - -################################### Memory #################################### - -# Elasticsearch performs poorly when JVM starts swapping: you should ensure that -# it _never_ swaps. -# -# Set this property to true to lock the memory: -# -#bootstrap.mlockall: true - -# Make sure that the ES_MIN_MEM and ES_MAX_MEM environment variables are set -# to the same value, and that the machine has enough memory to allocate -# for Elasticsearch, leaving enough memory for the operating system itself. -# -# You should also make sure that the Elasticsearch process is allowed to lock -# the memory, eg. by using `ulimit -l unlimited`. - - -############################## Network And HTTP ############################### - -# Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens -# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node -# communication. (the range means that if the port is busy, it will automatically -# try the next port). - -# Set the bind address specifically (IPv4 or IPv6): -# -#network.bind_host: 192.168.0.1 - -# Set the address other nodes will use to communicate with this node. If not -# set, it is automatically derived. It must point to an actual IP address. -# -#network.publish_host: 192.168.0.1 - -# Set both 'bind_host' and 'publish_host': -# -#network.host: 192.168.0.1 - -# Set a custom port for the node to node communication (9300 by default): -# -#transport.tcp.port: 9300 - -# Enable compression for all communication between nodes (disabled by default): -# -#transport.tcp.compress: true - -# Set a custom port to listen for HTTP traffic: -# -#http.port: 9200 - -# Set a custom allowed content length: -# -#http.max_content_length: 100mb - -# Disable HTTP completely: -# -#http.enabled: false - - -################################### Gateway ################################### - -# The gateway allows for persisting the cluster state between full cluster -# restarts. Every change to the state (such as adding an index) will be stored -# in the gateway, and when the cluster starts up for the first time, -# it will read its state from the gateway. - -# There are several types of gateway implementations. For more information, see -# . - -# The default gateway type is the "local" gateway (recommended): -# -#gateway.type: local - -# Settings below control how and when to start the initial recovery process on -# a full cluster restart (to reuse as much local data as possible when using shared -# gateway). - -# Allow recovery process after N nodes in a cluster are up: -# -#gateway.recover_after_nodes: 1 - -# Set the timeout to initiate the recovery process, once the N nodes -# from previous setting are up (accepts time value): -# -#gateway.recover_after_time: 5m - -# Set how many nodes are expected in this cluster. Once these N nodes -# are up (and recover_after_nodes is met), begin recovery process immediately -# (without waiting for recover_after_time to expire): -# -#gateway.expected_nodes: 2 - - -############################# Recovery Throttling ############################# - -# These settings allow to control the process of shards allocation between -# nodes during initial recovery, replica allocation, rebalancing, -# or when adding and removing nodes. - -# Set the number of concurrent recoveries happening on a node: -# -# 1. During the initial recovery -# -#cluster.routing.allocation.node_initial_primaries_recoveries: 4 -# -# 2. During adding/removing nodes, rebalancing, etc -# -#cluster.routing.allocation.node_concurrent_recoveries: 2 - -# Set to throttle throughput when recovering (eg. 100mb, by default 20mb): -# -#indices.recovery.max_bytes_per_sec: 20mb - -# Set to limit the number of open concurrent streams when -# recovering a shard from a peer: -# -#indices.recovery.concurrent_streams: 5 - - -################################## Discovery ################################## - -# Discovery infrastructure ensures nodes can be found within a cluster -# and master node is elected. Multicast discovery is the default. - -# Set to ensure a node sees N other master eligible nodes to be considered -# operational within the cluster. This should be set to a quorum/majority of -# the master-eligible nodes in the cluster. -# -#discovery.zen.minimum_master_nodes: 1 - -# Set the time to wait for ping responses from other nodes when discovering. -# Set this option to a higher value on a slow or congested network -# to minimize discovery failures: -# -#discovery.zen.ping.timeout: 3s - -# For more information, see -# - -# Unicast discovery allows to explicitly control which nodes will be used -# to discover the cluster. It can be used when multicast is not present, -# or to restrict the cluster communication-wise. -# -# 1. Disable multicast discovery (enabled by default): -# -#discovery.zen.ping.multicast.enabled: false -# -# 2. Configure an initial list of master nodes in the cluster -# to perform discovery when new nodes (master or data) are started: -# -#discovery.zen.ping.unicast.hosts: ["host1", "host2:port"] - -# EC2 discovery allows to use AWS EC2 API in order to perform discovery. -# -# You have to install the cloud-aws plugin for enabling the EC2 discovery. -# -# For more information, see -# -# -# See -# for a step-by-step tutorial. - -# GCE discovery allows to use Google Compute Engine API in order to perform discovery. -# -# You have to install the cloud-gce plugin for enabling the GCE discovery. -# -# For more information, see . - -# Azure discovery allows to use Azure API in order to perform discovery. -# -# You have to install the cloud-azure plugin for enabling the Azure discovery. -# -# For more information, see . - -################################## Slow Log ################################## - -# Shard level query and fetch threshold logging. - -#index.search.slowlog.threshold.query.warn: 10s -#index.search.slowlog.threshold.query.info: 5s -#index.search.slowlog.threshold.query.debug: 2s -#index.search.slowlog.threshold.query.trace: 500ms - -#index.search.slowlog.threshold.fetch.warn: 1s -#index.search.slowlog.threshold.fetch.info: 800ms -#index.search.slowlog.threshold.fetch.debug: 500ms -#index.search.slowlog.threshold.fetch.trace: 200ms - -#index.indexing.slowlog.threshold.index.warn: 10s -#index.indexing.slowlog.threshold.index.info: 5s -#index.indexing.slowlog.threshold.index.debug: 2s -#index.indexing.slowlog.threshold.index.trace: 500ms - -################################## GC Logging ################################ - -#monitor.jvm.gc.young.warn: 1000ms -#monitor.jvm.gc.young.info: 700ms -#monitor.jvm.gc.young.debug: 400ms - -#monitor.jvm.gc.old.warn: 10s -#monitor.jvm.gc.old.info: 5s -#monitor.jvm.gc.old.debug: 2s - -################################## Security ################################ - -# Uncomment if you want to enable JSONP as a valid return transport on the -# http server. With this enabled, it may pose a security risk, so disabling -# it unless you need it is recommended (it is disabled by default). -# -#http.jsonp.enable: true diff --git a/templates/centos/kibana/kibana.initd.erb b/templates/centos/kibana/kibana.initd.erb deleted file mode 100644 index 800dc84..0000000 --- a/templates/centos/kibana/kibana.initd.erb +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: kibana -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Runs kibana daemon -# Description: Runs the kibana daemon as a non-root user -### END INIT INFO - -# Process name -NAME=kibana -DESC="Kibana4" -PROG="/etc/init.d/kibana" -PID_FOLDER=/var/run/kibana/ -# pid file for daemon -PID_FILE=/var/run/kibana/$NAME.pid -LOCK_FILE=/var/lock/subsys/$NAME -PATH=/bin:/usr/bin:/sbin:/usr/sbin:$KIBANA_BIN - -# Configure the daemon & kibana variables based on Kibana location -KIBANA_BIN=/usr/local/bin/ -KIBANA_LOG=/var/log/kibana.log -# Daemon name -DAEMON="$KIBANA_BIN/kibana -c /etc/kibana.yml" -# User to run as daemon process -DAEMON_USER=kibana - -RETVAL=0 - -if [ `id -u` -ne 0 ]; then - echo "You need root privileges to run this script" - exit 1 -fi - -# Function library -. /etc/init.d/functions - -start() { - echo -n "Starting $DESC : " - - pid=`pidofproc -p $PID_FILE kibana` - if [ -n "$pid" ] ; then - echo "Already running." - exit 0 - else - # Start Daemon - if [ ! -d "$PID_FOLDER" ] ; then - mkdir $PID_FOLDER - fi - daemon --user=$DAEMON_USER --pidfile=$PID_FILE "$DAEMON" 1>"$KIBANA_LOG" 2>&1 & - sleep 2 - pidofproc node > $PID_FILE - RETVAL=$? - [[ $? -eq 0 ]] && success || failure - echo - [ $RETVAL = 0 ] && touch $LOCK_FILE - return $RETVAL - fi -} - -reload() -{ - echo "Reload command is not implemented for this service." - return $RETVAL -} - -stop() { - echo -n "Stopping $DESC : " - killproc -p $PID_FILE $DAEMON - RETVAL=$? - echo - [ $RETVAL = 0 ] && rm -f $PID_FILE $LOCK_FILE -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status -p $PID_FILE $DAEMON - RETVAL=$? - ;; - restart) - stop - start - ;; - reload) - reload - ;; - *) - # Invalid Arguments, print the following message. - echo "Usage: $0 {start|stop|status|restart}" >&2 - exit 2 - ;; -esac \ No newline at end of file diff --git a/templates/centos/logrotate/logstash.erb b/templates/centos/logrotate/logstash.erb deleted file mode 100755 index 69977ae..0000000 --- a/templates/centos/logrotate/logstash.erb +++ /dev/null @@ -1,9 +0,0 @@ -/var/log/logstash/*.log { - daily - rotate 7 - copytruncate - compress - delaycompress - missingok - notifempty -} diff --git a/templates/centos/logstash-forwarder/logstash-forwarder.erb b/templates/centos/logstash-forwarder/logstash-forwarder.erb deleted file mode 100755 index db189be..0000000 --- a/templates/centos/logstash-forwarder/logstash-forwarder.erb +++ /dev/null @@ -1,6 +0,0 @@ -user=<%= @options['user'] %> -group=<%= @options['group'] %> -chroot=<%= @options['chroot'] %> -chdir=<%= @options['chdir'] %> -nice=<%= @options['nice'] %> - diff --git a/templates/centos/logstash-forwarder/logstash-forwarder.initd.erb b/templates/centos/logstash-forwarder/logstash-forwarder.initd.erb deleted file mode 100755 index 406d928..0000000 --- a/templates/centos/logstash-forwarder/logstash-forwarder.initd.erb +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/sh -# Init script for logstash-forwarder -# Maintained by -# Generated by pleaserun. -# Implemented based on LSB Core 3.1: -# * Sections: 20.2, 20.3 -# -### BEGIN INIT INFO -# Provides: logstash-forwarder -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: -# Description: no description given -### END INIT INFO - -PATH=/sbin:/usr/sbin:/bin:/usr/bin -export PATH - -name=logstash-forwarder -program=/opt/logstash-forwarder/bin/logstash-forwarder -args=-config\ /etc/logstash-forwarder.conf -pidfile="/var/run/$name.pid" - -[ -r /etc/default/$name ] && . /etc/default/$name -[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name - -trace() { - logger -t "/etc/init.d/logstash-forwarder" "$@" -} - -emit() { - trace "$@" - echo "$@" -} - -start() { - - - # Setup any environmental stuff beforehand - - - # Run the program! - - chroot --userspec "$user":"$group" "$chroot" sh -c " - - cd \"$chdir\" - exec \"$program\" $args - " >> /var/log/logstash-forwarder/logstash-forwarder.log 2>> /var/log/logstash-forwarder/logstash-forwarder.err & - - # Generate the pidfile from here. If we instead made the forked process - # generate it there will be a race condition between the pidfile writing - # and a process possibly asking for status. - echo $! > $pidfile - - emit "$name started" - return 0 -} - -stop() { - # Try a few times to kill TERM the program - if status ; then - pid=$(cat "$pidfile") - trace "Killing $name (pid $pid) with SIGTERM" - kill -TERM $pid - # Wait for it to exit. - for i in 1 2 3 4 5 ; do - trace "Waiting $name (pid $pid) to die..." - status || break - sleep 1 - done - if status ; then - emit "$name stop failed; still running." - else - emit "$name stopped." - fi - fi -} - -status() { - if [ -f "$pidfile" ] ; then - pid=$(cat "$pidfile") - if ps -p $pid > /dev/null 2> /dev/null ; then - # process by this pid is running. - # It may not be our pid, but that's what you get with just pidfiles. - # TODO(sissel): Check if this process seems to be the same as the one we - # expect. It'd be nice to use flock here, but flock uses fork, not exec, - # so it makes it quite awkward to use in this case. - return 0 - else - return 2 # program is dead but pid file exists - fi - else - return 3 # program is not running - fi -} - -force_stop() { - if status ; then - stop - status && kill -KILL $(cat "$pidfile") - fi -} - - -case "$1" in - force-start|start|stop|force-stop|restart) - trace "Attempting '$1' on logstash-forwarder" - ;; -esac - -case "$1" in - force-start) - PRESTART=no - exec "$0" start - ;; - start) - status - code=$? - if [ $code -eq 0 ]; then - emit "$name is already running" - exit $code - else - start - exit $? - fi - ;; - stop) stop ;; - force-stop) force_stop ;; - status) - status - code=$? - if [ $code -eq 0 ] ; then - emit "$name is running" - else - emit "$name is not running" - fi - exit $code - ;; - restart) - - stop && start - ;; - *) - echo "Usage: $SCRIPTNAME {start|force-start|stop|force-start|force-stop|status|restart}" >&2 - exit 3 - ;; -esac - -exit $? diff --git a/templates/centos/logstash/conf.d/00-input.conf.erb b/templates/centos/logstash/conf.d/00-input.conf.erb deleted file mode 100755 index d0d6962..0000000 --- a/templates/centos/logstash/conf.d/00-input.conf.erb +++ /dev/null @@ -1,8 +0,0 @@ -input { - lumberjack { - port => "<%= @options['port'] %>" - type => "logs" - ssl_certificate => "<%= @options['crt_location'] %>" - ssl_key => "<%= @options['key_location'] %>" - } -} diff --git a/templates/centos/logstash/conf.d/99-output.conf.erb b/templates/centos/logstash/conf.d/99-output.conf.erb deleted file mode 100755 index 58c3ef4..0000000 --- a/templates/centos/logstash/conf.d/99-output.conf.erb +++ /dev/null @@ -1,4 +0,0 @@ -output { - elasticsearch { host => localhost } - stdout { codec => rubydebug } -} diff --git a/templates/centos/logstash/logstash.initd.erb b/templates/centos/logstash/logstash.initd.erb deleted file mode 100755 index 93209c3..0000000 --- a/templates/centos/logstash/logstash.initd.erb +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/sh -# Init script for logstash -# Maintained by Elasticsearch -# Generated by pleaserun. -# Implemented based on LSB Core 3.1: -# * Sections: 20.2, 20.3 -# -### BEGIN INIT INFO -# Provides: logstash -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: -# Description: Starts Logstash as a daemon. -### END INIT INFO - -PATH=/sbin:/usr/sbin:/bin:/usr/bin -export PATH - -if [ `id -u` -ne 0 ]; then - echo "You need root privileges to run this script" - exit 1 -fi - -name=logstash -pidfile="/var/run/$name.pid" - -LS_USER=<%= @options['ls_user'] %> -LS_GROUP=<%= @options['ls_group'] %> -LS_HOME=/var/lib/<%= @options['ls_home'] %> -LS_HEAP_SIZE=<%= @options['ls_heap_size'] %> -LS_LOG_DIR=<%= @options['ls_log_dir'] %> -LS_LOG_FILE=<%= @options['ls_log_file'] %> -LS_CONF_DIR=<%= @options['ls_conf_dir'] %> -LS_OPEN_FILES=<%= @options['ls_open_files'] %> -LS_NICE=<%= @options['ls_nice'] %> -LS_OPTS=<%= @options['ls_opts'] %> - - -[ -r /etc/default/$name ] && . /etc/default/$name -[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name - -program=/opt/logstash/bin/logstash -args="agent -f ${LS_CONF_DIR} -l ${LS_LOG_FILE} ${LS_OPTS}" - -start() { - - LS_JAVA_OPTS="${LS_JAVA_OPTS} -Djava.io.tmpdir=${LS_HOME}" - HOME=${LS_HOME} - export PATH HOME LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING - - # set ulimit as (root, presumably) first, before we drop privileges - ulimit -n ${LS_OPEN_FILES} - - # Run the program! - nice -n ${LS_NICE} chroot --userspec $LS_USER:$LS_GROUP / sh -c " - cd $LS_HOME - ulimit -n ${LS_OPEN_FILES} - exec \"$program\" $args - " > "${LS_LOG_DIR}/$name.stdout" 2> "${LS_LOG_DIR}/$name.err" & - - # Generate the pidfile from here. If we instead made the forked process - # generate it there will be a race condition between the pidfile writing - # and a process possibly asking for status. - echo $! > $pidfile - - echo "$name started." - return 0 -} - -stop() { - # Try a few times to kill TERM the program - if status ; then - pid=`cat "$pidfile"` - echo "Killing $name (pid $pid) with SIGTERM" - kill -TERM $pid - # Wait for it to exit. - for i in 1 2 3 4 5 ; do - echo "Waiting $name (pid $pid) to die..." - status || break - sleep 1 - done - if status ; then - echo "$name stop failed; still running." - else - echo "$name stopped." - fi - fi -} - -status() { - if [ -f "$pidfile" ] ; then - pid=`cat "$pidfile"` - if kill -0 $pid > /dev/null 2> /dev/null ; then - # process by this pid is running. - # It may not be our pid, but that's what you get with just pidfiles. - # TODO(sissel): Check if this process seems to be the same as the one we - # expect. It'd be nice to use flock here, but flock uses fork, not exec, - # so it makes it quite awkward to use in this case. - return 0 - else - return 2 # program is dead but pid file exists - fi - else - return 3 # program is not running - fi -} - -force_stop() { - if status ; then - stop - status && kill -KILL `cat "$pidfile"` - fi -} - - -case "$1" in - start) - status - code=$? - if [ $code -eq 0 ]; then - echo "$name is already running" - else - start - code=$? - fi - exit $code - ;; - stop) stop ;; - force-stop) force_stop ;; - status) - status - code=$? - if [ $code -eq 0 ] ; then - echo "$name is running" - else - echo "$name is not running" - fi - exit $code - ;; - restart) - - stop && start - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|force-stop|status|restart}" >&2 - exit 3 - ;; -esac - -exit $? diff --git a/templates/centos/sv-kibana-run.erb b/templates/centos/sv-kibana-run.erb deleted file mode 100644 index 7436962..0000000 --- a/templates/centos/sv-kibana-run.erb +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -cd /home/kibana -exec 2>&1 - -exec /usr/bin/env kibana -c /etc/kibana.yml diff --git a/templates/centos/kibana/kibana.yml.erb b/templates/default/kibana/kibana.yml.erb similarity index 100% rename from templates/centos/kibana/kibana.yml.erb rename to templates/default/kibana/kibana.yml.erb diff --git a/templates/centos/logstash-forwarder/logstash-forwarder.conf.erb b/templates/default/logstash-forwarder/logstash-forwarder.conf.erb similarity index 100% rename from templates/centos/logstash-forwarder/logstash-forwarder.conf.erb rename to templates/default/logstash-forwarder/logstash-forwarder.conf.erb diff --git a/templates/centos/logstash/logging.yml.erb b/templates/default/logstash/logging.yml.erb similarity index 100% rename from templates/centos/logstash/logging.yml.erb rename to templates/default/logstash/logging.yml.erb diff --git a/templates/centos/logstash/conf.d/10-syslog.conf.erb b/templates/default/logstash/logstash.conf.erb old mode 100755 new mode 100644 similarity index 59% rename from templates/centos/logstash/conf.d/10-syslog.conf.erb rename to templates/default/logstash/logstash.conf.erb index 3344a78..ee381ce --- a/templates/centos/logstash/conf.d/10-syslog.conf.erb +++ b/templates/default/logstash/logstash.conf.erb @@ -1,3 +1,12 @@ +input { + lumberjack { + port => "<%= @options['port'] %>" + type => "logs" + ssl_certificate => "<%= @options['crt_location'] %>" + ssl_key => "<%= @options['key_location'] %>" + } +} + filter { if [type] == "syslog" { grok { @@ -10,4 +19,9 @@ filter { match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ] } } -} \ No newline at end of file +} + +output { + elasticsearch { host => localhost } + stdout { codec => rubydebug } +} diff --git a/templates/centos/logstash/logstash.sysconfig.erb b/templates/default/logstash/logstash.sysconfig.erb similarity index 100% rename from templates/centos/logstash/logstash.sysconfig.erb rename to templates/default/logstash/logstash.sysconfig.erb diff --git a/templates/default/sv-elasticsearch-run.erb b/templates/default/sv-elasticsearch-run.erb new file mode 100644 index 0000000..5c77a09 --- /dev/null +++ b/templates/default/sv-elasticsearch-run.erb @@ -0,0 +1,7 @@ +#!/bin/sh + +cd <%= @options['home_dir'] %> +exec 2>&1 + +chpst -u :<%= @options['user'] %>:<%= @options['group'] %> +exec ./bin/elasticsearch diff --git a/templates/default/sv-kibana-run.erb b/templates/default/sv-kibana-run.erb new file mode 100644 index 0000000..e95885a --- /dev/null +++ b/templates/default/sv-kibana-run.erb @@ -0,0 +1,7 @@ +#!/bin/sh + +cd <%= @options['home_dir'] %> +exec 2>&1 + +chpst -u :<%= @options['user'] %>:<%= @options['group'] %> +exec ./bin/kibana -c <%= @options['config_file'] %> diff --git a/templates/default/sv-logstash-forwarder-run.erb b/templates/default/sv-logstash-forwarder-run.erb new file mode 100644 index 0000000..9d8e6ef --- /dev/null +++ b/templates/default/sv-logstash-forwarder-run.erb @@ -0,0 +1,7 @@ +#!/bin/sh + +cd <%= @options['home_dir'] %> +exec 2>&1 + +chpst -u :<%= @options['user'] %>:<%= @options['group'] %> +exec ./logstash-forwarder -config <%= @options['config_file'] %> diff --git a/templates/default/sv-logstash-run.erb b/templates/default/sv-logstash-run.erb new file mode 100644 index 0000000..fb42860 --- /dev/null +++ b/templates/default/sv-logstash-run.erb @@ -0,0 +1,7 @@ +#!/bin/sh + +cd <%= @options['home_dir'] %> +exec 2>&1 + +chpst -u :<%= @options['user'] %>:<%= @options['group'] %> +exec ./bin/logstash -f <%= @options['config_file'] %> diff --git a/test/cookbooks/elktest/metadata.rb b/test/cookbooks/elktest/metadata.rb index c91096d..5d81c09 100644 --- a/test/cookbooks/elktest/metadata.rb +++ b/test/cookbooks/elktest/metadata.rb @@ -7,4 +7,4 @@ version '0.1.0' depends 'elk' -depends 'runit' \ No newline at end of file +depends 'runit' diff --git a/test/cookbooks/elktest/recipes/default.rb b/test/cookbooks/elktest/recipes/default.rb index a22f48c..a5540cc 100644 --- a/test/cookbooks/elktest/recipes/default.rb +++ b/test/cookbooks/elktest/recipes/default.rb @@ -1,13 +1,31 @@ +# test a single node with all four projects +%w( tar nano htop java-1.8.0-openjdk-headless).each do |pkg| + package pkg +end -# test a single node with all three projects +include_recipe 'runit::default' -package 'htop' -package 'java-1.8.0-openjdk-headless' -package 'nginx' +# create certs (subject = localhost) +secrets = Chef::DataBagItem.load('secrets', 'logstash') +logstash_key = Base64.decode64(secrets['key']) +file '/tmp/logstash.key' do + content logstash_key +end +logstash_crt = Base64.decode64(secrets['certificate']) +file '/tmp/logstash.crt' do + content logstash_crt +end -include_recipe 'runit::default' +elasticsearch 'default' + +logstash 'default' do + crt_location '/tmp/logstash.crt' + key_location '/tmp/logstash.key' +end + +logstash_forwarder 'default' do + crt_location '/tmp/logstash.crt' + key_location '/tmp/logstash.key' +end -include_recipe 'elktest::elasticsearch' -include_recipe 'elktest::logstash' -include_recipe 'elktest::logstash_forwarder' -include_recipe 'elktest::kibana' +kibana 'default' diff --git a/test/cookbooks/elktest/recipes/elasticsearch.rb b/test/cookbooks/elktest/recipes/elasticsearch.rb deleted file mode 100755 index b29f552..0000000 --- a/test/cookbooks/elktest/recipes/elasticsearch.rb +++ /dev/null @@ -1,8 +0,0 @@ -elasticsearch_service 'default' do - action [:create, :start, :enable] -end - -elasticsearch_config 'default' do - action :create - notifies :restart, 'elasticsearch_service[default]' -end diff --git a/test/cookbooks/elktest/recipes/kibana.rb b/test/cookbooks/elktest/recipes/kibana.rb deleted file mode 100644 index 6d37c11..0000000 --- a/test/cookbooks/elktest/recipes/kibana.rb +++ /dev/null @@ -1,9 +0,0 @@ -kibana_service 'default' do - action [:create] -end - -kibana_config 'default' do - port 8080 - action :create - notifies :restart, 'kibana_service[default]' -end diff --git a/test/cookbooks/elktest/recipes/logstash.rb b/test/cookbooks/elktest/recipes/logstash.rb deleted file mode 100755 index 5d5c04a..0000000 --- a/test/cookbooks/elktest/recipes/logstash.rb +++ /dev/null @@ -1,21 +0,0 @@ -logstash_service 'default' do - action [:create, :start, :enable] -end - -secrets = Chef::DataBagItem.load('secrets', 'logstash') -logstash_key = Base64.decode64(secrets['key']) -logstash_crt = Base64.decode64(secrets['certificate']) - -file '/opt/logstash/logstash.key' do - content logstash_key -end -file '/opt/logstash/logstash.crt' do - content logstash_crt -end - -logstash_config 'default' do - action :create - key logstash_key - crt logstash_crt - notifies :restart, 'logstash_service[default]' -end diff --git a/test/cookbooks/elktest/recipes/logstash_forwarder.rb b/test/cookbooks/elktest/recipes/logstash_forwarder.rb deleted file mode 100755 index f394917..0000000 --- a/test/cookbooks/elktest/recipes/logstash_forwarder.rb +++ /dev/null @@ -1,21 +0,0 @@ -logstash_forwarder_service 'default' do - action [:create, :start] -end - -secrets = Chef::DataBagItem.load('secrets', 'logstash') -logstash_key = Base64.decode64(secrets['key']) -logstash_crt = Base64.decode64(secrets['certificate']) - -file '/opt/logstash-forwarder/logstash.key' do - content logstash_key -end -file '/opt/logstash-forwarder/logstash.crt' do - content logstash_crt -end - -logstash_forwarder_config 'default' do - action :create - key logstash_key - crt logstash_crt - notifies :restart, 'logstash_forwarder_service[default]' -end diff --git a/test/integration/helpers/serverspec/elasticsearch.rb b/test/integration/helpers/serverspec/elasticsearch.rb old mode 100755 new mode 100644 index e6a2845..6f8af97 --- a/test/integration/helpers/serverspec/elasticsearch.rb +++ b/test/integration/helpers/serverspec/elasticsearch.rb @@ -1,12 +1,10 @@ # sshd_service = os[:family] == 'redhat' ? 'sshd' : 'ssh' shared_examples 'elasticsearch' do - describe service('elasticsearch') do - it 'is enabled and running' do - expect(subject).to be_enabled - expect(subject).to be_running - end + describe command('sv status elasticsearch') do + its(:stdout) { should match 'run: elasticsearch' } end end # curl -X GET http://localhost:9200/ +# curl 'localhost:9200/_cat/health?v' diff --git a/test/integration/helpers/serverspec/kibana.rb b/test/integration/helpers/serverspec/kibana.rb old mode 100755 new mode 100644 index 5e8d28a..27f0f55 --- a/test/integration/helpers/serverspec/kibana.rb +++ b/test/integration/helpers/serverspec/kibana.rb @@ -1,10 +1,7 @@ # sshd_service = os[:family] == 'redhat' ? 'sshd' : 'ssh' shared_examples 'kibana' do - describe service('kibana') do - it 'is enabled and running' do - expect(subject).to be_enabled - expect(subject).to be_running - end + describe command('sv status kibana') do + its(:stdout) { should match 'run: kibana' } end end diff --git a/test/integration/helpers/serverspec/logstash.rb b/test/integration/helpers/serverspec/logstash.rb old mode 100755 new mode 100644 index 25f2591..5a84fff --- a/test/integration/helpers/serverspec/logstash.rb +++ b/test/integration/helpers/serverspec/logstash.rb @@ -1,10 +1,7 @@ # sshd_service = os[:family] == 'redhat' ? 'sshd' : 'ssh' shared_examples 'logstash' do - describe service('logstash') do - it 'is enabled and running' do - expect(subject).to be_enabled - expect(subject).to be_running - end + describe command('sv status logstash') do + its(:stdout) { should match 'run: logstash' } end end diff --git a/test/integration/helpers/serverspec/logstash_forwarder.rb b/test/integration/helpers/serverspec/logstash_forwarder.rb old mode 100755 new mode 100644 index 40e6e93..849001c --- a/test/integration/helpers/serverspec/logstash_forwarder.rb +++ b/test/integration/helpers/serverspec/logstash_forwarder.rb @@ -1,10 +1,7 @@ # sshd_service = os[:family] == 'redhat' ? 'sshd' : 'ssh' shared_examples 'logstash_forwarder' do - describe service('logstash-forwarder') do - it 'is enabled and running' do - expect(subject).to be_enabled - expect(subject).to be_running - end + describe command('sv status logstash-forwarder') do + its(:stdout) { should match 'run: logstash-forwarder' } end end