knife-chef-inventory 0.2.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +9 -7
- data/knife-chef-inventory.gemspec +1 -1
- data/lib/chef/knife/inventory_chef_client.rb +14 -10
- data/lib/chef/knife/inventory_cookbook.rb +14 -10
- data/lib/knife-chef-inventory/shared.rb +15 -0
- data/lib/knife-chef-inventory/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f91812999c2632572f1862649d09185a48168365
|
4
|
+
data.tar.gz: 049e4042535631445f08bc3f76778a269b566b71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53026cc6ccf258fd7bd223a548cc9c9f9022c73e4bae4baa421aabc408edd73afb3c5744b8b26005b6c6266ff6d8a1bd5b9dc5756efc5fd6f4906bc2f24c83f2
|
7
|
+
data.tar.gz: ea2aebfd0fe1456a9802d874a9db92cc92f26b235e998ed47e4694c1d39ca73109e18e377b29b75744f108715c2b7e04afd22fc9cc7ae5ab33b56db4dd3c39c6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.2.1](https://github.com/brentm5/knife-chef-inventory/tree/v0.2.1) (2016-08-19)
|
4
|
+
[Full Changelog](https://github.com/brentm5/knife-chef-inventory/compare/v0.2.0...v0.2.1)
|
5
|
+
|
6
|
+
**Merged pull requests:**
|
7
|
+
|
8
|
+
- Improve performance by switching to partial search [\#14](https://github.com/brentm5/knife-chef-inventory/pull/14) ([brentm5](https://github.com/brentm5))
|
9
|
+
- Fix issue where only first 1000 nodes get returned [\#13](https://github.com/brentm5/knife-chef-inventory/pull/13) ([brentm5](https://github.com/brentm5))
|
10
|
+
- Fix deprecation warnings for chef 13 when accessing nodes [\#10](https://github.com/brentm5/knife-chef-inventory/pull/10) ([brentm5](https://github.com/brentm5))
|
11
|
+
|
3
12
|
## [v0.2.0](https://github.com/brentm5/knife-chef-inventory/tree/v0.2.0) (2016-08-16)
|
4
13
|
[Full Changelog](https://github.com/brentm5/knife-chef-inventory/compare/v0.1.0...v0.2.0)
|
5
14
|
|
@@ -12,16 +21,9 @@
|
|
12
21
|
|
13
22
|
**Merged pull requests:**
|
14
23
|
|
15
|
-
- Add changelog generator and cleanup naming [\#7](https://github.com/brentm5/knife-chef-inventory/pull/7) ([brentm5](https://github.com/brentm5))
|
16
24
|
- Update banner for inventory\_cookbook.rb [\#6](https://github.com/brentm5/knife-chef-inventory/pull/6) ([afiune](https://github.com/afiune))
|
17
|
-
- Add more information to readme [\#4](https://github.com/brentm5/knife-chef-inventory/pull/4) ([brentm5](https://github.com/brentm5))
|
18
|
-
- Add more to the readme and fix travis [\#3](https://github.com/brentm5/knife-chef-inventory/pull/3) ([brentm5](https://github.com/brentm5))
|
19
25
|
|
20
26
|
## [v0.0.1](https://github.com/brentm5/knife-chef-inventory/tree/v0.0.1) (2016-05-12)
|
21
|
-
**Merged pull requests:**
|
22
|
-
|
23
|
-
- Update to be called knife-chef-inventory [\#2](https://github.com/brentm5/knife-chef-inventory/pull/2) ([brentm5](https://github.com/brentm5))
|
24
|
-
|
25
27
|
|
26
28
|
|
27
29
|
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
@@ -1,9 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
require "chef/knife"
|
2
|
+
require "knife-chef-inventory/shared"
|
3
3
|
|
4
4
|
class Chef
|
5
5
|
class Knife
|
6
6
|
class InventoryChefClient < Knife
|
7
|
+
include KnifeChefInventory::Shared
|
7
8
|
banner "knife inventory chef_client"
|
8
9
|
|
9
10
|
deps do
|
@@ -35,14 +36,21 @@ class Chef
|
|
35
36
|
@client_version_nodes ||= search_nodes("chef_packages_chef_version:#{@client_version}")
|
36
37
|
end
|
37
38
|
|
38
|
-
def
|
39
|
-
|
39
|
+
def search_args
|
40
|
+
{
|
41
|
+
rows: max_results,
|
42
|
+
filter_result: {
|
43
|
+
name: ["name"],
|
44
|
+
chef_version: %w(chef_packages chef version),
|
45
|
+
ohai_time: ["ohai_time"]
|
46
|
+
}
|
47
|
+
}
|
40
48
|
end
|
41
49
|
|
42
50
|
def client_usage_per_version
|
43
51
|
version_map = Hash.new(0)
|
44
52
|
all_nodes.each do |node|
|
45
|
-
version = node
|
53
|
+
version = node["chef_version"]
|
46
54
|
|
47
55
|
version_map[version] += 1
|
48
56
|
end
|
@@ -61,14 +69,10 @@ class Chef
|
|
61
69
|
ui.info "#{version} is used by #{client_usage} hosts" if client_usage > 0
|
62
70
|
end
|
63
71
|
|
64
|
-
def time_since(timestamp)
|
65
|
-
(Time.now - Time.at(timestamp)).to_i / 60
|
66
|
-
end
|
67
|
-
|
68
72
|
def output_version_analysis
|
69
73
|
ui.info "Client Versions being used"
|
70
|
-
client_version_nodes.sort_by
|
71
|
-
ui.info "#{node
|
74
|
+
client_version_nodes.sort_by { |node| node["ohai_time"] }.each do |node|
|
75
|
+
ui.info "#{node['name']} - #{time_since(node['ohai_time'])} Minutes"
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
@@ -1,9 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
require "chef/knife"
|
2
|
+
require "knife-chef-inventory/shared"
|
3
3
|
|
4
4
|
class Chef
|
5
5
|
class Knife
|
6
6
|
class InventoryCookbook < Knife
|
7
|
+
include KnifeChefInventory::Shared
|
7
8
|
banner "knife inventory cookbook COOKBOOK [VERSION] (options)"
|
8
9
|
|
9
10
|
deps do
|
@@ -67,8 +68,15 @@ class Chef
|
|
67
68
|
@environment_versions
|
68
69
|
end
|
69
70
|
|
70
|
-
def
|
71
|
-
|
71
|
+
def search_args
|
72
|
+
{
|
73
|
+
rows: max_results,
|
74
|
+
filter_result: {
|
75
|
+
name: ["name"],
|
76
|
+
cookbook_version: ["cookbooks", @cookbook_name, "version"],
|
77
|
+
ohai_time: ["ohai_time"]
|
78
|
+
}
|
79
|
+
}
|
72
80
|
end
|
73
81
|
|
74
82
|
def all_cookbook_versions
|
@@ -78,7 +86,7 @@ class Chef
|
|
78
86
|
def cookbook_usage_per_version
|
79
87
|
version_map = Hash.new(0)
|
80
88
|
cookbook_nodes.each do |node|
|
81
|
-
version = node
|
89
|
+
version = node["cookbook_version"]
|
82
90
|
|
83
91
|
version_map[version] += 1
|
84
92
|
end
|
@@ -104,14 +112,10 @@ class Chef
|
|
104
112
|
end
|
105
113
|
end
|
106
114
|
|
107
|
-
def time_since(timestamp)
|
108
|
-
(Time.now - Time.at(timestamp)).to_i / 60
|
109
|
-
end
|
110
|
-
|
111
115
|
def output_version_analysis
|
112
116
|
ui.info "Cookbook Versions being used for #{@cookbook_name}"
|
113
|
-
cookbook_version_nodes.sort_by
|
114
|
-
ui.info "#{node
|
117
|
+
cookbook_version_nodes.sort_by { |node| node["ohai_time"] }.each do |node|
|
118
|
+
ui.info "#{node['name']} - #{time_since(node['ohai_time'])} Minutes"
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module KnifeChefInventory
|
2
|
+
module Shared
|
3
|
+
def time_since(timestamp)
|
4
|
+
(Time.now - Time.at(timestamp)).to_i / 60
|
5
|
+
end
|
6
|
+
|
7
|
+
def search_nodes(query)
|
8
|
+
Chef::Search::Query.new.search(:node, query, search_args).first
|
9
|
+
end
|
10
|
+
|
11
|
+
def max_results
|
12
|
+
Chef::Node.list.count || 1000
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-chef-inventory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brent Montague
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 12.11
|
19
|
+
version: '12.11'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 12.11
|
26
|
+
version: '12.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- knife-chef-inventory.gemspec
|
100
100
|
- lib/chef/knife/inventory_chef_client.rb
|
101
101
|
- lib/chef/knife/inventory_cookbook.rb
|
102
|
+
- lib/knife-chef-inventory/shared.rb
|
102
103
|
- lib/knife-chef-inventory/version.rb
|
103
104
|
- tasks/changelog.rake
|
104
105
|
homepage: https://github.com/brentm5/knife-chef-inventory
|