ronin-wrapper 0.0.9 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c3c00f54efdb0caece795e59b3647d555f25ea3
4
- data.tar.gz: 8cb9cae2f49b2bc0453e32fefdc5f649f34dac24
3
+ metadata.gz: 11143e25ba860d375511daa655d3bce4518e78b4
4
+ data.tar.gz: 3bd2050c5d6cd7250518d2de9ddb542fc08a26fa
5
5
  SHA512:
6
- metadata.gz: 2f1fb190ffc1853a1341fcc19741b563898e82691c493b3c222d5713e9e3bece065c7d04204fc9212d6719ae43a512f6eff06ae5c8cdc19ed8d31f32221f5cc1
7
- data.tar.gz: 7e4bcdf75d4b40262809e7958a2f7a0fc7e10bdd37d44cd3b24ba47b8bd57d1c4ae700d43278d89d3db293c43192d47789633762f7aa3532e2c2967cae15bb03
6
+ metadata.gz: b280ea075de35614afea3a9cfd4b3b516794bc43660abb34fa86312cf251c6db736e8ce08c90c3ab84f6ca4c8c2bb6d2629b1f22012a44be37a41799d275e71d
7
+ data.tar.gz: 01a7f99f884aabff11e0c181bd244b9cc080b6dce87a3bbed926f17e0fe92dc6af448dfc4878071cff758475d359105607f73740ab8ce17c2686eb7b2464e684
data/bin/ronin CHANGED
@@ -14,11 +14,12 @@
14
14
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
- require 'ronin'
18
17
 
19
18
  unless Process.uid == 0
20
19
  puts 'You need to be root to perform this command.'
21
20
  exit 1
22
21
  end
23
22
 
23
+ require 'ronin'
24
+
24
25
  Ronin.run
data/lib/ronin/chef.rb CHANGED
@@ -47,7 +47,7 @@ module Ronin
47
47
  self.create_run_list
48
48
  self.create_solo_conf
49
49
  Ronin::Log.info("Running Chef, logging to #{Ronin::Config[:log_path]}/ronin-chef.log.")
50
- @cmd = Mixlib::ShellOut.new("chef-solo --logfile #{Ronin::Config[:log_path]}/ronin-chef.log --config #{@solo_conf} --json-attributes #{@run_list}")
50
+ @cmd = Mixlib::ShellOut.new("#{$CHEFSOLO_BIN} --logfile #{Ronin::Config[:log_path]}/ronin-chef.log --config #{@solo_conf} --json-attributes #{@run_list}")
51
51
  @cmd.run_command
52
52
  self.clean_up
53
53
  end
data/lib/ronin/config.rb CHANGED
@@ -28,13 +28,17 @@ module Ronin
28
28
  end
29
29
 
30
30
  config_strict_mode true
31
+ default :lock_file, '/var/tmp/ronin.lock'
31
32
  default :log_path, '/var/log/ronin'
32
33
  default :log_level, :info
33
34
  default :update_on_change, true
34
- default :run_list_type, :yaml
35
35
  default :interpreter, :puppet
36
- default :run_list_file, '/etc/ronin/artifacts.yaml'
37
36
  default :artifact_path, '/var/lib/ronin/artifacts'
37
+ default :run_list_type, :yaml
38
+ default :run_list_file, '/etc/ronin/artifacts.yaml'
39
+ default :etcd_host, '127.0.0.1'
40
+ default :etcd_port, 4001
41
+
38
42
  end
39
43
  end
40
44
 
data/lib/ronin/etcd.rb ADDED
@@ -0,0 +1,44 @@
1
+ # Author:: Nathan Milford (<nathan@milford.io>)
2
+ # Copyright:: Copyright (c) 2013 Nathan Milford
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ require 'mixlib/config'
17
+ require 'net/https'
18
+ require 'net/http'
19
+ require 'socket'
20
+ require 'json'
21
+
22
+ # Add test data thus.
23
+ #curl -L http://127.0.0.1:4001/v2/keys/ronin/run_lists/localhost.localdomain -X PUT -d value='{
24
+ # "run_list": [
25
+ # "https://github.com/opscode-cookbooks/motd-tail"
26
+ # ]
27
+ #}'
28
+
29
+ module Ronin
30
+ module Etcd
31
+ def get_run_list
32
+ # Will add error handling... one day.
33
+ @hostname = Socket.gethostname
34
+ @path = "/v2/keys/ronin/run_lists/#{@hostname}"
35
+ @http = Net::HTTP.new(Ronin::Config['etcd_host'], Ronin::Config['etcd_port'])
36
+ @http.use_ssl = false
37
+ @request = Net::HTTP::Get.new(@path)
38
+ @result = @http.request(@request)
39
+ @raw = JSON.parse(@result.body)['node']['value']
40
+ return JSON.parse(@raw)['run_list']
41
+ end
42
+ module_function :get_run_list
43
+ end
44
+ end
data/lib/ronin/git.rb CHANGED
@@ -19,7 +19,7 @@ require 'ronin/config'
19
19
  module Ronin
20
20
  module Git
21
21
  def branch(artifact)
22
- @cmd = Mixlib::ShellOut.new("git --git-dir=#{Ronin::Config[:artifact_path]}/#{artifact}/.git --work-tree=#{Ronin::Config[:artifact_path]}/#{artifact}/ branch")
22
+ @cmd = Mixlib::ShellOut.new("#{$GIT_BIN} --git-dir=#{Ronin::Config[:artifact_path]}/#{artifact}/.git --work-tree=#{Ronin::Config[:artifact_path]}/#{artifact}/ branch")
23
23
  @cmd.run_command
24
24
  @branch = @cmd.stdout.chomp.split(' ')[1]
25
25
  @branch
data/lib/ronin/puppet.rb CHANGED
@@ -37,7 +37,7 @@ module Ronin
37
37
  def run
38
38
  self.create_run_list
39
39
  Ronin::Log.info("Running Puppet, logging to #{Ronin::Config[:log_path]}/ronin-puppet.log.")
40
- @cmd = Mixlib::ShellOut.new("puppet apply --verbose --ordering manifest --logdest #{Ronin::Config[:log_path]}/ronin-puppet.log --modulepath #{Ronin::Config[:artifact_path]} #{@run_list}")
40
+ @cmd = Mixlib::ShellOut.new("#{$PUPPET_BIN} apply --verbose --ordering manifest --logdest #{Ronin::Config[:log_path]}/ronin-puppet.log --modulepath #{Ronin::Config[:artifact_path]} #{@run_list}")
41
41
  @cmd.run_command
42
42
  self.clean_up
43
43
  end
data/lib/ronin/ronin.rb CHANGED
@@ -17,24 +17,51 @@ $LOAD_PATH << "."
17
17
  require 'ronin/artifact_runner'
18
18
  require 'ronin/run_list'
19
19
  require 'ronin/config'
20
+ require 'ronin/util'
21
+ require 'ronin/log'
20
22
 
21
23
  module Ronin
22
24
  def run
23
25
 
24
26
  Ronin::Log.level = Ronin::Config[:log_level]
25
27
 
26
- puts Ronin::Config[:interpreter].inspect
28
+ if Ronin::Util.find_cmd("git").nil?
29
+ abort("You need to have git installed to perform this command.")
30
+ else
31
+ $GIT_BIN = Ronin::Util.find_cmd("git")
32
+ end
33
+
34
+ if Ronin::Util.find_cmd("puppet").nil? and Ronin::Config[:interpreter] == :puppet
35
+ abort("You need to have Puppet installed to perform this command with Puppet set as the interpreter.")
36
+ else
37
+ $PUPPET_BIN = Ronin::Util.find_cmd("puppet")
38
+ end
39
+
40
+ if Ronin::Util.find_cmd("chef-solo").nil? and Ronin::Config[:interpreter] == :puppet
41
+ abort("You need to have Chef-Solo installed to perform this command with Chef set as the interpreter.")
42
+ else
43
+ $CHEFSOLO_BIN = Ronin::Util.find_cmd("puppet")
44
+ end
45
+
46
+ unless File.exists?(Ronin::Config[:lock_file])
47
+ Ronin::Log.info("Dropping lock file. (#{Ronin::Config[:lock_file]})")
48
+ File.new(Ronin::Config[:lock_file], "w")
27
49
 
28
- @r = Ronin::ArtifactRunner.new
29
- @changes = @r.download_and_report_changes
30
- @r.purge_unused
50
+ @r = Ronin::ArtifactRunner.new
51
+ @changes = @r.download_and_report_changes
52
+ @r.purge_unused
31
53
 
32
- if @changes
33
- if Ronin::Config[:interpreter] == :puppet
34
- Ronin::Puppet.run
35
- elsif Ronin::Config[:interpreter] == :chef
36
- Ronin::Chef.run
54
+ if @changes
55
+ if Ronin::Config[:interpreter] == :puppet
56
+ Ronin::Puppet.run
57
+ elsif Ronin::Config[:interpreter] == :chef
58
+ Ronin::Chef.run
59
+ end
37
60
  end
61
+ Ronin::Log.info("Deleting lock file and exiting. (#{Ronin::Config[:lock_file]})")
62
+ File.delete(Ronin::Config[:lock_file])
63
+ else
64
+ abort("Lock file (#{Ronin::Config[:lock_file]}) exists! Check to see if this Ronin is already running. Exiting.")
38
65
  end
39
66
  end
40
67
  module_function :run
@@ -14,6 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  require 'mixlib/config'
17
+ require 'ronin/etcd'
17
18
  require 'yaml'
18
19
 
19
20
  module Ronin
@@ -22,16 +23,18 @@ module Ronin
22
23
 
23
24
  def initialize
24
25
  @run_list = {}
25
- if Ronin::Config['run_list_type'] = :yaml
26
- @modules_raw = YAML.load_file(Ronin::Config['run_list_file'])['artifacts']
26
+ if Ronin::Config[:run_list_type] == :yaml
27
+ @artifacts_raw = YAML.load_file(Ronin::Config['run_list_file'])['artifacts']
28
+ elsif Ronin::Config[:run_list_type] == :etcd
29
+ @artifacts_raw = Ronin::Etcd.get_run_list
27
30
  end
28
31
 
29
- @modules_raw.each do |m|
30
- if m.include?(";")
31
- @repo = m.split(";")[0].sub(/(\/)+$/,'')
32
- @branch = m.split(";")[1]
32
+ @artifacts_raw.each do |a|
33
+ if a.include?(";")
34
+ @repo = a.split(";")[0].sub(/(\/)+$/,'')
35
+ @branch = a.split(";")[1]
33
36
  else
34
- @repo = m
37
+ @repo = a
35
38
  @branch = 'master'
36
39
  end
37
40
 
@@ -44,9 +47,9 @@ module Ronin
44
47
  end
45
48
 
46
49
  def artifacts
47
- @mods = []
48
- @run_list.each { |k,v| @mods << k }
49
- @mods
50
+ @arts = []
51
+ @run_list.each { |k,v| @arts << k }
52
+ @arts
50
53
  end
51
54
 
52
55
  def items
data/lib/ronin/util.rb ADDED
@@ -0,0 +1,30 @@
1
+ # Author:: Nathan Milford (<nathan@milford.io>)
2
+ # Copyright:: Copyright (c) 2013 Nathan Milford
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ module Ronin
18
+ module Util
19
+
20
+ def find_cmd(cmd)
21
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
22
+ cmd_path = File.join(path, cmd)
23
+ return cmd_path if File.executable? cmd_path
24
+ end
25
+ return nil
26
+ end
27
+ module_function :find_cmd
28
+
29
+ end
30
+ end
data/lib/ronin/version.rb CHANGED
@@ -14,5 +14,5 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
  module Ronin
17
- VERSION = '0.0.9'
17
+ VERSION = '0.0.11'
18
18
  end
data/lib/ronin.rb CHANGED
@@ -13,12 +13,14 @@
13
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
+ require 'ronin/ronin'
16
17
  require 'ronin/config'
17
18
  require 'ronin/artifact_runner'
18
19
  require 'ronin/run_list'
19
20
  require 'ronin/version'
20
21
  require 'ronin/puppet'
21
- require 'ronin/ronin'
22
22
  require 'ronin/chef'
23
23
  require 'ronin/git'
24
24
  require 'ronin/log'
25
+ require 'ronin/etcd'
26
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Milford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-27 00:00:00.000000000 Z
11
+ date: 2013-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby
@@ -91,11 +91,13 @@ extra_rdoc_files:
91
91
  files:
92
92
  - lib/ronin.rb
93
93
  - lib/ronin/ronin.rb
94
+ - lib/ronin/util.rb
94
95
  - lib/ronin/config.rb
95
96
  - lib/ronin/puppet.rb
96
97
  - lib/ronin/chef.rb
97
98
  - lib/ronin/git.rb
98
99
  - lib/ronin/log.rb
100
+ - lib/ronin/etcd.rb
99
101
  - lib/ronin/artifact_runner.rb
100
102
  - lib/ronin/run_list.rb
101
103
  - lib/ronin/version.rb