chef-formatters-simple 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c6b2b11bc6d9144438ab437e4a0d4b4079b43285
4
+ data.tar.gz: 4909f78fd17c715ecce63a18f47d3e43b0eadb7d
5
+ SHA512:
6
+ metadata.gz: bcf4e1151a5fecb3b6573c87fd4754e51e58c15cd4f64e2fb55fb4818591290ee606c2d6bb706ea87d1382b4e3fc743c9b82fdda397d965f134341d9b57f3745
7
+ data.tar.gz: ed5f8c56ed1247e77ddcf275f97f5ae3b06b293c1dc23dbde74a0ce08c4f3d58bfed85ac3d29f71bd985c0f6e0ab4c8f15e53337036c8a14bc60d1280b080fa1
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chef-formatters-simple.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 sakazuki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Chef::Formatters::Simple
2
+
3
+ chef-client simple formatter
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'chef-formatters-simple'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install chef-formatters-simple
20
+
21
+ ## Usage
22
+
23
+ Add below in /etc/chef/client.rb:
24
+
25
+ ```
26
+ require 'chef/formatters/simple'
27
+ ```
28
+
29
+ Use chef-client with -F or --format option
30
+
31
+ ```bash
32
+ chef-client -F simple -W
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/[my-github-username]/chef-formatters-simple/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chef/formatters/simple/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "chef-formatters-simple"
8
+ spec.version = Chef::Formatters::Simple::VERSION
9
+ spec.authors = ["sakazuki"]
10
+ spec.email = ["sakazuki@gmail.com"]
11
+ spec.summary = %q{chef-client simple formatter}
12
+ spec.description = %q{chef-client simple formatter outputs that minimal's output plus delta}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,271 @@
1
+ require "chef/formatters/simple/version"
2
+ require "chef/formatters/base"
3
+
4
+ class Chef
5
+
6
+ module Formatters
7
+
8
+
9
+ # == Formatters::Simple
10
+ # Shows the progress of the chef run by printing single characters, and
11
+ # displays a summary of updates at the conclusion of the run. For events
12
+ # that don't have meaningful status information (loading a file, syncing a
13
+ # cookbook) a dot is printed. For resources, a dot, 'S' or 'U' is printed
14
+ # if the resource is up to date, skipped by not_if/only_if, or updated,
15
+ # respectively.
16
+ class Simple < Formatters::Base
17
+
18
+ cli_name(:simple)
19
+
20
+ attr_reader :updated_resources
21
+ attr_reader :updates_by_resource
22
+
23
+
24
+ def initialize(out, err)
25
+ super
26
+ @updated_resources = []
27
+ @updates_by_resource = Hash.new {|h, k| h[k] = []}
28
+ end
29
+
30
+ # Called at the very start of a Chef Run
31
+ def run_start(version)
32
+ puts "Starting Chef Client, version #{version}"
33
+ end
34
+
35
+ # Called at the end of the Chef run.
36
+ def run_completed(node)
37
+ puts "chef client finished, #{@updated_resources.size} resources updated"
38
+ end
39
+
40
+ # called at the end of a failed run
41
+ def run_failed(exception)
42
+ puts "chef client failed. #{@updated_resources.size} resources updated"
43
+ end
44
+
45
+ # Called right after ohai runs.
46
+ def ohai_completed(node)
47
+ end
48
+
49
+ # Already have a client key, assuming this node has registered.
50
+ def skipping_registration(node_name, config)
51
+ end
52
+
53
+ # About to attempt to register as +node_name+
54
+ def registration_start(node_name, config)
55
+ end
56
+
57
+ def registration_completed
58
+ end
59
+
60
+ # Failed to register this client with the server.
61
+ def registration_failed(node_name, exception, config)
62
+ super
63
+ end
64
+
65
+ def node_load_start(node_name, config)
66
+ end
67
+
68
+ # Failed to load node data from the server
69
+ def node_load_failed(node_name, exception, config)
70
+ end
71
+
72
+ # Default and override attrs from roles have been computed, but not yet applied.
73
+ # Normal attrs from JSON have been added to the node.
74
+ def node_load_completed(node, expanded_run_list, config)
75
+ end
76
+
77
+ # Called before the cookbook collection is fetched from the server.
78
+ def cookbook_resolution_start(expanded_run_list)
79
+ puts "resolving cookbooks for run list: #{expanded_run_list.inspect}"
80
+ end
81
+
82
+ # Called when there is an error getting the cookbook collection from the
83
+ # server.
84
+ def cookbook_resolution_failed(expanded_run_list, exception)
85
+ end
86
+
87
+ # Called when the cookbook collection is returned from the server.
88
+ def cookbook_resolution_complete(cookbook_collection)
89
+ end
90
+
91
+ # Called before unneeded cookbooks are removed
92
+ #--
93
+ # TODO: Should be called in CookbookVersion.sync_cookbooks
94
+ def cookbook_clean_start
95
+ end
96
+
97
+ # Called after the file at +path+ is removed. It may be removed if the
98
+ # cookbook containing it was removed from the run list, or if the file was
99
+ # removed from the cookbook.
100
+ def removed_cookbook_file(path)
101
+ end
102
+
103
+ # Called when cookbook cleaning is finished.
104
+ def cookbook_clean_complete
105
+ end
106
+
107
+ # Called before cookbook sync starts
108
+ def cookbook_sync_start(cookbook_count)
109
+ puts "Synchronizing cookbooks"
110
+ end
111
+
112
+ # Called when cookbook +cookbook_name+ has been sync'd
113
+ def synchronized_cookbook(cookbook_name)
114
+ print "."
115
+ end
116
+
117
+ # Called when an individual file in a cookbook has been updated
118
+ def updated_cookbook_file(cookbook_name, path)
119
+ end
120
+
121
+ # Called after all cookbooks have been sync'd.
122
+ def cookbook_sync_complete
123
+ puts "done."
124
+ end
125
+
126
+ # Called when cookbook loading starts.
127
+ def library_load_start(file_count)
128
+ puts "Compiling cookbooks"
129
+ end
130
+
131
+ # Called after a file in a cookbook is loaded.
132
+ def file_loaded(path)
133
+ print '.'
134
+ end
135
+
136
+ def file_load_failed(path, exception)
137
+ super
138
+ end
139
+
140
+ # Called when recipes have been loaded.
141
+ def recipe_load_complete
142
+ puts "done."
143
+ end
144
+
145
+ # Called before convergence starts
146
+ def converge_start(run_context)
147
+ puts "Converging #{run_context.resource_collection.all_resources.size} resources"
148
+ end
149
+
150
+ # Called when the converge phase is finished.
151
+ def converge_complete
152
+ prefix = Chef::Config[:why_run] ? "Would " : ""
153
+ puts "\n"
154
+ puts "System converged."
155
+ if updated_resources.empty?
156
+ puts "no resources updated"
157
+ else
158
+ puts "\n"
159
+ puts "resources updated this run:"
160
+ updated_resources.each do |resource|
161
+ if resource.cookbook_name && resource.recipe_name
162
+ resource_recipe = "#{resource.cookbook_name}::#{resource.recipe_name}"
163
+ else
164
+ resource_recipe = "<Dynamically Defined Resource>"
165
+ end
166
+ if resource_recipe != @current_recipe && !resource.enclosing_provider
167
+ unindent if @current_recipe
168
+ puts_line "Recipe: #{resource_recipe}"
169
+ @current_recipe = resource_recipe
170
+ indent
171
+ end
172
+ puts "* #{resource.to_s}"
173
+ updates_by_resource[resource.name].each do |update|
174
+ Array(update).each do |line|
175
+ next if line.nil?
176
+ output_record line
177
+ if line.kind_of? String
178
+ start_line "- #{prefix}#{line}", :green
179
+ elsif line.kind_of? Array
180
+ # Expanded output - delta
181
+ # @todo should we have a resource_update_delta callback?
182
+ indent
183
+ line.each do |detail|
184
+ start_line detail, :white
185
+ end
186
+ unindent
187
+ end
188
+ end
189
+ end
190
+ puts "\n"
191
+ end
192
+ end
193
+ end
194
+
195
+ def output_record(line)
196
+ end
197
+
198
+ # Called before action is executed on a resource.
199
+ def resource_action_start(resource, action, notification_type=nil, notifier=nil)
200
+ end
201
+
202
+ # Called when a resource fails, but will retry.
203
+ def resource_failed_retriable(resource, action, retry_count, exception)
204
+ end
205
+
206
+ # Called when a resource fails and will not be retried.
207
+ def resource_failed(resource, action, exception)
208
+ end
209
+
210
+ # Called when a resource action has been skipped b/c of a conditional
211
+ def resource_skipped(resource, action, conditional)
212
+ print "S"
213
+ end
214
+
215
+ # Called after #load_current_resource has run.
216
+ def resource_current_state_loaded(resource, action, current_resource)
217
+ end
218
+
219
+ # Called when a resource has no converge actions, e.g., it was already correct.
220
+ def resource_up_to_date(resource, action)
221
+ print "."
222
+ end
223
+
224
+ ## TODO: callback for assertion failures
225
+
226
+ ## TODO: callback for assertion fallback in why run
227
+
228
+ # Called when a change has been made to a resource. May be called multiple
229
+ # times per resource, e.g., a file may have its content updated, and then
230
+ # its permissions updated.
231
+ def resource_update_applied(resource, action, update)
232
+ @updates_by_resource[resource.name] << Array(update) #[0]
233
+ end
234
+
235
+ # Called after a resource has been completely converged.
236
+ def resource_updated(resource, action)
237
+ updated_resources << resource
238
+ print "U"
239
+ end
240
+
241
+ # Called before handlers run
242
+ def handlers_start(handler_count)
243
+ end
244
+
245
+ # Called after an individual handler has run
246
+ def handler_executed(handler)
247
+ end
248
+
249
+ # Called after all handlers have executed
250
+ def handlers_completed
251
+ end
252
+
253
+ # An uncategorized message. This supports the case that a user needs to
254
+ # pass output that doesn't fit into one of the callbacks above. Note that
255
+ # there's no semantic information about the content or importance of the
256
+ # message. That means that if you're using this too often, you should add a
257
+ # callback for it.
258
+ def msg(message)
259
+ end
260
+
261
+ def indent
262
+ indent_by(2)
263
+ end
264
+
265
+ def unindent
266
+ indent_by(-2)
267
+ end
268
+
269
+ end
270
+ end
271
+ end
@@ -0,0 +1,7 @@
1
+ module Chef
2
+ module Formatters
3
+ module Simple
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-formatters-simple
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - sakazuki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: chef-client simple formatter outputs that minimal's output plus delta
42
+ email:
43
+ - sakazuki@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - chef-formatters-simple.gemspec
54
+ - lib/chef/formatters/simple.rb
55
+ - lib/chef/formatters/simple/version.rb
56
+ homepage: ''
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.1
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: chef-client simple formatter
80
+ test_files: []