chef-handler-users 0.0.2

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/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ # gem "rails"
5
+
6
+ gem "rake"
data/Gemfile.lock ADDED
@@ -0,0 +1,10 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ rake (10.0.2)
5
+
6
+ PLATFORMS
7
+ ruby
8
+
9
+ DEPENDENCIES
10
+ rake
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ chef-handler-users
2
+ ==================
3
+
4
+ A Chef Handler to report changes in users
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'bundler/gem_tasks'
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "chef-handler-users"
6
+ gem.version = "0.0.2"
7
+ gem.authors = ["Heavy Water Operations, LLC. (OR)"]
8
+ gem.email = ["ops@hw-ops.com"]
9
+ gem.homepage = "http://github.com/heavywater/chef-handler-users"
10
+ gem.summary = "Chef Handler to report changes in users"
11
+ gem.description = "Chef Handler to report changes in users"
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ gem.require_paths = ["lib"]
16
+
17
+ gem.add_development_dependency "rake"
18
+ end
@@ -0,0 +1,52 @@
1
+ # Author:: AJ Christensen <aj@hw-ops.com>
2
+ # Copyright:: 2012, Heavy Water Operations, LLC (OR)
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
14
+ #implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'rubygems'
20
+ require 'chef/handler'
21
+ # require 'pony'
22
+
23
+ class Chef::Handler::Users < Chef::Handler
24
+ attr_reader :config
25
+ def initialize(config={})
26
+ @config = config
27
+ @config[:path] ||= "/var/chef/reports/users"
28
+ @config
29
+ end
30
+
31
+ def report
32
+ build_report_dir
33
+ savetime = Time.now.strftime("%Y%m%d%H%M%S")
34
+
35
+ updated_users = run_status.updated_resources.inject([]) do |updated_users, resource|
36
+ updated_users << resource if resource.resource_name =~ /user/i
37
+ updated_users
38
+ end
39
+
40
+ File.open(File.join(config[:path], "chef-run-report-#{savetime}.json"), "w") do |file|
41
+ file.puts Chef::JSONCompat.to_json_pretty(updated_users)
42
+ end
43
+ end
44
+
45
+ def build_report_dir
46
+ unless File.exists?(config[:path])
47
+ FileUtils.mkdir_p(config[:path])
48
+ File.chmod(00700, config[:path])
49
+ end
50
+ end
51
+
52
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-handler-users
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Heavy Water Operations, LLC. (OR)
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Chef Handler to report changes in users
31
+ email:
32
+ - ops@hw-ops.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - Gemfile.lock
40
+ - README.md
41
+ - Rakefile
42
+ - chef-handler-users.gemspec
43
+ - lib/chef-handler-users.rb
44
+ homepage: http://github.com/heavywater/chef-handler-users
45
+ licenses: []
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.24
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Chef Handler to report changes in users
68
+ test_files: []