cookbook-zabbix/recipes/server.rb

110 lines
2.4 KiB
Ruby
Raw Permalink Normal View History

2017-02-07 01:02:03 -05:00
#
# Cookbook Name:: zabbix
# Recipe:: server
#
# Copyright 2017, Linux-Help.org
# Authors:
# Eric Renfro <psi-jack@linux-help.org>
#
%w{httpd mod_ssl}.each do |pkg|
yum_package pkg do
version '2.2.15-39.el6'
allow_downgrade true
action :install
end
end
%w{php56u php56u-bcmath php56u-gd php56u-mbstring php56u-pgsql php56u-xml php56u-xmlrpc php56u-cli php56u-opcache}.each do |pkg|
yum_package pkg do
version '5.6.28-1.ius.centos6'
allow_downgrade true
action :install
end
end
%w{zabbix-server-pgsql zabbix-web-pgsql zabbix-get}.each do |pkg|
yum_package pkg do
version '3.0.5-1.el6'
allow_downgrade true
action :install
end
end
template "/etc/httpd/conf/httpd.conf" do
source "httpd.conf.erb"
mode "0644"
owner "root"
group "root"
notifies :restart, "service[httpd]", :delayed
end
template "/etc/httpd/conf.d/zabbix.conf" do
source "zabbix_httpd.conf.erb"
mode "0644"
owner "root"
group "root"
notifies :restart, "service[httpd]", :delayed
end
template "/etc/httpd/conf.d/security.conf" do
source "security.conf.erb"
mode "0644"
owner "root"
group "root"
notifies :restart, "service[httpd]", :delayed
end
template "/etc/httpd/conf.d/ssl.conf" do
source "ssl.conf.erb"
mode "0644"
owner "root"
group "root"
notifies :restart, "service[httpd]", :delayed
end
template "/etc/zabbix/zabbix_server.conf" do
credentials = Chef::EncryptedDataBagItem.load("odhp_credentials", "credentials")
variables({
:DBPassword => credentials['zabbix']['postgres_password']
})
source "zabbix_server.conf.erb"
sensitive true
mode "0640"
owner "root"
group "root"
notifies :restart, "service[zabbix-server]", :immediately
end
template "/etc/zabbix/web/zabbix.conf.php" do
credentials = Chef::EncryptedDataBagItem.load("odhp_credentials", "credentials")
variables({
:DBPassword => credentials['zabbix']['postgres_password']
})
source "zabbix_web.conf.erb"
sensitive true
mode "0640"
owner "root"
group "apache"
end
template "/etc/php.ini" do
source "php.ini.erb"
mode "0644"
owner "root"
group "root"
notifies :restart, "service[httpd]", :immediately
end
service 'httpd' do
supports :restart => true, :start => true
action :enable
end
service 'zabbix-server' do
supports :restart => true, :start => true
action :enable
end
include_recipe 'zabbix::agent'