collect-agent 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/collect-agent +16 -3
- data/collect-agent.gemspec +1 -1
- metadata +2 -2
data/bin/collect-agent
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# coding: utf-8
|
3
3
|
|
4
4
|
require 'chef'
|
5
5
|
require 'trollop'
|
@@ -16,8 +16,14 @@ EOS
|
|
16
16
|
|
17
17
|
opt :config, "Config chef file", :default => "/etc/chef/client.rb"
|
18
18
|
opt :plugins, "Ohai plugins directory", :default => "/etc/chef/ohai_plugins"
|
19
|
+
opt :cookbook, "Ohai download plugins from cookbook", :default => "commonlib"
|
20
|
+
opt :cookbook_path, "Cookbook path", :default => "files/default/ohai/plugins"
|
19
21
|
end
|
20
22
|
|
23
|
+
# Get chef config
|
24
|
+
Chef::Config.from_file(opts[:config])
|
25
|
+
Ohai::Log.level = Chef::Config[:log_level]
|
26
|
+
|
21
27
|
# load ohai
|
22
28
|
Ohai::Config[:plugin_path] << opts[:plugins]
|
23
29
|
ohai = Ohai::System.new
|
@@ -25,7 +31,6 @@ ohai.all_plugins
|
|
25
31
|
ohai.seen_plugins
|
26
32
|
|
27
33
|
# get node
|
28
|
-
Chef::Config.from_file(opts[:config])
|
29
34
|
host = Chef::Config[:node_name] || ohai[:fqdn] || ohai[:hostname]
|
30
35
|
client = Chef::REST.new(Chef::Config[:chef_server_url], host, Chef::Config[:client_key])
|
31
36
|
node = client.get_rest("nodes/#{host}")
|
@@ -36,4 +41,12 @@ ohai.data.keys.each { |key| node.automatic_attrs[key] = ohai.data[key] }
|
|
36
41
|
node.set[:collect_agent][:flag] = "collect_agent"
|
37
42
|
|
38
43
|
# post node
|
39
|
-
client.put_rest("nodes/#{host}", node)
|
44
|
+
client.put_rest("nodes/#{host}", node)
|
45
|
+
|
46
|
+
# upload plugins
|
47
|
+
cookbook = client.get_rest("cookbooks/#{opts[:cookbook]}/latest")
|
48
|
+
cookbook.to_hash['files'].each do |file|
|
49
|
+
dest = file['path'].gsub(opts[:cookbook_path], opts[:plugins])
|
50
|
+
tempfile = client.get_rest(file['url'], true)
|
51
|
+
FileUtils.mv(tempfile.path, dest)
|
52
|
+
end
|
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.9
|
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-
|
12
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|