forked from sous-chefs/nagios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_source.rb
131 lines (114 loc) · 3.46 KB
/
server_source.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#
# Author:: Seth Chisamore <[email protected]>
# Cookbook Name:: nagios
# Recipe:: server_source
#
# Copyright 2011, Opscode, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Package pre-reqs
include_recipe "build-essential"
include_recipe "nagios::client"
include_recipe "php"
include_recipe "php::module_gd"
web_srv = node['nagios']['server']['web_server'].to_sym
case web_srv
when :apache
include_recipe "nagios::apache"
else
include_recipe "nagios::nginx"
end
pkgs = value_for_platform(
["redhat","centos","fedora","scientific","amazon"] =>
{"default" => %w{ openssl-devel gd-devel }},
[ "debian", "ubuntu" ] =>
{"default" => %w{ libssl-dev libgd2-xpm-dev bsd-mailx}},
"default" => %w{ libssl-dev libgd2-xpm-dev bsd-mailx }
)
pkgs.each do |pkg|
package pkg do
action :install
end
end
group node['nagios']['group'] do
members [
node['nagios']['user'],
web_srv == :nginx ? node['nginx']['user'] : node['apache']['user']
]
action :modify
end
version = node['nagios']['server']['version']
remote_file "#{Chef::Config[:file_cache_path]}/nagios-#{version}.tar.gz" do
source "http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-#{version}.tar.gz"
checksum node['nagios']['server']['checksum']
action :create_if_missing
end
bash "compile-nagios" do
cwd Chef::Config[:file_cache_path]
code <<-EOH
tar zxvf nagios-#{version}.tar.gz
cd nagios
./configure --prefix=/usr \
--mandir=/usr/share/man \
--bindir=/usr/sbin \
--sbindir=/usr/lib/cgi-bin/nagios3 \
--datadir=#{node['nagios']['docroot']} \
--sysconfdir=#{node['nagios']['conf_dir']} \
--infodir=/usr/share/info \
--libexecdir=#{node['nagios']['plugin_dir']} \
--localstatedir=#{node['nagios']['state_dir']} \
--enable-event-broker \
--with-nagios-user=#{node['nagios']['user']} \
--with-nagios-group=#{node['nagios']['group']} \
--with-command-user=#{node['nagios']['user']} \
--with-command-group=#{node['nagios']['group']} \
--with-init-dir=/etc/init.d \
--with-lockfile=#{node['nagios']['run_dir']}/nagios3.pid \
--with-mail=/usr/bin/mail \
--with-perlcache \
--with-htmurl=/nagios3 \
--with-cgiurl=/cgi-bin/nagios3
make all
make install
make install-init
make install-config
make install-commandmode
EOH
creates "/usr/sbin/nagios"
end
directory "#{node['nagios']['conf_dir']}/conf.d" do
owner "root"
group "root"
mode 00755
end
%w{ cache_dir log_dir run_dir }.each do |dir|
directory node['nagios'][dir] do
owner node['nagios']['user']
group node['nagios']['group']
mode 00755
end
end
directory "/usr/lib/nagios3" do
owner node['nagios']['user']
group node['nagios']['group']
mode 00755
end
link "#{node['nagios']['conf_dir']}/stylesheets" do
to "#{node['nagios']['docroot']}/stylesheets"
end
if web_srv == :apache
apache_module "cgi" do
enable :true
end
end