mirror of
https://github.com/kemko/bw.git
synced 2026-01-01 07:35:43 +03:00
start point
This commit is contained in:
11
.chef/encrypted_data_bag_secret
Normal file
11
.chef/encrypted_data_bag_secret
Normal file
@@ -0,0 +1,11 @@
|
||||
CmwCmc4LhWxu2lTy1jFkfy8Z3OElekkgTDZgHKM+ut/5pZ7lLhOOunYC9Pr/BH+O
|
||||
Utrp7O+jW2Is9A6zDc+7oF6MzMcpVmvh5XRXfde7HA+8VbdqqbquOMu/m8/vj9V/
|
||||
h5VVTW+9xYiydCh0kUfidUZSVf50dEA+gKSKrKC4SR2PaLIZIXM18W0xsH8EaKjs
|
||||
qG1fK2wi04zA+XzdlvD1u11eMpy6xcyQmj8+kko8g9vNk0bP5qgfO/QcTIjA/Icd
|
||||
5DsUKbeD4Ts4VjhVhepQzD9xA3xg6pRv7qxDC1PYYDl3tNZ/hxsolNTH7piANfQg
|
||||
01AXKqBfOaWJ75Rg/BvmAiH3CvLKb1x5wINyLuIaiZAY/oF5PzlzidVv9liJChLm
|
||||
GrM7ihXlKMn2S0+z8Y++4e0swznZkBlJHhF35jNIt/QZT5wrok7jJyk1XeuhIOpY
|
||||
RgY9bxrBhEq1PPF4AwRN7my7U7K4u2iN7w306pBRBwlB3oU9g73UD3WxXkjX8LsS
|
||||
01x8HrA6oORrqkBgRhnP9uGULy22sWsb6nszYugSAnvRtgPEKCt2B0B/wndIvowk
|
||||
rVfUm4Gu7WWdcEGVMqjEaBKQIoauOs3iJ4TujaahE4Ffs9/BOqc6pwIPGArGPr0u
|
||||
NymyUQBdLh7j8w51E0LVW/J5K4MlJ6WnBU0BOO629nc=
|
||||
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
.vagrant
|
||||
*~
|
||||
*#
|
||||
.#*
|
||||
\#*#
|
||||
.*.sw[a-z]
|
||||
*.un~
|
||||
/cookbooks
|
||||
tmp/
|
||||
54
Cheffile
Normal file
54
Cheffile
Normal file
@@ -0,0 +1,54 @@
|
||||
site 'http://community.opscode.com/api/v1'
|
||||
|
||||
cookbook 'base', :path => 'inhouse-cookbooks/base'
|
||||
|
||||
cookbook 'fake', :path => 'inhouse-cookbooks/fake'
|
||||
|
||||
cookbook "timezone",
|
||||
:git => "git@github.com:express42-cookbooks/timezone.git"
|
||||
|
||||
cookbook "sysctl",
|
||||
:git => "git@github.com:express42-cookbooks/sysctl.git"
|
||||
|
||||
cookbook "apt",
|
||||
:git => "git@github.com:opscode-cookbooks/apt.git"
|
||||
|
||||
cookbook "ntp",
|
||||
:git => "https://github.com/opscode-cookbooks/ntp.git"
|
||||
|
||||
cookbook "user",
|
||||
:git => "https://github.com/fnichol/chef-user.git"
|
||||
|
||||
cookbook "sudo",
|
||||
:git => "git@github.com:express42-cookbooks/sudo.git"
|
||||
|
||||
cookbook "lvm",
|
||||
:git => "https://github.com/opscode-cookbooks/lvm.git"
|
||||
|
||||
cookbook "zabbix",
|
||||
:git => "git@github.com:express42-cookbooks/zabbix.git"
|
||||
|
||||
cookbook "zabbix-server",
|
||||
:git => "git@github.com:express42-cookbooks/zabbix-server.git"
|
||||
|
||||
cookbook "partition",
|
||||
:git => "git@github.com:express42-cookbooks/partition.git"
|
||||
|
||||
cookbook "postgresql",
|
||||
:git => "git@github.com:express42-cookbooks/postgresql.git"
|
||||
|
||||
cookbook "php",
|
||||
:git => "git@github.com:express42-cookbooks/php.git"
|
||||
|
||||
cookbook "nginx",
|
||||
:git => "git@github.com:evilmartians/chef-nginx.git"
|
||||
|
||||
cookbook "ruby",
|
||||
:git => "git@github.com:express42-cookbooks/ruby.git"
|
||||
|
||||
cookbook "redmine",
|
||||
:git => "git@github.com:express42-cookbooks/redmine.git"
|
||||
|
||||
cookbook "runit",
|
||||
:git => "git@github.com:express42-cookbooks/runit.git"
|
||||
|
||||
147
Cheffile.lock
Normal file
147
Cheffile.lock
Normal file
@@ -0,0 +1,147 @@
|
||||
GIT
|
||||
remote: git@github.com:evilmartians/chef-nginx.git
|
||||
ref: master
|
||||
sha: d0084e014b469a79ad7ab90635e20a06cbcafbe3
|
||||
specs:
|
||||
nginx (2.2.0)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/partition.git
|
||||
ref: master
|
||||
sha: 2fa3aa3b1c9badaebcaeb63f05db37b138dec369
|
||||
specs:
|
||||
partition (0.2.0)
|
||||
lvm (>= 0.8.6)
|
||||
zabbix (>= 0.1.1)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/php.git
|
||||
ref: master
|
||||
sha: 4764b5b668462208740f7eda1f4ddc5182d0ea1f
|
||||
specs:
|
||||
php (0.1.0)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/postgresql.git
|
||||
ref: master
|
||||
sha: ccf15076a95dc50059ff9cbc06cb6028d217341c
|
||||
specs:
|
||||
postgresql (0.2.3)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/redmine.git
|
||||
ref: master
|
||||
sha: d050e49e9de3f6c4d3f945fd858d3a5c8c079c7f
|
||||
specs:
|
||||
redmine (2.0.0)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/ruby.git
|
||||
ref: master
|
||||
sha: 4cfa866373fb90dcb8ad4484d7eabceb5e56c5d5
|
||||
specs:
|
||||
ruby (0.1.2)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/runit.git
|
||||
ref: master
|
||||
sha: d2e2f0bb1cd131db0d36f0baf4429585e0c360e4
|
||||
specs:
|
||||
runit (0.14.3)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/sudo.git
|
||||
ref: master
|
||||
sha: e76baf470e25dac18014b423aa712b854c87d94c
|
||||
specs:
|
||||
sudo (1.1.1)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/sysctl.git
|
||||
ref: master
|
||||
sha: ceca1b382f1cc434d3ba43502c301bfbe7c9ffbb
|
||||
specs:
|
||||
sysctl (0.2.2)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/timezone.git
|
||||
ref: master
|
||||
sha: cd8e67dd1076264b0d2ea0864432b74eaefffc8a
|
||||
specs:
|
||||
timezone (0.1.0)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/zabbix-server.git
|
||||
ref: master
|
||||
sha: 8ee553759285af2bdb1ae3ce4261de8a0ee3f31b
|
||||
specs:
|
||||
zabbix-server (0.1.0)
|
||||
lvm (>= 0.8.6)
|
||||
nginx (>= 2.2.0)
|
||||
partition (>= 0.1.0)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:express42-cookbooks/zabbix.git
|
||||
ref: master
|
||||
sha: ef96256ef9848f0332a9249e89f46e006ae58b60
|
||||
specs:
|
||||
zabbix (0.2.0)
|
||||
|
||||
GIT
|
||||
remote: git@github.com:opscode-cookbooks/apt.git
|
||||
ref: master
|
||||
sha: b58c75536300794e5b5ffa8747fc9e6c48a4e5ce
|
||||
specs:
|
||||
apt (2.1.1)
|
||||
|
||||
GIT
|
||||
remote: https://github.com/fnichol/chef-user.git
|
||||
ref: master
|
||||
sha: ce45d05e13491a82cbb5a2c36292391f3a1aaa36
|
||||
specs:
|
||||
user (0.3.1)
|
||||
|
||||
GIT
|
||||
remote: https://github.com/opscode-cookbooks/lvm.git
|
||||
ref: master
|
||||
sha: 5f76a85d4bf5ea56b37bf85e8326a8d7386f7054
|
||||
specs:
|
||||
lvm (0.8.13)
|
||||
|
||||
GIT
|
||||
remote: https://github.com/opscode-cookbooks/ntp.git
|
||||
ref: master
|
||||
sha: 6e47826c939add35cec2a5b528cd187c7eb3f3b6
|
||||
specs:
|
||||
ntp (1.4.1)
|
||||
|
||||
PATH
|
||||
remote: inhouse-cookbooks/base
|
||||
specs:
|
||||
base (0.1.0)
|
||||
|
||||
PATH
|
||||
remote: inhouse-cookbooks/fake
|
||||
specs:
|
||||
fake (0.1.0)
|
||||
|
||||
DEPENDENCIES
|
||||
apt (>= 0)
|
||||
base (>= 0)
|
||||
fake (>= 0)
|
||||
lvm (>= 0)
|
||||
nginx (>= 0)
|
||||
ntp (>= 0)
|
||||
partition (>= 0)
|
||||
php (>= 0)
|
||||
postgresql (>= 0)
|
||||
redmine (>= 0)
|
||||
ruby (>= 0)
|
||||
runit (>= 0)
|
||||
sudo (>= 0)
|
||||
sysctl (>= 0)
|
||||
timezone (>= 0)
|
||||
user (>= 0)
|
||||
zabbix (>= 0)
|
||||
zabbix-server (>= 0)
|
||||
|
||||
61
Gemfile.lock
Normal file
61
Gemfile.lock
Normal file
@@ -0,0 +1,61 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
archive-tar-minitar (0.5.2)
|
||||
chef (11.6.0)
|
||||
erubis
|
||||
highline (>= 1.6.9)
|
||||
json (>= 1.4.4, <= 1.7.7)
|
||||
mixlib-authentication (>= 1.3.0)
|
||||
mixlib-cli (~> 1.3.0)
|
||||
mixlib-config (>= 1.1.2)
|
||||
mixlib-log (>= 1.3.0)
|
||||
mixlib-shellout
|
||||
net-ssh (~> 2.6)
|
||||
net-ssh-multi (~> 1.1.0)
|
||||
ohai (>= 0.6.0)
|
||||
rest-client (>= 1.0.4, < 1.7.0)
|
||||
yajl-ruby (~> 1.1)
|
||||
erubis (2.7.0)
|
||||
highline (1.6.19)
|
||||
ipaddress (0.8.0)
|
||||
json (1.7.7)
|
||||
librarian (0.1.0)
|
||||
highline
|
||||
thor (~> 0.15)
|
||||
librarian-chef (0.0.1)
|
||||
archive-tar-minitar (>= 0.5.2)
|
||||
chef (>= 0.10)
|
||||
librarian (~> 0.1.0)
|
||||
mime-types (1.25)
|
||||
mixlib-authentication (1.3.0)
|
||||
mixlib-log
|
||||
mixlib-cli (1.3.0)
|
||||
mixlib-config (1.1.2)
|
||||
mixlib-log (1.6.0)
|
||||
mixlib-shellout (1.2.0)
|
||||
net-ssh (2.6.8)
|
||||
net-ssh-gateway (1.2.0)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh-multi (1.1)
|
||||
net-ssh (>= 2.1.4)
|
||||
net-ssh-gateway (>= 0.99.0)
|
||||
ohai (6.18.0)
|
||||
ipaddress
|
||||
mixlib-cli
|
||||
mixlib-config
|
||||
mixlib-log
|
||||
mixlib-shellout
|
||||
systemu
|
||||
yajl-ruby
|
||||
rest-client (1.6.7)
|
||||
mime-types (>= 1.16)
|
||||
systemu (2.5.2)
|
||||
thor (0.17.0)
|
||||
yajl-ruby (1.1.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
librarian-chef
|
||||
20
Vagrantfile
vendored
Normal file
20
Vagrantfile
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.define :etalon do |main|
|
||||
main.vm.box = "ubuntu12.04-chef11-chruby"
|
||||
main.vm.hostname = "etalon"
|
||||
config.vm.network :forwarded_port, guest: 8080, host: 7070
|
||||
main.vm.provider :virtualbox do |vb|
|
||||
vb.customize ["modifyvm", :id, "--memory", "2048"]
|
||||
end
|
||||
main.vm.provision :chef_solo do |chef|
|
||||
chef.log_level = :info
|
||||
chef.roles_path = "roles"
|
||||
chef.data_bags_path = "data_bags"
|
||||
# Here the path to secret file on local filesystem
|
||||
chef.encrypted_data_bag_secret_key_path = "./.chef/encrypted_data_bag_secret"
|
||||
|
||||
chef.add_role "base"
|
||||
chef.add_role "redmine"
|
||||
end
|
||||
end
|
||||
end
|
||||
0
data_bags/.gitkeep
Normal file
0
data_bags/.gitkeep
Normal file
10
data_bags/db/databases.json
Normal file
10
data_bags/db/databases.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "databases",
|
||||
"databases": {
|
||||
"redmine": {
|
||||
"options": {
|
||||
"owner": "redmine"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
data_bags/db/users.json
Normal file
6
data_bags/db/users.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"id": "users",
|
||||
"users": {
|
||||
"redmine": {}
|
||||
}
|
||||
}
|
||||
10
data_bags/zabbix/databases.json
Normal file
10
data_bags/zabbix/databases.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "databases",
|
||||
"databases": {
|
||||
"zabbix": {
|
||||
"options": {
|
||||
"owner": "zabbix"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
data_bags/zabbix/users.json
Normal file
11
data_bags/zabbix/users.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "users",
|
||||
"users": {
|
||||
"zabbix": {
|
||||
"options": {
|
||||
"password": "yosJVAtYa4L4F7Q",
|
||||
"superuser": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
0
environments/.gitkeep
Normal file
0
environments/.gitkeep
Normal file
0
inhouse-cookbooks/.gitkeep
Normal file
0
inhouse-cookbooks/.gitkeep
Normal file
2
inhouse-cookbooks/base/attributes/default.rb
Normal file
2
inhouse-cookbooks/base/attributes/default.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
default['base']['packages'] = %w{sudo nscd screen vim curl sysstat gdb dstat tcpdump strace iozone3 htop tmux byobu mailutils ncdu mosh iotop atop}
|
||||
default['base']['extra-packages'] = []
|
||||
28
inhouse-cookbooks/base/libraries/mail.rb
Normal file
28
inhouse-cookbooks/base/libraries/mail.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
require 'rubygems'
|
||||
|
||||
module Express42
|
||||
class MailHandler < Chef::Handler
|
||||
def initialize(from_address, to_address)
|
||||
@from_address = from_address
|
||||
@to_address = to_address
|
||||
end
|
||||
|
||||
def report
|
||||
require 'pony'
|
||||
# The Node is available as +node+
|
||||
subject = "Chef run failed on #{node.name}"
|
||||
# +run_status+ is a value object with all of the run status data
|
||||
message = "#{run_status.formatted_exception}\n"
|
||||
# Join the backtrace lines. Coerce to an array just in case.
|
||||
message << Array(backtrace).join("\n")
|
||||
|
||||
Pony.mail(
|
||||
:to => @to_address,
|
||||
:from => @from_address,
|
||||
:subject => subject,
|
||||
:body => message)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
83
inhouse-cookbooks/base/libraries/network.rb
Normal file
83
inhouse-cookbooks/base/libraries/network.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
begin
|
||||
require 'ipaddr'
|
||||
rescue LoadError
|
||||
Chef::Log.error("Missing gem 'ipaddr'")
|
||||
end
|
||||
|
||||
module Express42
|
||||
module Base
|
||||
module Network
|
||||
|
||||
def net_get_networks(the_node=node)
|
||||
networks = { :private => [], :public => [] }
|
||||
|
||||
private_conditions = []
|
||||
public_exclusions = []
|
||||
|
||||
private_conditions << net1 = IPAddr.new("192.168.0.0/16")
|
||||
private_conditions << net2 = IPAddr.new("172.16.0.0/12")
|
||||
private_conditions << net3 = IPAddr.new("10.0.0.0/8")
|
||||
|
||||
public_exclusions << net4 = IPAddr.new("127.0.0.1/8")
|
||||
public_exclusions << net5 = IPAddr.new("169.254.0.0/16")
|
||||
|
||||
the_node["network"]["interfaces"].each do |interface|
|
||||
next if not interface[1]["addresses"] or interface[1]["state"] == "down"
|
||||
|
||||
ip_addr = interface[1]["addresses"].select { |address, data| data["family"] == "inet" }.to_a[0]
|
||||
next if ip_addr.nil?
|
||||
ip_addr = ip_addr[0]
|
||||
|
||||
|
||||
if private_conditions.detect{ |pc| pc.include?(ip_addr) }
|
||||
networks[:private] << [ interface[0], ip_addr ]
|
||||
next
|
||||
end
|
||||
if not private_conditions.detect { |pc| pc.include?(ip_addr) } and not public_exclusions.each.detect { |pe| pe.include?(ip_addr) }
|
||||
networks[:public] << [ interface[0], ip_addr ]
|
||||
next
|
||||
end
|
||||
|
||||
end
|
||||
return networks
|
||||
end
|
||||
|
||||
def net_get_all_ip(the_node=node)
|
||||
ips=[]
|
||||
networks = net_get_networks(the_node)
|
||||
networks.each_pair do |cond,eth_ip_array|
|
||||
eth_ip_array.each do |eth_ip|
|
||||
ips << eth_ip[1]
|
||||
end
|
||||
end
|
||||
return ips
|
||||
end
|
||||
|
||||
def net_get_public(the_node=node)
|
||||
return net_get_networks(the_node)[:public]
|
||||
end
|
||||
|
||||
def net_get_private(the_node=node)
|
||||
return net_get_networks(the_node)[:private]
|
||||
end
|
||||
|
||||
def get_private_ip_by_role(role)
|
||||
if n = search(:node, "role:#{role} AND chef_environment:#{node.chef_environment}").first
|
||||
net_get_private(n)[0][1]
|
||||
else
|
||||
raise "Role #{role} not found"
|
||||
end
|
||||
end
|
||||
|
||||
def get_public_ip_by_role(role)
|
||||
if n = search(:node, "role:#{role} AND chef_environment:#{node.chef_environment}").first
|
||||
net_get_public(n)[0][1]
|
||||
else
|
||||
raise "Role #{role} not found"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
16
inhouse-cookbooks/base/libraries/report.rb
Normal file
16
inhouse-cookbooks/base/libraries/report.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
require 'rubygems'
|
||||
|
||||
module Express42
|
||||
class ReportHandler < Chef::Handler
|
||||
def initialize
|
||||
end
|
||||
|
||||
def report
|
||||
run_status.updated_resources.each do |r|
|
||||
puts r.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
5
inhouse-cookbooks/base/metadata.rb
Normal file
5
inhouse-cookbooks/base/metadata.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
maintainer "LLC Express 42"
|
||||
maintainer_email "info@express42.com"
|
||||
license "MIT"
|
||||
description "Installs/Configures base"
|
||||
version "0.1.0"
|
||||
45
inhouse-cookbooks/base/recipes/default.rb
Normal file
45
inhouse-cookbooks/base/recipes/default.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# Cookbook Name:: base
|
||||
# Recipe:: default
|
||||
#
|
||||
# Author:: LLC Express 42 (info@express42.com)
|
||||
#
|
||||
# Copyright (C) LLC 2012 Express 42
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
# of the Software, and to permit persons to whom the Software is furnished to do
|
||||
# so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
|
||||
class Chef::Recipe
|
||||
include Express42::Base::Network
|
||||
end
|
||||
|
||||
apt_repository "express42-obs" do
|
||||
action :add
|
||||
uri "http://repos.express42.com:/web/precise/ ./"
|
||||
key 'http://repos.express42.com:/web/precise/Release.key'
|
||||
end
|
||||
|
||||
(node['base']['packages'] + node['base']['extra-packages']).uniq.each do |pkg|
|
||||
package pkg
|
||||
end
|
||||
|
||||
chef_gem "pony"
|
||||
|
||||
Chef::Config.exception_handlers = [Express42::MailHandler.new('chef@project.ru', ['admin@project.ru'])]
|
||||
Chef::Config.report_handlers = [Express42::ReportHandler.new]
|
||||
31
inhouse-cookbooks/base/recipes/hvm.rb
Normal file
31
inhouse-cookbooks/base/recipes/hvm.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Cookbook Name:: base
|
||||
# Recipe:: hvm
|
||||
#
|
||||
# Author:: LLC Express 42 (info@express42.com)
|
||||
#
|
||||
# Copyright (C) LLC 2012 Express 42
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
# of the Software, and to permit persons to whom the Software is furnished to do
|
||||
# so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
|
||||
%w{qemu-kvm libvirt-bin bridge-utils}.each do |pkg|
|
||||
package pkg
|
||||
end
|
||||
|
||||
6783
inhouse-cookbooks/fake/files/default/zbx_templates.xml
Normal file
6783
inhouse-cookbooks/fake/files/default/zbx_templates.xml
Normal file
File diff suppressed because it is too large
Load Diff
5
inhouse-cookbooks/fake/metadata.rb
Normal file
5
inhouse-cookbooks/fake/metadata.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
maintainer "LLC Express 42"
|
||||
maintainer_email "info@express42.com"
|
||||
license "MIT"
|
||||
description "Installs/Configures fake client"
|
||||
version "0.1.0"
|
||||
4
inhouse-cookbooks/fake/recipes/after.rb
Normal file
4
inhouse-cookbooks/fake/recipes/after.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
puts "*" * 80
|
||||
puts "After"
|
||||
puts "*" * 80
|
||||
p run_context.resource_collection.map(&:to_s)
|
||||
1
inhouse-cookbooks/fake/recipes/before.rb
Normal file
1
inhouse-cookbooks/fake/recipes/before.rb
Normal file
@@ -0,0 +1 @@
|
||||
p run_context.resource_collection.map(&:to_s)
|
||||
50
inhouse-cookbooks/fake/recipes/zabbix-screens.rb
Normal file
50
inhouse-cookbooks/fake/recipes/zabbix-screens.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
disks = `find /sys/devices/pci* -type d | grep block/[a-z,0-9,\!]*$`.split("\n")
|
||||
|
||||
disks = disks.select do |disk|
|
||||
type = `cat #{disk}/device/type`.chomp.to_i
|
||||
type != 5 # dvd and so on
|
||||
end
|
||||
|
||||
disks = disks.map { |disk| disk.split("\/").last.gsub("!", "\/") }
|
||||
|
||||
zabbix_screen node.fqdn do
|
||||
vsize(3 + disks.size * 2)
|
||||
|
||||
screen_item "System: Load Average" do
|
||||
resource_type :graph
|
||||
width 900
|
||||
height 200
|
||||
y 0
|
||||
end
|
||||
|
||||
screen_item "System: CPU Utilization" do
|
||||
resource_type :graph
|
||||
width 900
|
||||
height 200
|
||||
y 1
|
||||
end
|
||||
|
||||
pos_y = 2
|
||||
|
||||
disks.each do |disk|
|
||||
application = "Disk performance of /dev/#{disk}"
|
||||
|
||||
screen_item "#{application}: io per second" do
|
||||
resource_type :graph
|
||||
width 900
|
||||
height 200
|
||||
y pos_y
|
||||
end
|
||||
|
||||
pos_y += 1
|
||||
|
||||
screen_item "#{application}: io latency" do
|
||||
resource_type :graph
|
||||
width 900
|
||||
height 200
|
||||
y pos_y
|
||||
end
|
||||
|
||||
pos_y += 1
|
||||
end
|
||||
end
|
||||
57
inhouse-cookbooks/fake/recipes/zabbix.rb
Normal file
57
inhouse-cookbooks/fake/recipes/zabbix.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
zabbix_connect "connect to kupikupon zabbix" do
|
||||
apiurl "http://127.0.0.1/api_jsonrpc.php"
|
||||
user "Admin"
|
||||
password "zabbix"
|
||||
end
|
||||
|
||||
ip_mon = net_get_private(node).empty? ? net_get_public(node)[0][1] : net_get_private(node)[0][1]
|
||||
|
||||
zabbix_host node.fqdn do
|
||||
host_group "Fake client"
|
||||
use_ip true
|
||||
ip_address ip_mon
|
||||
end
|
||||
|
||||
cookbook_file "zbx_templates.xml" do
|
||||
path "/tmp/zbx_templates.xml"
|
||||
end
|
||||
|
||||
zabbix_template "/tmp/zbx_templates.xml" do
|
||||
action :import
|
||||
end
|
||||
|
||||
zabbix_template 'Linux_Template'
|
||||
|
||||
## Just for test
|
||||
zabbix_media_type "sms" do
|
||||
type :sms
|
||||
modem "/dev/modem"
|
||||
end
|
||||
|
||||
zabbix_user_group 'My Beloved group'
|
||||
|
||||
zabbix_action 'My favorite action' do
|
||||
event_source :triggers
|
||||
operation do
|
||||
user_groups 'My Beloved group'
|
||||
message do
|
||||
use_default_message false
|
||||
subject "Test {TRIGGER.SEVERITY}: {HOSTNAME1} {TRIGGER.STATUS}: {TRIGGER.NAME}"
|
||||
message "Trigger: {TRIGGER.NAME}\n"+
|
||||
"Trigger status: {TRIGGER.STATUS}\n" +
|
||||
"Trigger severity: {TRIGGER.SEVERITY}\n" +
|
||||
"\n" +
|
||||
"Item values:\n" +
|
||||
"{ITEM.NAME1} ({HOSTNAME1}:{TRIGGER.KEY1}): {ITEM.VALUE1}"
|
||||
media_type "sms"
|
||||
end
|
||||
end
|
||||
|
||||
condition :trigger_severity, :gte, :high
|
||||
# condition :host_group, :equal, "Fake Client"
|
||||
condition :maintenance, :not_in, :maintenance
|
||||
end
|
||||
|
||||
zabbix_user_macro 'my_macro' do
|
||||
value 'foobar'
|
||||
end
|
||||
0
roles/.gitkeep
Normal file
0
roles/.gitkeep
Normal file
14
roles/base.rb
Normal file
14
roles/base.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
name "base"
|
||||
description "common for all"
|
||||
run_list "recipe[sysctl]", "recipe[timezone]", "recipe[apt]", "recipe[ntp]", "recipe[user::data_bag]", "recipe[base]", "recipe[sudo]", "recipe[lvm]"
|
||||
|
||||
default_attributes(
|
||||
'ruby' => {
|
||||
'ruby_build' => {
|
||||
'git_ref' => 'd410f6811defd71d872dc2acd9ee633f52fbf94a'
|
||||
},
|
||||
'chruby' => {
|
||||
'git_ref' => 'df6bde0573c2df1ec9bf959b717d0005dfaf936e'
|
||||
}
|
||||
}
|
||||
)
|
||||
6
roles/redmine.rb
Normal file
6
roles/redmine.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
name "redmine"
|
||||
description "Install and configure redmine"
|
||||
run_list "recipe[runit]", "recipe[postgresql]", "recipe[ruby]", "recipe[redmine]"
|
||||
|
||||
default_attributes(
|
||||
)
|
||||
6
roles/zbx.rb
Normal file
6
roles/zbx.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
name "zbx"
|
||||
description "zabbix server and client"
|
||||
run_list "recipe[php::default]", "recipe[nginx]", "recipe[fake::zabbix]", "recipe[zabbix-server::database]", "recipe[zabbix-server::server]", "recipe[zabbix-server::web]", "recipe[zabbix]", "recipe[partition]"#, "recipe[fake::zabbix-screens]"
|
||||
|
||||
default_attributes(
|
||||
)
|
||||
Reference in New Issue
Block a user