naminori 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -53
- data/lib/naminori.rb +22 -4
- data/lib/naminori/attribute.rb +11 -0
- data/lib/naminori/configure.rb +31 -0
- data/lib/naminori/lb/base.rb +3 -3
- data/lib/naminori/lb/lvs.rb +16 -36
- data/lib/naminori/notifier.rb +4 -16
- data/lib/naminori/notifier/configure.rb +9 -28
- data/lib/naminori/notifier/slack.rb +15 -13
- data/lib/naminori/serf.rb +5 -2
- data/lib/naminori/service/base.rb +12 -30
- data/lib/naminori/service/configure.rb +15 -10
- data/lib/naminori/service/dns.rb +5 -5
- data/lib/naminori/service/http.rb +5 -4
- data/lib/naminori/version.rb +1 -1
- metadata +4 -6
- data/lib/naminori/lb.rb +0 -13
- data/lib/naminori/naminori.rb +0 -14
- data/lib/naminori/notifier/base.rb +0 -10
- data/lib/naminori/service.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 211f84aefe99edcff09ec2e6cc5c4566c82e58bb
|
4
|
+
data.tar.gz: 287a42d2cb81de3be55d92c7a7db79ab884471ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4317b5996c31afb0ec4adb1dd2adbcf2d1fa4f143c471797b77bb7996d3f3533e67f817962c4148feb39c5bdaf876544ebd7ee347d8d6100adfe1f971743a587
|
7
|
+
data.tar.gz: a4ed6a67a9787ceee61fa71dfc206122ae8f494f6aab7c6ca6fba5acec063d2f98f02d804d87ca69139c9c8bb7cde6837cefc7ebd53da3da1af9803e125b68f9
|
data/README.md
CHANGED
@@ -21,30 +21,33 @@ Or install it yourself as:
|
|
21
21
|
#### envent_example.rb
|
22
22
|
1. check the event classification
|
23
23
|
2. add or delete rip if these member-join or member-leave(faile)
|
24
|
-
3.
|
24
|
+
3. health_check with fetch member
|
25
25
|
|
26
26
|
```ruby
|
27
27
|
#! /usr/bin/env ruby
|
28
28
|
require 'rubygems'
|
29
29
|
require 'naminori'
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
Naminori.configure do |config|
|
32
|
+
config.notifier :slack do
|
33
|
+
webhook_url "https://hooks.slack.com/services/XXXXXX"
|
34
|
+
channel "#pyama"
|
35
|
+
end
|
36
|
+
|
37
|
+
config.service :dns_server do
|
38
|
+
service :dns
|
39
|
+
protocol "udp"
|
40
|
+
vip "192.68.77.9"
|
41
|
+
end
|
42
|
+
|
43
|
+
config.service :dns_server do
|
44
|
+
service :dns
|
45
|
+
protocol "tcp"
|
46
|
+
vip "192.68.77.9"
|
47
|
+
end
|
34
48
|
end
|
35
49
|
|
36
|
-
|
37
|
-
vip:"192.168.77.9",
|
38
|
-
role: "dns",
|
39
|
-
notifier: Naminori::Notifier.get_notifier("slack" ,notifier_options)
|
40
|
-
}
|
41
|
-
|
42
|
-
case
|
43
|
-
when Naminori::Serf.role?("dns")
|
44
|
-
Naminori::Service::Dns.event("lvs", service_options)
|
45
|
-
when Naminori::Serf.role?("lb")
|
46
|
-
Naminori::Service::Dns.health_check("lvs", service_options)
|
47
|
-
end
|
50
|
+
Naminori.run
|
48
51
|
|
49
52
|
```
|
50
53
|
|
@@ -57,7 +60,7 @@ end
|
|
57
60
|
"interface": "enp0s9",
|
58
61
|
"discover": "cache-dns",
|
59
62
|
"tags": {
|
60
|
-
"role": "
|
63
|
+
"role": "lb_server"
|
61
64
|
},
|
62
65
|
"log_level": "debug"
|
63
66
|
}
|
@@ -72,55 +75,45 @@ end
|
|
72
75
|
"interface": "enp0s8",
|
73
76
|
"discover": "cache-dns",
|
74
77
|
"tags": {
|
75
|
-
"role": "
|
78
|
+
"role": "dns_server"
|
76
79
|
}
|
77
80
|
}
|
78
81
|
```
|
79
82
|
|
80
|
-
#### health_check_example.rb
|
81
|
-
1. Using cron to the health check of the service
|
82
|
-
2. Service is removed from the member if that is not healthy
|
83
|
-
* Parameter [query, timeout ,retry]
|
84
|
-
|
85
|
-
```ruby
|
86
|
-
#! /usr/bin/env ruby
|
87
|
-
require 'rubygems'
|
88
|
-
require 'naminori'
|
89
|
-
|
90
|
-
service_options = { vip:"192.168.77.9", role: "dns" }
|
91
|
-
|
92
|
-
Naminori::Service::Dns.health_check("lvs", service_options)
|
93
|
-
```
|
94
83
|
```zsh
|
95
84
|
# crontab -l
|
96
85
|
# Chef Name: health_check
|
97
86
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
|
98
|
-
* * * * * for i in `seq 0 10 59`;do (sleep ${i}; /opt/serf/event_handlers/
|
87
|
+
* * * * * for i in `seq 0 10 59`;do (sleep ${i}; /opt/serf/event_handlers/event_example.rb)& done;
|
99
88
|
```
|
100
89
|
|
101
|
-
###
|
90
|
+
### default parameter
|
91
|
+
#### DNS
|
102
92
|
```
|
103
|
-
|
93
|
+
{
|
94
|
+
lb: "lvs" # lb type
|
95
|
+
port: "53", # service port
|
96
|
+
protocol: "udp" # protocol
|
97
|
+
vip: "192.168.77.9", # service vip
|
98
|
+
method: "nat", # lvs_method gateway/ip/nat
|
99
|
+
query: "pepabo.com", # health_check_query
|
100
|
+
retry_c: 3, # health_check_retry_c_count
|
101
|
+
timeout: 3, # health_check_time_out
|
102
|
+
}
|
104
103
|
```
|
105
|
-
|
106
|
-
dns or http
|
107
|
-
* lb_name:
|
108
|
-
lvs
|
109
|
-
* options
|
110
|
-
|
104
|
+
#### HTTP
|
111
105
|
```
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
notifier: nil # notifier
|
123
|
-
}
|
106
|
+
{
|
107
|
+
lb: "lvs",
|
108
|
+
port: "80",
|
109
|
+
protocol: "tcp",
|
110
|
+
vip: "192.168.77.9",
|
111
|
+
method: "nat",
|
112
|
+
query: "index.html",
|
113
|
+
retry_c: 3,
|
114
|
+
timeout: 3
|
115
|
+
}
|
124
116
|
```
|
117
|
+
|
125
118
|
## Author
|
126
119
|
* pyama
|
data/lib/naminori.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
require "naminori/version"
|
2
|
+
require "naminori/attribute"
|
3
|
+
require 'naminori/configure'
|
2
4
|
require 'naminori/serf'
|
3
|
-
require 'naminori/lb'
|
4
5
|
require 'naminori/lb/base'
|
5
6
|
require 'naminori/lb/lvs'
|
6
|
-
require 'naminori/service'
|
7
7
|
require 'naminori/service/base'
|
8
8
|
require 'naminori/service/configure'
|
9
9
|
require 'naminori/service/dns'
|
10
10
|
require 'naminori/service/http'
|
11
11
|
require 'naminori/notifier'
|
12
|
-
require 'naminori/notifier/base'
|
13
12
|
require 'naminori/notifier/configure'
|
14
13
|
require 'naminori/notifier/slack'
|
15
14
|
require 'resolv'
|
@@ -17,5 +16,24 @@ require 'slack-notifier'
|
|
17
16
|
|
18
17
|
|
19
18
|
module Naminori
|
20
|
-
|
19
|
+
def self.run
|
20
|
+
Naminori.configure.service.each do |s|
|
21
|
+
service = Object.const_get("Naminori::Service::#{s.service.to_s.capitalize}").new(s)
|
22
|
+
service.run
|
23
|
+
health_check(service)
|
24
|
+
end if Naminori.configure.service
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.health_check(service)
|
28
|
+
if members = Naminori::Serf.get_alive_member_by_role(service.config.role.to_s)
|
29
|
+
members.each do |member|
|
30
|
+
ip = member[:ip]
|
31
|
+
if service.healty?(ip)
|
32
|
+
Object.const_get("Naminori::Lb::#{service.config.lb.to_s.capitalize}").add_member(ip, service)
|
33
|
+
elsif service.config.retry_c.times.all? { sleep 1; !service.healty?(ip) }
|
34
|
+
Object.const_get("Naminori::Lb::#{service.config.lb.to_s.capitalize}").delete_member(ip, service)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
21
39
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Naminori
|
2
|
+
class Configure
|
3
|
+
def initialize
|
4
|
+
@_config ||= {}
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.resource(resource_name)
|
8
|
+
define_method(resource_name, ->(name=nil, &block){
|
9
|
+
if name
|
10
|
+
config = Object.const_get("Naminori::#{resource_name.capitalize}::Configure").new(name)
|
11
|
+
config.instance_eval(&block) if block
|
12
|
+
@_config[resource_name] ||= []
|
13
|
+
@_config[resource_name] << config
|
14
|
+
end
|
15
|
+
@_config[resource_name]
|
16
|
+
})
|
17
|
+
end
|
18
|
+
|
19
|
+
resource :service
|
20
|
+
resource :notifier
|
21
|
+
resource :lb
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.configure(&block)
|
25
|
+
if block
|
26
|
+
@__config = Configure.new
|
27
|
+
@__config.instance_eval(&block)
|
28
|
+
end
|
29
|
+
@__config
|
30
|
+
end
|
31
|
+
end
|
data/lib/naminori/lb/base.rb
CHANGED
@@ -9,9 +9,9 @@ module Naminori
|
|
9
9
|
def delete_member(rip, service)
|
10
10
|
raise "Called abstract method: add_member"
|
11
11
|
end
|
12
|
-
|
13
|
-
def
|
14
|
-
message = "#{type} member ip:#{
|
12
|
+
|
13
|
+
def notify(type, rip, service)
|
14
|
+
message = "#{type} member ip:#{rip} protocol:#{service.config.protocol} in vip:#{service.config.vip}"
|
15
15
|
puts message
|
16
16
|
Naminori::Notifier.notify(type, message)
|
17
17
|
end
|
data/lib/naminori/lb/lvs.rb
CHANGED
@@ -4,57 +4,38 @@ module Naminori
|
|
4
4
|
class Lvs < Naminori::Lb::Base
|
5
5
|
class << self
|
6
6
|
def add_member(rip, service)
|
7
|
-
transaction("add",
|
7
|
+
transaction("add", rip, service) if service.healty?(rip) && exist_ip?(service.config.vip, service) && !exist_ip?(rip, service)
|
8
8
|
end
|
9
9
|
|
10
10
|
def delete_member(rip, service)
|
11
|
-
transaction("delete",
|
11
|
+
transaction("delete", rip, service) if exist_ip?(rip, service)
|
12
12
|
end
|
13
13
|
|
14
|
-
def transaction(type,
|
15
|
-
|
16
|
-
|
17
|
-
if self.send("#{type}?", merge_option) && system("ipvsadm #{command_option(type, merge_option)}")
|
18
|
-
notifier(type, merge_option)
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end.all? {|res| res }
|
22
|
-
end
|
23
|
-
|
24
|
-
def add?(ops)
|
25
|
-
vip_exists?(ops) && !delete?(ops)
|
26
|
-
end
|
27
|
-
|
28
|
-
def delete?(ops)
|
29
|
-
fetch_service(ops).each do |line|
|
30
|
-
return true if line.match(/#{ops[:rip]}:/)
|
14
|
+
def transaction(type, rip, service)
|
15
|
+
if system("ipvsadm #{command_option(type, rip, service)}")
|
16
|
+
notify(type, rip, service)
|
31
17
|
end
|
32
|
-
false
|
33
18
|
end
|
34
19
|
|
35
|
-
def
|
36
|
-
fetch_service(
|
37
|
-
|
20
|
+
def exist_ip?(ip, service)
|
21
|
+
fetch_service(service).find do |line|
|
22
|
+
line.match(/#{ip}/)
|
38
23
|
end
|
39
|
-
false
|
40
24
|
end
|
41
25
|
|
42
|
-
def fetch_service(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def lvs_option(rip, service)
|
49
|
-
{ service: service, vip: service.config.vip, rip: rip, protocols: service.config.protocols, port: service.config.port, method: service.config.method }
|
26
|
+
def fetch_service(service)
|
27
|
+
unless result = `ipvsadm -Ln --#{service.config.protocol}-service #{service.config.vip}:#{service.config.port}`.split("\n")
|
28
|
+
raise "fetch errror!"
|
29
|
+
end
|
30
|
+
result
|
50
31
|
end
|
51
32
|
|
52
|
-
def command_option(type,
|
33
|
+
def command_option(type, rip, service)
|
53
34
|
case
|
54
35
|
when type == "add"
|
55
|
-
"--#{type}-server --#{
|
36
|
+
"--#{type}-server --#{service.config.protocol}-service #{service.config.vip}:#{service.config.port} -r #{rip}:#{service.config.port} #{method_option(service.config.method)}"
|
56
37
|
when type == "delete"
|
57
|
-
"--#{type}-server --#{
|
38
|
+
"--#{type}-server --#{service.config.protocol}-service #{service.config.vip}:#{service.config.port} -r #{rip}:#{service.config.port}"
|
58
39
|
end
|
59
40
|
end
|
60
41
|
|
@@ -68,7 +49,6 @@ module Naminori
|
|
68
49
|
"-i"
|
69
50
|
end
|
70
51
|
end
|
71
|
-
|
72
52
|
end
|
73
53
|
end
|
74
54
|
end
|
data/lib/naminori/notifier.rb
CHANGED
@@ -3,23 +3,11 @@ module Naminori
|
|
3
3
|
module Notifier
|
4
4
|
class << self
|
5
5
|
def notify(type, message)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def get_notifier(notifier)
|
13
|
-
case notifier
|
14
|
-
when "slack"
|
15
|
-
Naminori::Notifier::Slack.new
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def configure(&block)
|
20
|
-
Naminori::Notifier.config(&block)
|
6
|
+
return true unless Naminori.configure.notifier
|
7
|
+
Naminori.configure.notifier.all? do |config|
|
8
|
+
Object.const_get("Naminori::Notifier::#{config.type.to_s.capitalize}").notify(type, message, config)
|
9
|
+
end
|
21
10
|
end
|
22
11
|
end
|
23
12
|
end
|
24
|
-
|
25
13
|
end
|
@@ -1,38 +1,19 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
|
+
require 'naminori'
|
2
3
|
module Naminori
|
3
4
|
module Notifier
|
4
5
|
class Configure
|
5
|
-
|
6
|
-
|
7
|
-
instance_variable_set(v, nil)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def slack_enable?
|
12
|
-
webhook_url && channel && user
|
13
|
-
end
|
6
|
+
extend Naminori::Attribute
|
7
|
+
attr_accessor :config
|
14
8
|
|
15
|
-
def
|
16
|
-
|
17
|
-
@_webhook_url
|
9
|
+
def initialize(name)
|
10
|
+
type name
|
18
11
|
end
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def user(user=nil)
|
26
|
-
@_user = user if user
|
27
|
-
@_user
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.config(&block)
|
32
|
-
@_config ||= Naminori::Notifier::Configure.new
|
33
|
-
@_config.instance_eval(&block) if block
|
34
|
-
@_config
|
13
|
+
attribute :type
|
14
|
+
attribute :webhook_url
|
15
|
+
attribute :channel
|
16
|
+
attribute :user
|
35
17
|
end
|
36
18
|
end
|
37
|
-
|
38
19
|
end
|
@@ -1,19 +1,21 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
module Naminori
|
3
3
|
module Notifier
|
4
|
-
class Slack
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
4
|
+
class Slack
|
5
|
+
class << self
|
6
|
+
def notify(type, message, config)
|
7
|
+
icon = type == "add" ? ":white_check_mark:" : ":no_entry_sign:"
|
8
|
+
notifier = ::Slack::Notifier.new(
|
9
|
+
config.webhook_url,
|
10
|
+
{
|
11
|
+
channel: config.channel,
|
12
|
+
username: config.user
|
13
|
+
}
|
14
|
+
)
|
15
|
+
notifier.ping icon + message, icon_emoji: ":sparkle:"
|
16
|
+
rescue => e
|
17
|
+
p e
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
data/lib/naminori/serf.rb
CHANGED
@@ -2,13 +2,16 @@
|
|
2
2
|
module Naminori
|
3
3
|
class Serf
|
4
4
|
@@event = nil
|
5
|
+
|
5
6
|
class << self
|
6
7
|
def gets
|
7
8
|
@@event ||= STDIN.gets.chomp.match(/(?<node>.+?)\t(?<ip>.+?)\t(?<role>.+?)\t/)
|
9
|
+
rescue
|
10
|
+
@@event
|
8
11
|
end
|
9
12
|
|
10
13
|
def event_message
|
11
|
-
puts "event:#{ENV['SERF_EVENT']} value:#{
|
14
|
+
puts "event:#{ENV['SERF_EVENT']} value:#{gets}" if gets
|
12
15
|
end
|
13
16
|
|
14
17
|
def join?
|
@@ -24,7 +27,7 @@ module Naminori
|
|
24
27
|
end
|
25
28
|
|
26
29
|
def role?(role)
|
27
|
-
gets[:role] == role
|
30
|
+
gets && gets[:role] == role
|
28
31
|
end
|
29
32
|
|
30
33
|
def get_alive_member_by_role(role)
|
@@ -3,41 +3,23 @@ module Naminori
|
|
3
3
|
class Service
|
4
4
|
class Base
|
5
5
|
attr_reader :config
|
6
|
-
|
7
|
-
|
6
|
+
def initialize(config_klass)
|
7
|
+
config_klass.config = default_config.merge(config_klass.config)
|
8
|
+
@config = config_klass
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
if Naminori::Serf.role?(config.role.to_s)
|
13
|
+
ip = Naminori::Serf.gets[:ip]
|
8
14
|
case
|
9
15
|
when Naminori::Serf.join?
|
10
|
-
Naminori::Lb.
|
16
|
+
Object.const_get("Naminori::Lb::#{config.lb.to_s.capitalize}").add_member(ip, self)
|
11
17
|
when Naminori::Serf.leave? || Naminori::Serf.failed?
|
12
|
-
Naminori::Lb.
|
18
|
+
Object.const_get("Naminori::Lb::#{config.lb.to_s.capitalize}").delete_member(ip, self)
|
13
19
|
end
|
14
20
|
end
|
15
|
-
|
16
|
-
def event_ip
|
17
|
-
Naminori::Serf.gets[:ip]
|
18
|
-
end
|
19
|
-
|
20
|
-
def health_check(lb_name, options)
|
21
|
-
service = self.new(options)
|
22
|
-
members = Naminori::Serf.get_alive_member_by_role(service.config.role)
|
23
|
-
members.each do |member|
|
24
|
-
ip = member[:ip]
|
25
|
-
if service.healty?(ip)
|
26
|
-
Naminori::Lb.get_lb(lb_name).add_member(ip, service)
|
27
|
-
elsif service.config.retry.times.all? { sleep 1; !service.healty?(ip) }
|
28
|
-
Naminori::Lb.get_lb(lb_name).delete_member(ip, service)
|
29
|
-
end
|
30
|
-
end if members
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
def initialize(options)
|
36
|
-
@config = Naminori::Service::Configure.new(
|
37
|
-
default_config.merge(options)
|
38
|
-
)
|
39
21
|
end
|
40
|
-
|
22
|
+
|
41
23
|
def healty?(ip)
|
42
24
|
raise "Called abstract method: healty?"
|
43
25
|
end
|
@@ -45,7 +27,7 @@ module Naminori
|
|
45
27
|
def default_config
|
46
28
|
raise "Called abstract method: default_config"
|
47
29
|
end
|
48
|
-
|
30
|
+
|
49
31
|
end
|
50
32
|
end
|
51
33
|
end
|
@@ -2,17 +2,22 @@
|
|
2
2
|
module Naminori
|
3
3
|
class Service
|
4
4
|
class Configure
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@protocols = options[:protocols]
|
10
|
-
@vip = options[:vip]
|
11
|
-
@method = options[:method]
|
12
|
-
@query = options[:query]
|
13
|
-
@retry = options[:retry]
|
14
|
-
@timeout = options[:timeout]
|
5
|
+
extend Naminori::Attribute
|
6
|
+
attr_accessor :config
|
7
|
+
def initialize(name)
|
8
|
+
role name
|
15
9
|
end
|
10
|
+
|
11
|
+
attribute :role
|
12
|
+
attribute :service
|
13
|
+
attribute :lb
|
14
|
+
attribute :port
|
15
|
+
attribute :protocol
|
16
|
+
attribute :vip
|
17
|
+
attribute :method
|
18
|
+
attribute :query
|
19
|
+
attribute :retry_c
|
20
|
+
attribute :timeout
|
16
21
|
end
|
17
22
|
end
|
18
23
|
end
|
data/lib/naminori/service/dns.rb
CHANGED
@@ -2,26 +2,26 @@
|
|
2
2
|
module Naminori
|
3
3
|
class Service
|
4
4
|
class Dns < Naminori::Service::Base
|
5
|
-
|
6
5
|
def healty?(ip)
|
7
6
|
dns = Resolv::DNS.new(:nameserver => ip )
|
8
7
|
dns.timeouts = config.timeout
|
9
8
|
begin
|
10
|
-
dns.getaddress(
|
11
|
-
rescue
|
9
|
+
dns.getaddress(config.query)
|
10
|
+
rescue
|
12
11
|
false
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
def default_config
|
17
16
|
{
|
17
|
+
lb: "lvs",
|
18
18
|
role: "dns",
|
19
19
|
port: "53",
|
20
|
-
|
20
|
+
protocol: "udp",
|
21
21
|
vip: "192.168.77.9",
|
22
22
|
method: "nat",
|
23
23
|
query: "pepabo.com",
|
24
|
-
|
24
|
+
retry_c: 3,
|
25
25
|
timeout: 3
|
26
26
|
}
|
27
27
|
end
|
@@ -8,21 +8,22 @@ module Naminori
|
|
8
8
|
http.open_timeout = config.timeout
|
9
9
|
|
10
10
|
begin
|
11
|
-
http.get("/#{
|
12
|
-
rescue
|
11
|
+
http.get("/#{config.query}")
|
12
|
+
rescue
|
13
13
|
false
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def default_config
|
18
18
|
{
|
19
|
+
lb: "lvs",
|
19
20
|
role: "http",
|
20
21
|
port: "80",
|
21
|
-
|
22
|
+
protocol: "tcp",
|
22
23
|
vip: "192.168.77.9",
|
23
24
|
method: "nat",
|
24
25
|
query: "index.html",
|
25
|
-
|
26
|
+
retry_c: 3,
|
26
27
|
timeout: 3
|
27
28
|
}
|
28
29
|
end
|
data/lib/naminori/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naminori
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kazuhiko yamahsita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-notifier
|
@@ -80,16 +80,14 @@ files:
|
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
82
|
- lib/naminori.rb
|
83
|
-
- lib/naminori/
|
83
|
+
- lib/naminori/attribute.rb
|
84
|
+
- lib/naminori/configure.rb
|
84
85
|
- lib/naminori/lb/base.rb
|
85
86
|
- lib/naminori/lb/lvs.rb
|
86
|
-
- lib/naminori/naminori.rb
|
87
87
|
- lib/naminori/notifier.rb
|
88
|
-
- lib/naminori/notifier/base.rb
|
89
88
|
- lib/naminori/notifier/configure.rb
|
90
89
|
- lib/naminori/notifier/slack.rb
|
91
90
|
- lib/naminori/serf.rb
|
92
|
-
- lib/naminori/service.rb
|
93
91
|
- lib/naminori/service/base.rb
|
94
92
|
- lib/naminori/service/configure.rb
|
95
93
|
- lib/naminori/service/dns.rb
|
data/lib/naminori/lb.rb
DELETED
data/lib/naminori/naminori.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
require File.dirname(__FILE__) + '/serf'
|
3
|
-
require File.dirname(__FILE__) + '/lb'
|
4
|
-
require File.dirname(__FILE__) + '/lb/base'
|
5
|
-
require File.dirname(__FILE__) + '/lb/lvs'
|
6
|
-
require File.dirname(__FILE__) + '/service'
|
7
|
-
require File.dirname(__FILE__) + '/service/base'
|
8
|
-
require File.dirname(__FILE__) + '/service/configure'
|
9
|
-
require File.dirname(__FILE__) + '/service/dns'
|
10
|
-
require File.dirname(__FILE__) + '/service/http'
|
11
|
-
require 'resolv'
|
12
|
-
require 'net/http'
|
13
|
-
require 'net/https'
|
14
|
-
|
data/lib/naminori/service.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
module Naminori
|
3
|
-
class Service
|
4
|
-
class << self
|
5
|
-
def event(service_name, lb_name, options={})
|
6
|
-
get_service(service_name).event(lb_name, options)
|
7
|
-
end
|
8
|
-
|
9
|
-
def get_service(service_name)
|
10
|
-
case service_name
|
11
|
-
when "dns"
|
12
|
-
Naminori::Service::Dns
|
13
|
-
when "http"
|
14
|
-
Naminori::Service::Http
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|