chef-silent 0.0.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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea/*
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'chef'
4
+
5
+ # Specify your gem's dependencies in chef-silent.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Vasiliev Dmitry
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Chef::Silent
2
+
3
+ Make chef silent
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'chef-silent'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install chef-silent
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ require 'chef-silent'
23
+ ```
24
+
25
+ in client.rb
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chef/silent/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "chef-silent"
8
+ spec.version = Chef::Silent::VERSION
9
+ spec.authors = ["Vasiliev Dmitry"]
10
+ spec.email = ["vadv.mkn@gmail.com"]
11
+ spec.description = %q{Silent formatters for chef-client}
12
+ spec.summary = %q{Make chef-client silent}
13
+ spec.homepage = "https://github.com/vadv/chef-silent"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency('chef')
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'silent/silent_formatters'
2
+ require_relative 'silent/monkey_patches'
@@ -0,0 +1,38 @@
1
+ module ColorDiff
2
+
3
+ FILE_IN_R = /^\-\-\- /
4
+ FILE_OUT_R = /^\+\+\+ /
5
+ OUT_R = /^\-/
6
+ IN_R = /^\+/
7
+
8
+ $RESET = "\033[0m"
9
+ $BOLD = "\033[1m"
10
+ $BLINK = "\033[5m"
11
+
12
+ $BLACK = "\033[30m"
13
+ $RED = "\033[31m"
14
+ $GREEN = "\033[32m"
15
+ $BROWN = "\033[33m"
16
+ $BLUE = "\033[34m"
17
+ $MAGENTA = "\033[35m"
18
+ $CYAN = "\033[36m"
19
+ $WHITE = "\033[37m"
20
+
21
+ def self.print_diff(array)
22
+ array.each do |line|
23
+ line.chomp!
24
+ if line =~ FILE_IN_R
25
+ puts "#{$MAGENTA}" + line + "#{$RESET}"
26
+ elsif line =~ FILE_OUT_R
27
+ puts "#{$BLUE}" + line + "#{$RESET}"
28
+ elsif line =~ OUT_R
29
+ puts "#{$RED}" + line + "#{$RESET}"
30
+ elsif line =~ IN_R
31
+ puts "#{$GREEN}" + line + "#{$RESET}"
32
+ else
33
+ puts line
34
+ end
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,19 @@
1
+ require 'chef/resource'
2
+
3
+ class Chef::Resource::Notification
4
+
5
+ def load_prior_resource
6
+ begin
7
+ prior_resource = run_context.resource_collection.lookup(self.to_s)
8
+ prior_resource.instance_variables.each do |iv|
9
+ unless iv.to_sym == :@source_line || iv.to_sym == :@action || iv.to_sym == :@not_if || iv.to_sym == :@only_if
10
+ self.instance_variable_set(iv, prior_resource.instance_variable_get(iv))
11
+ end
12
+ end
13
+ true
14
+ rescue Chef::Exceptions::ResourceNotFound
15
+ true
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,124 @@
1
+ require 'chef/formatters/minimal'
2
+ require_relative 'color_diff'
3
+
4
+ class Chef
5
+ module Formatters
6
+ class Silent < Formatters::Minimal
7
+
8
+ cli_name(:silent)
9
+ cli_name(:undev)
10
+
11
+ def run_start(version)
12
+ puts "Starting Chef Client, version #{version}"
13
+ end
14
+
15
+ def run_completed(node)
16
+ puts "Chef client finished, #{@updated_resources.size} resources updated"
17
+ end
18
+
19
+ def run_failed(exception)
20
+ puts "Chef client failed. #{@updated_resources.size} resources updated"
21
+ end
22
+
23
+ def cookbook_resolution_start(expanded_run_list)
24
+ puts "Resolving cookbooks for run list: #{expanded_run_list.inspect}"
25
+ end
26
+
27
+ def cookbook_sync_start(cookbook_count)
28
+ puts "Synchronizing cookbooks"
29
+ end
30
+
31
+ def synchronized_cookbook(cookbook_name)
32
+ ;
33
+ end
34
+
35
+ def cookbook_sync_complete
36
+ ;
37
+ end
38
+
39
+ def library_load_start(file_count)
40
+ ;
41
+ end
42
+
43
+ def file_loaded(path)
44
+ ;
45
+ end
46
+
47
+ def recipe_load_complete;
48
+ end
49
+
50
+ def converge_start(run_context)
51
+ ;
52
+ end
53
+
54
+ def converge_complete;
55
+ end
56
+
57
+ def resource_skipped(resource, action, conditional)
58
+ ;
59
+ end
60
+
61
+ def resource_up_to_date(resource, action)
62
+ ;
63
+ end
64
+
65
+ def msg(message)
66
+ ;
67
+ end
68
+
69
+ def resource_update_applied(resource, action, update)
70
+ @updates_by_resource[resource.name] << Array(update)[0]
71
+ end
72
+
73
+ def resource_updated(resource, action)
74
+ if resource.class == Chef::Resource::File
75
+ if resource.diff
76
+ print "Modify #{resource.name} :\n"
77
+ ColorDiff.print_diff resource.diff.split('\n')
78
+ print "\n"
79
+ end
80
+ end
81
+ end
82
+
83
+ def display_error(description)
84
+ puts("")
85
+ description.display(output)
86
+ end
87
+
88
+ #
89
+ # Очень хотим красивые fail
90
+ #
91
+
92
+ def registration_failed(node_name, exception, config)
93
+ description = ErrorMapper.registration_failed(node_name, exception, config)
94
+ display_error(description)
95
+ end
96
+
97
+ def node_load_failed(node_name, exception, config)
98
+ description = ErrorMapper.node_load_failed(node_name, exception, config)
99
+ display_error(description)
100
+ end
101
+
102
+ def run_list_expand_failed(node, exception)
103
+ description = ErrorMapper.run_list_expand_failed(node, exception)
104
+ display_error(description)
105
+ end
106
+
107
+ def cookbook_resolution_failed(expanded_run_list, exception)
108
+ description = ErrorMapper.cookbook_resolution_failed(expanded_run_list, exception)
109
+ display_error(description)
110
+ end
111
+
112
+ def cookbook_sync_failed(cookbooks, exception)
113
+ description = ErrorMapper.cookbook_sync_failed(cookbooks, exception)
114
+ display_error(description)
115
+ end
116
+
117
+ def resource_failed(resource, action, exception)
118
+ description = ErrorMapper.resource_failed(resource, action, exception)
119
+ display_error(description)
120
+ end
121
+
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,5 @@
1
+ module Chef
2
+ module Silent
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-silent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Vasiliev Dmitry
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chef
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
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
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Silent formatters for chef-client
63
+ email:
64
+ - vadv.mkn@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - chef-silent.gemspec
75
+ - lib/chef/silent.rb
76
+ - lib/chef/silent/color_diff.rb
77
+ - lib/chef/silent/monkey_patches.rb
78
+ - lib/chef/silent/silent_formatters.rb
79
+ - lib/chef/silent/version.rb
80
+ homepage: https://github.com/vadv/chef-silent
81
+ licenses:
82
+ - MIT
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.23
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Make chef-client silent
105
+ test_files: []
106
+ has_rdoc: