bourdain 1.2.22 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/bourdain/resources/checks/chef.rb +27 -0
- data/templates/chef/knife_plugin_node_log.rb +132 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8d327ccc2d235afadd7e841cb23debbd9b6cdf0
|
4
|
+
data.tar.gz: 9defb5a153dfb8ebbf13cd3182ee1556f231024f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 889ada00baee53f3e15d2a8b7b341a2fa39c8b52b6ea33eef57550883096c95e3b9a092002562deb7e3507dca059c0ddcfc5085d9e5bc37604297aef0f5be501
|
7
|
+
data.tar.gz: e8bd93f603d58e0d9b4e1181fa00f31c4fa5124ed486e3c40bc9921a8b1bc085856a7cc9c37d00a0076446be8bb697983a2101aa27bae059aedd670f4af15fde
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
|
1
4
|
module Bourdain
|
2
5
|
module Checks
|
3
6
|
|
@@ -12,11 +15,13 @@ module Bourdain
|
|
12
15
|
super []
|
13
16
|
return unless require_chef!
|
14
17
|
check_chef_repo!
|
18
|
+
install_knife_plugins!
|
15
19
|
end
|
16
20
|
|
17
21
|
|
18
22
|
|
19
23
|
private
|
24
|
+
|
20
25
|
def check_chef_repo!
|
21
26
|
# Check if we have an up-to-date copy of the Kitchen
|
22
27
|
if youre_dirty? '.'
|
@@ -30,6 +35,28 @@ module Bourdain
|
|
30
35
|
log.info "Your Kitchen looks up-to-date."
|
31
36
|
end
|
32
37
|
end
|
38
|
+
|
39
|
+
def install_knife_plugins!
|
40
|
+
plugin_glob = File.join \
|
41
|
+
gem_path('templates', 'chef'), 'knife_plugin_*.rb'
|
42
|
+
|
43
|
+
plugin_dir = File.join \
|
44
|
+
ENV['HOME'], '.chef', 'plugins', 'knife'
|
45
|
+
|
46
|
+
Dir[plugin_glob].each do |template_path|
|
47
|
+
plugin = File.basename template_path
|
48
|
+
plugin =~ /knife_plugin_(.*?).rb/
|
49
|
+
plugin_name = $1.sub('_', ' ')
|
50
|
+
|
51
|
+
FileUtils.mkdir_p plugin_dir
|
52
|
+
plugin_path = File.join plugin_dir, plugin
|
53
|
+
|
54
|
+
apply_template plugin_path, template: [ 'chef', plugin ]
|
55
|
+
|
56
|
+
log.info "Installed 'knife #{plugin_name}' plugin"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
33
60
|
end
|
34
61
|
end
|
35
62
|
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'chef/knife'
|
2
|
+
|
3
|
+
|
4
|
+
module Plugins
|
5
|
+
class NodeCookbooks < Chef::Knife
|
6
|
+
banner "knife node cookbooks NODE"
|
7
|
+
|
8
|
+
deps do
|
9
|
+
require 'chef/search/query'
|
10
|
+
require 'chef/knife/search'
|
11
|
+
require 'highline'
|
12
|
+
end
|
13
|
+
|
14
|
+
def h
|
15
|
+
@highline ||= HighLine.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
unless node_name = name_args.shift
|
20
|
+
ui.error 'Please specify a node'
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
|
24
|
+
searcher = Chef::Search::Query.new
|
25
|
+
result = searcher.search(:node, "name:#{node_name}")
|
26
|
+
node = result.first.first
|
27
|
+
|
28
|
+
if node.nil?
|
29
|
+
ui.error 'Could find the given node'
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
33
|
+
$stdout.sync = true
|
34
|
+
|
35
|
+
unless cookbook_versions = node['cookbook_versions']
|
36
|
+
ui.error 'No cookbooks to report'
|
37
|
+
exit 1
|
38
|
+
end
|
39
|
+
|
40
|
+
log_entries = [
|
41
|
+
h.color('Cookbook', :bold),
|
42
|
+
h.color('Version', :bold)
|
43
|
+
]
|
44
|
+
|
45
|
+
num_columns = log_entries.length
|
46
|
+
|
47
|
+
cookbook_versions.to_a.sort_by(&:first).each do |(name, version)|
|
48
|
+
log_entries << name
|
49
|
+
log_entries << version
|
50
|
+
end
|
51
|
+
|
52
|
+
puts h.list(log_entries, :columns_across, num_columns)
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class NodeLog < Chef::Knife
|
58
|
+
banner "knife node log NODE"
|
59
|
+
|
60
|
+
deps do
|
61
|
+
require 'chef/search/query'
|
62
|
+
require 'chef/knife/search'
|
63
|
+
require 'highline'
|
64
|
+
require 'date'
|
65
|
+
require 'time'
|
66
|
+
end
|
67
|
+
|
68
|
+
def h
|
69
|
+
@highline ||= HighLine.new
|
70
|
+
end
|
71
|
+
|
72
|
+
def recipe entry
|
73
|
+
"%s@%s::%s" % [
|
74
|
+
entry['cookbook_name'],
|
75
|
+
entry['cookbook_version'],
|
76
|
+
entry['recipe_name']
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
def join array
|
81
|
+
array.join(',') rescue array
|
82
|
+
end
|
83
|
+
|
84
|
+
def iso8601 date_string
|
85
|
+
DateTime.strptime(date_string).to_time.iso8601 rescue date_string
|
86
|
+
end
|
87
|
+
|
88
|
+
def run
|
89
|
+
unless node_name = name_args.shift
|
90
|
+
ui.error 'Please specify a node'
|
91
|
+
exit 1
|
92
|
+
end
|
93
|
+
|
94
|
+
searcher = Chef::Search::Query.new
|
95
|
+
result = searcher.search(:node, "name:#{node_name}")
|
96
|
+
node = result.first.first
|
97
|
+
|
98
|
+
if node.nil?
|
99
|
+
ui.error 'Could find the given node'
|
100
|
+
exit 1
|
101
|
+
end
|
102
|
+
|
103
|
+
$stdout.sync = true
|
104
|
+
|
105
|
+
unless node['log']
|
106
|
+
ui.error 'No log to report'
|
107
|
+
exit 1
|
108
|
+
end
|
109
|
+
|
110
|
+
log_entries = [
|
111
|
+
h.color('Time', :bold),
|
112
|
+
h.color('Recipe', :bold),
|
113
|
+
h.color('Action', :bold),
|
114
|
+
h.color('Resource Type', :bold),
|
115
|
+
h.color('Resource', :bold)
|
116
|
+
]
|
117
|
+
|
118
|
+
num_columns = log_entries.length
|
119
|
+
|
120
|
+
node['log'].each do |log_entry|
|
121
|
+
log_entries << iso8601(log_entry['time'])
|
122
|
+
log_entries << recipe(log_entry)
|
123
|
+
log_entries << join(log_entry['action'])
|
124
|
+
log_entries << log_entry['resource_type'].to_s
|
125
|
+
log_entries << log_entry['resource'].to_s
|
126
|
+
end
|
127
|
+
|
128
|
+
puts h.list(log_entries, :columns_across, num_columns)
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bourdain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pmap
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/bourdain/resources/generators/cookbook.rb
|
126
126
|
- lib/bourdain/resources/generators/recipe.rb
|
127
127
|
- templates/chef/environment.json
|
128
|
+
- templates/chef/knife_plugin_node_log.rb
|
128
129
|
- templates/chef/role.json
|
129
130
|
- templates/cookbook/Berksfile
|
130
131
|
- templates/cookbook/Readme.md
|