collect-agent 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/collect-agent +10 -5
- data/collect-agent.gemspec +1 -1
- metadata +2 -4
- data/lib/helpers.rb +0 -18
data/bin/collect-agent
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'chef'
|
4
4
|
require 'trollop'
|
5
|
-
require File.dirname(__FILE__) + '/../lib/helpers.rb'
|
6
5
|
|
7
6
|
opts = Trollop::options do
|
8
7
|
version "Collect-agent for chef"
|
@@ -15,19 +14,25 @@ where [options] are:
|
|
15
14
|
EOS
|
16
15
|
|
17
16
|
opt :config, "Config chef file", :default => "/etc/chef/client.rb"
|
17
|
+
opt :plugins, "Ohai plugins directory", :default => "/etc/chef/ohai_plugins"
|
18
18
|
end
|
19
19
|
|
20
|
+
# load ohai
|
21
|
+
Ohai::Config[:plugin_path] << opts[:plugins]
|
20
22
|
ohai = Ohai::System.new
|
21
23
|
ohai.all_plugins
|
22
24
|
ohai.seen_plugins
|
25
|
+
|
26
|
+
# get node
|
23
27
|
Chef::Config.from_file(opts[:config])
|
24
28
|
host = Chef::Config[:node_name] || ohai[:fqdn] || ohai[:hostname]
|
25
29
|
client = Chef::REST.new(Chef::Config[:chef_server_url], host, Chef::Config[:client_key])
|
26
30
|
node = client.get_rest("nodes/#{host}")
|
27
31
|
|
32
|
+
# refresh node automatic contents
|
28
33
|
node.automatic_attrs.keys.each { |key| node.automatic_attrs[key] = ohai.data[key] if ohai.data[key] }
|
34
|
+
ohai.data.keys.each { |key| node.automatic_attrs[key] = ohai.data[key] }
|
35
|
+
node.set[:collect_agent][:flag] = "collect_agent"
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
client.put_rest("nodes/#{host}", node)
|
37
|
+
# post node
|
38
|
+
client.put_rest("nodes/#{host}", node)
|
data/collect-agent.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collect-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -57,7 +57,6 @@ files:
|
|
57
57
|
- Rakefile
|
58
58
|
- bin/collect-agent
|
59
59
|
- collect-agent.gemspec
|
60
|
-
- lib/helpers.rb
|
61
60
|
homepage: https://git.undev.cc/megaadmins/collect-agent
|
62
61
|
licenses:
|
63
62
|
- MIT
|
@@ -84,4 +83,3 @@ signing_key:
|
|
84
83
|
specification_version: 3
|
85
84
|
summary: Chef collect agent
|
86
85
|
test_files: []
|
87
|
-
has_rdoc:
|
data/lib/helpers.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
def set_network_addresses(node)
|
2
|
-
private_regexp = "(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)"
|
3
|
-
localhost_regexp = "(^127\.)"
|
4
|
-
all_addresses = Array.new
|
5
|
-
private_addresses = Array.new
|
6
|
-
node.network['interfaces'].each do |iface, addrs|
|
7
|
-
addrs['addresses'].each do |ip, params|
|
8
|
-
all_addresses << ip if params['family'].eql?('inet') && !ip.match(localhost_regexp) && !iface.match(/^lo/)
|
9
|
-
private_addresses << ip if params['family'].eql?('inet') && ip.match(private_regexp)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
node.automatic_attrs['network']['addresses_private'] = private_addresses
|
13
|
-
node.automatic_attrs['network']['addresses_all'] = all_addresses
|
14
|
-
end
|
15
|
-
|
16
|
-
def set_flag(node)
|
17
|
-
node.set[:collect_agent][:flag] = "collect_agent"
|
18
|
-
end
|