chef-handler-s3 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. data/lib/chef/handler/s3.rb +22 -8
  2. metadata +10 -5
@@ -13,7 +13,7 @@ require 'aws-sdk'
13
13
  class Chef
14
14
  class Handler
15
15
  class S3 < ::Chef::Handler
16
- VERSION = '0.1.0'
16
+ VERSION = '0.1.1'
17
17
 
18
18
  attr_reader :config
19
19
 
@@ -53,8 +53,8 @@ class Chef
53
53
  run_data = Hash.new
54
54
  if run_status.failed?
55
55
  Chef::Log.error("Creating JSON exception report")
56
- run_data[:formatted_exception] = run_status.formatted_exception
57
- run_data[:exception] = run_status.exception
56
+ run_data[:formatted_exception] = run_status.formatted_exception.split("\n")
57
+ run_data[:exception] = run_status.exception.split("\n")
58
58
  run_data[:backtrace] = run_status.backtrace
59
59
  else
60
60
  Chef::Log.info("Creating JSON run report")
@@ -62,7 +62,11 @@ class Chef
62
62
 
63
63
  build_report_dir
64
64
 
65
- savetime = Time.now.strftime("%Y%m%d%H%M%S")
65
+ if node.include? :cloud
66
+ run_data[:ipaddress] = node.cloud.public_ipv4
67
+ else
68
+ run_data[:ipaddress] = node.ipaddress
69
+ end
66
70
  run_data[:name] = node.name
67
71
  run_data[:fqdn] = node.fqdn
68
72
  run_data[:success] = run_status.success?
@@ -79,12 +83,22 @@ class Chef
79
83
  }
80
84
  end
81
85
 
82
- if node.include? :cloud
83
- run_data[:ipaddress] = node.cloud.public_ipv4
84
- else
85
- run_data[:ipaddress] = node.ipaddress
86
+ # This need to be used carefully. The values of the passed has will be evaluated
87
+ # It is mean to be used at the resource as following example:
88
+ # chef_handler "Chef::Handler::S3" do
89
+ # source 'chef/handler/s3'
90
+ # arguments :extra_data => {
91
+ # 'iptables' => %{`iptables -L -n`.split("\n")},
92
+ # 'route' => %{`route -n`.split("\n")}
93
+ # }
94
+ # end
95
+ if @config.include? :extra_data and @config[:extra_data].is_a? Hash
96
+ @config[:extra_data].each do |k,v|
97
+ run_data[k] = eval v
98
+ end
86
99
  end
87
100
 
101
+ savetime = Time.now.strftime("%Y%m%d%H%M%S")
88
102
  file_path = File.join(config[:path], "#{node.name}-#{savetime}.json")
89
103
  File.open(file_path, "w") do |file|
90
104
  file.puts Chef::JSONCompat.to_json_pretty(run_data)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-handler-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- requirement: &87386120 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *87386120
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: Allows storing reports of Chef Exceptions to S3.
26
31
  email: juanje.ojeda@gmail.com
27
32
  executables: []
@@ -51,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
56
  version: '0'
52
57
  requirements: []
53
58
  rubyforge_project:
54
- rubygems_version: 1.8.10
59
+ rubygems_version: 1.8.24
55
60
  signing_key:
56
61
  specification_version: 3
57
62
  summary: Chef Exception & Reporting Handler for storing reports at S3