knife-pinnings 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/chef/knife/pinnings_mixin.rb +2 -1
- data/lib/chef/knife/pinnings_set_auto.rb +14 -8
- data/lib/knife-pinnings/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 935707e1593f4d939e25e7a4bc3b229290d805f8
|
4
|
+
data.tar.gz: 1c00659870f5a446c2e5d23dfa7632ae886975c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61bf92763a42fe50efede8766706f31101a35bf2aefb7e741d56661cb1e298c1503398328df7e98727a0f192aa79d4318baee25bff747ba4e300698b7a0372fb
|
7
|
+
data.tar.gz: b2f1ec6319769a5ce6d4c11f6239620caa72f5cec421e53136cd5815758425cca6ed2c8301858f059b038ba35a75d4f75abdf2ccf878e1a3cf8d954be9175083
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ To take the name and version from the metadata.rb in the current directory use
|
|
30
30
|
|
31
31
|
$ knife pinnings set <environment>
|
32
32
|
|
33
|
-
To leverage chef resolver to find out all cookbook versions used by all nodes of a given chef environment and set them back in the environment (typically latest versions will be resolved)
|
33
|
+
To leverage chef resolver to find out all cookbook versions used by all nodes of a given chef environment and set them back in the environment (typically latest versions will be resolved, but not always)
|
34
34
|
|
35
35
|
$ knife pinnings set auto <environment>
|
36
36
|
|
@@ -123,9 +123,10 @@ def nodes_in(rest, environment)
|
|
123
123
|
rest.get_rest("/environments/#{environment}/nodes").keys
|
124
124
|
end
|
125
125
|
|
126
|
-
def cookbooks_used_by(rest, environment
|
126
|
+
def cookbooks_used_by(rest, environment)
|
127
127
|
recipes = []
|
128
128
|
roles = []
|
129
|
+
nodes = nodes_in(rest, environment)
|
129
130
|
nodes.each do |node|
|
130
131
|
response = rest.get_rest("/nodes/#{node}").run_list
|
131
132
|
_recipes = response.recipe_names
|
@@ -18,15 +18,18 @@ class Chef
|
|
18
18
|
class PinningsSetAuto < Chef::Knife
|
19
19
|
require 'chef/knife/pinnings_mixin'
|
20
20
|
banner 'knife pinnings set auto ENVIRONMENT [COOKBOOK_VERSION_CONSTRAINTS]'
|
21
|
+
FakeChefEnvironmentStruct = Struct.new :name, :cookbook_versions
|
21
22
|
|
22
23
|
def run
|
23
24
|
case name_args.length
|
24
25
|
when 1 # Just environment was specified
|
25
26
|
@environment_name = name_args[0]
|
26
|
-
|
27
|
+
@cookbook_regex = '.*'
|
28
|
+
when 2 # Environment, cookbook version constraints specified
|
27
29
|
@environment_name = name_args[0]
|
28
30
|
@cookbook_version_constraints_string = name_args[1]
|
29
31
|
@cookbook_version_constraints = @cookbook_version_constraints_string.split(",")
|
32
|
+
@cookbook_regex = '.*'
|
30
33
|
else
|
31
34
|
ui.fatal('You must specify ENVIRONMENT or ENVIRONMENT COOKBOOK_CONSTRAINTS (constraints example: "foo","bar","zed@0.0.1")')
|
32
35
|
exit 255
|
@@ -34,7 +37,7 @@ class Chef
|
|
34
37
|
@environment = Environment.load(@environment_name)
|
35
38
|
nodes = nodes_in(rest, @environment)
|
36
39
|
ui.info("#{nodes.length} nodes have been found in environment #{@environment_name}: #{nodes.to_s}")
|
37
|
-
cookbooks = cookbooks_used_by(rest, @environment_name
|
40
|
+
cookbooks = cookbooks_used_by(rest, @environment_name)
|
38
41
|
ui.info("#{cookbooks.length} recipes have been found for the nodes: #{cookbooks.to_s}")
|
39
42
|
if @cookbook_version_constraints != nil
|
40
43
|
cookbooks_with_contraints = cookbooks_merged_with_version_constraints(cookbooks, @cookbook_version_constraints)
|
@@ -43,18 +46,21 @@ class Chef
|
|
43
46
|
ui.info("No version constraint have been specified as input")
|
44
47
|
cookbooks_with_contraints = cookbooks
|
45
48
|
end
|
46
|
-
ui.info("will attempt resolving the dependencies with chef resolver...")
|
47
|
-
|
49
|
+
ui.info("knife-pinnings will attempt resolving the dependencies with chef resolver...")
|
50
|
+
solution_cookbook_versions = solve_recipes(rest, @environment, cookbooks_with_contraints)
|
48
51
|
ui.msg('')
|
49
|
-
|
50
|
-
|
52
|
+
|
53
|
+
environments = []
|
54
|
+
environments.push(@environment)
|
55
|
+
environments.push(FakeChefEnvironmentStruct.new('chef_resolver_solution',solution_cookbook_versions))
|
56
|
+
display_pinnings_table(environments, @cookbook_regex)
|
51
57
|
|
52
58
|
ui.msg('')
|
53
59
|
ui.confirm("Do you want to set these cookbook versions on chef environment:#{@environment_name} ")
|
54
60
|
ui.msg('')
|
55
61
|
|
56
|
-
set_environnment_pinnings(@environment,
|
57
|
-
ui.info("pinnings have been set on #{@environment_name}")
|
62
|
+
set_environnment_pinnings(@environment, solution_cookbook_versions)
|
63
|
+
ui.info("version pinnings have been set on #{@environment_name}")
|
58
64
|
|
59
65
|
end
|
60
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-pinnings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Nixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
184
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.4.
|
185
|
+
rubygems_version: 2.4.1
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Chef knife plugin to set, list, compare, copy and delete cookbook pinnings
|