Chefのレシピにしておくと便利かなと。
環境
CentOS 6.5
elasticsearch
recipes/elasticsearch.rb
## java install
package "java-1.7.0-openjdk" do
action :install
end
## install
bash "elasticsearch" do
not_if "ls /usr/local/share/elasticsearch-1.2.1"
user "root"
cwd "/usr/local/src"
code <<-EOH
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.tar.gz
tar xvzf elasticsearch-1.2.1.tar.gz -C /usr/local/share/
EOH
end
## add service
bash "elasticsearch_as_service" do
not_if "ls usr/local/share/elasticsearch-1.2.1/bin/service"
user "root"
cwd "/usr/local/src"
code <<-EOH
wget https://github.com/elasticsearch/elasticsearch-servicewrapper/archive/master.zip
unzip /usr/local/src/master
mv /usr/local/src/elasticsearch-servicewrapper-master/service/ /usr/local/share/elasticsearch-1.2.1/bin/
/usr/local/share/elasticsearch-1.2.1/bin/service/elasticsearch install
EOH
end
## elasticsearch log dir
directory '/usr/local/share/elasticsearch-1.2.1/logs/' do
owner 'root'
group 'root'
mode '0755'
action :create
end
## elasticsearch.yml
template "/usr/local/share/elasticsearch-1.2.1/config/elasticsearch.yml" do
source "elasticsearch.yml.erb"
owner "root"
group "root"
mode 755
end
## service start
service "elasticsearch" do
action [ :enable, :start ]
subscribes :restart, resources(:template => "/usr/local/share/elasticsearch-1.2.1/config/elasticsearch.yml")
end
## chkconfig
execute "add_elasticsearch_service" do
user "root"
command "chkconfig elasticsearch on"
action :run
end
- template/default
このディレクトリに以下のファイルをおいておくこと。
elasticsearch.yml.erb
あれ?って思ったこと
- logディレクトリがなくて、起動に失敗したので、ディレクトリ作成を追加した
- javaがなかったのでインストールしました。。
kibana
recipes/kibana.rb
## directory
directory '/var/www/html/kibana' do
owner 'root'
group 'root'
mode '0755'
action :create
end
## kibana install
bash "kibana" do
not_if "ls /var/www/html/kibana"
user "root"
cwd "/usr/local/src"
code <<-EOH
wget https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
tar xvzf kibana-3.1.0.tar.gz -C /var/www/html
mv /var/www/html/kibana-3.1.0 /var/www/html/kibana
EOH
end
## kibana config setting
template "/var/www/html/kibana/config.js" do
source "config.js.erb"
owner "root"
group "root"
mode 755
end
apacheのインストールは別レシピにして使い回し
recipes/apache.rb
package "httpd" do
version "2.2.15-30.el6.centos"
action :install
end
service "httpd" do
supports :status =>true, :restart=>true, :reload=>true
action [:enable, :start]
end
execute "add_httpd_service" do
user "root"
command "chkconfig httpd on"
action :run
end
- template/default
このディレクトリに以下のファイルをおいておくこと。
config.js.erb