small-ops 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/etcd2conf +10 -2
- metadata +1 -3
- data/bin/rsyslog2logstash +0 -41
data/bin/etcd2conf
CHANGED
|
@@ -21,12 +21,15 @@ OptionParser.new do |opts|
|
|
|
21
21
|
opts.on("-i","--input file","Input file") do |o|
|
|
22
22
|
@options[:input]=o
|
|
23
23
|
end
|
|
24
|
+
opts.on("-s","--string template","Template as string") do |s|
|
|
25
|
+
@options[:template] = s
|
|
26
|
+
end
|
|
24
27
|
opts.on("-c","--command cmd","A command to execute after each run") do |c|
|
|
25
28
|
@options[:cmd]=c
|
|
26
29
|
end
|
|
27
30
|
end.parse!
|
|
28
31
|
|
|
29
|
-
if !@options[:input] || !@options[:output] then
|
|
32
|
+
if ( !@options[:input] && !@options[:template] ) || !@options[:output] then
|
|
30
33
|
raise "Need input and output!"
|
|
31
34
|
end
|
|
32
35
|
|
|
@@ -49,7 +52,12 @@ while run do
|
|
|
49
52
|
|
|
50
53
|
data = nodes2obj(r["node"]["nodes"],"/")
|
|
51
54
|
|
|
52
|
-
template =
|
|
55
|
+
template = ""
|
|
56
|
+
if @options[:input] then
|
|
57
|
+
template = File.read(@options[:input])
|
|
58
|
+
elsif @options[:template]
|
|
59
|
+
template = @options[:template]
|
|
60
|
+
end
|
|
53
61
|
|
|
54
62
|
ns = Namespace.new(data,{"host"=>@options[:host]})
|
|
55
63
|
result=ERB.new(template).result(ns.get_binding)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: small-ops
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.22
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -18,7 +18,6 @@ executables:
|
|
|
18
18
|
- etcd2env
|
|
19
19
|
- etcd2conf
|
|
20
20
|
- fige
|
|
21
|
-
- rsyslog2logstash
|
|
22
21
|
extensions: []
|
|
23
22
|
extra_rdoc_files: []
|
|
24
23
|
files:
|
|
@@ -27,7 +26,6 @@ files:
|
|
|
27
26
|
- bin/etcd2env
|
|
28
27
|
- bin/etcd2conf
|
|
29
28
|
- bin/fige
|
|
30
|
-
- bin/rsyslog2logstash
|
|
31
29
|
homepage: https://github.com/
|
|
32
30
|
licenses:
|
|
33
31
|
- MIT
|
data/bin/rsyslog2logstash
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'small-setup'
|
|
4
|
-
|
|
5
|
-
OptionParser.new do |opts|
|
|
6
|
-
opts.banner = "Usage: command [options]"
|
|
7
|
-
opts.on("-h", "--host host", "Set host IP/domain") do |h|
|
|
8
|
-
@options[:host] = h
|
|
9
|
-
end
|
|
10
|
-
opts.on("-e", "--etcd host:port", "Set etcd host and port") do |e|
|
|
11
|
-
@options[:etcd] = e
|
|
12
|
-
end
|
|
13
|
-
opts.on("-t", "--target container", "Set container to use with logstash") do |t|
|
|
14
|
-
@options[:target] = t
|
|
15
|
-
end
|
|
16
|
-
opts.on("-l", "--logstash host:port", "Set host:port where is logstash") do |l|
|
|
17
|
-
@options[:logstash] = l
|
|
18
|
-
end
|
|
19
|
-
opts.on("-f","--foreground","Keep running on foregroud. Default is run once and exit.") do |f|
|
|
20
|
-
@options[:foreground]=f
|
|
21
|
-
end
|
|
22
|
-
end.parse!
|
|
23
|
-
|
|
24
|
-
logstash=""
|
|
25
|
-
if @options[:logstash] then
|
|
26
|
-
logstash=@options[:logstash]
|
|
27
|
-
else
|
|
28
|
-
target=@options[:target] || "logstash"
|
|
29
|
-
data = http_get("#{@options[:etcd]}/v2/keys/#{target}/networksettings?recursive=true")
|
|
30
|
-
final = eflatten( data["node"] )
|
|
31
|
-
logstash = "#{final["#{target}_networksettings_ipaddress"]}:9514"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
File.open("/etc/rsyslog.d/50-logstash.conf", 'w') { |file| file.write("*.* @@#{logstash}") }
|
|
35
|
-
|
|
36
|
-
if @options[:foreground] then
|
|
37
|
-
while true
|
|
38
|
-
sleep 100
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|