knife-zero 1.15.3 → 1.16.0.pre1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f101736fd4259132c3bc58de4ebc0242cf4384f3
4
- data.tar.gz: 4c792fe31836a9bd6ae261247ff64fa21949ec9a
3
+ metadata.gz: 9dc4464b0ebe5babb1012fec6d849b0fbc3d9b08
4
+ data.tar.gz: 258b4f0893a60245da187c947184bbe756efc544
5
5
  SHA512:
6
- metadata.gz: 3c239c00cf00bc9061238c8f6cfcc566f16a91c753c36bc92d056f557159c1904ba63ab05d8b54e7b473aafa65749dc515f72e569d50173dea3d5b88ee245fb4
7
- data.tar.gz: 12518b6fe5f43e0f850d9c78f94c7dfa2cc4d265a5273717a781da037b01b3bb30f6de23f3548fec4da58d6ebf8d840a1ece868233f77984c4672feb6ed0f98d
6
+ metadata.gz: 34d76dffa90a49468451c030034867b8e449c104decb81e607222a3060f95e5de81e3fcccb0381ac3ae536b12c695486077f01879de39b7e756b3fb74538ef53
7
+ data.tar.gz: 671cc93e8c418609c8bece5b647283cc60f8a449d81ea2fbe5c3fd11de3f17b07ba7962f8a16990c06988e88ad7a71fb47f3ed03402ae9b2c290ea55c9d9e31b
@@ -3,6 +3,11 @@
3
3
  ## Unreleased
4
4
 
5
5
  Empty.
6
+
7
+ ## v1.16.0.pre~
8
+
9
+ - [Feature] converge with `--json-attributes` #98
10
+
6
11
  ## v1.15.3
7
12
 
8
13
  - [Bugfix] move overridden options of bootstrap into deps.
@@ -1,6 +1,7 @@
1
1
  require 'chef/knife'
2
2
  require 'chef/knife/zero_base'
3
3
  require 'chef/application/client'
4
+ require 'chef/config_fetcher'
4
5
  require 'knife-zero/bootstrap_ssh'
5
6
  require 'knife-zero/helper'
6
7
 
@@ -20,7 +21,9 @@ class Chef
20
21
  self.options[:use_sudo_password] = Bootstrap.options[:use_sudo_password]
21
22
 
22
23
  ## Import Features from chef-client
23
- ## > 12.5.1
24
+ self.options[:json_attribs] = Chef::Application::Client.options[:json_attribs]
25
+
26
+ ### > 12.5.1
24
27
  self.options[:named_run_list] = Chef::Application::Client.options[:named_run_list]
25
28
 
26
29
  if ::Knife::Zero::Helper.required_chef_version?('12.8.1')
@@ -70,6 +73,9 @@ class Chef
70
73
  end
71
74
 
72
75
  validate_options!
76
+ if @config[:json_attribs]
77
+ @config[:chef_client_json] = fetch_json_from_url
78
+ end
73
79
 
74
80
  @name_args = [@name_args[0], start_chef_client]
75
81
  end
@@ -81,6 +87,7 @@ class Chef
81
87
  s << ' -l debug' if @config[:verbosity] and @config[:verbosity] >= 2
82
88
  s << " -S http://127.0.0.1:#{::Knife::Zero::Helper.zero_remote_port}"
83
89
  s << " -o #{@config[:override_runlist]}" if @config[:override_runlist]
90
+ s << ' -j /etc/chef/chef_client_json.json' if @config[:json_attribs]
84
91
  s << " --splay #{@config[:splay]}" if @config[:splay]
85
92
  s << " -n #{@config[:named_run_list]}" if @config[:named_run_list]
86
93
  s << " --skip-cookbook-sync" if @config[:skip_cookbook_sync]
@@ -95,6 +102,13 @@ class Chef
95
102
  ui.error("--override_runlist and --named_run_list are exclusive")
96
103
  exit 1
97
104
  end
105
+ if json_attribs_without_override_given?
106
+ ui.error(
107
+ '--json-attributes must be used with --override-runlist ' \
108
+ 'to avoid updating local node object.'
109
+ )
110
+ exit 1
111
+ end
98
112
  true
99
113
  end
100
114
  # True if policy_name and run_list are both given
@@ -103,13 +117,30 @@ class Chef
103
117
  end
104
118
 
105
119
  def override_runlist_given?
106
- !config[:run_list].nil? && !config[:run_list].empty?
120
+ !config[:override_runlist].nil? && !config[:override_runlist].empty?
107
121
  end
108
122
 
109
123
  def named_run_list_given?
110
- !config[:run_list].nil? && !config[:run_list].empty?
124
+ !config[:named_run_list].nil? && !config[:named_run_list].empty?
125
+ end
126
+
127
+ def json_attribs_without_override_given?
128
+ if json_attribs_given?
129
+ return true unless override_runlist_given?
130
+ else
131
+ false
132
+ end
133
+ false
111
134
  end
112
135
 
136
+ def json_attribs_given?
137
+ !config[:json_attribs].nil? && !config[:json_attribs].empty?
138
+ end
139
+
140
+ def fetch_json_from_url
141
+ config_fetcher = Chef::ConfigFetcher.new(@config[:json_attribs])
142
+ config_fetcher.fetch_json
143
+ end
113
144
  end
114
145
  end
115
146
  end
@@ -16,6 +16,11 @@ class Chef
16
16
  super(%Q{/opt/chef/embedded/bin/ruby -ropen-uri -e 'puts open("https://chef.sh").read' | sudo sh -s -- -v #{config[:client_version]}})
17
17
  end
18
18
 
19
+ if config[:json_attribs]
20
+ Chef::Log.info "Onetime Attributes: #{config[:chef_client_json]}"
21
+ super(build_client_json)
22
+ end
23
+
19
24
  chef_zero_port = config[:chef_zero_port] ||
20
25
  Chef::Config[:knife][:chef_zero_port] ||
21
26
  URI.parse(Chef::Config.chef_server_url).port
@@ -33,6 +38,14 @@ class Chef
33
38
  exit 1
34
39
  end
35
40
  end
41
+
42
+ def build_client_json
43
+ <<-EOH
44
+ sudo sh -c 'cat <<"EOP" > /etc/chef/chef_client_json.json
45
+ #{config[:chef_client_json].to_json}
46
+ '
47
+ EOH
48
+ end
36
49
  end
37
50
  end
38
51
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Zero
3
- VERSION = "1.15.3"
3
+ VERSION = "1.16.0.pre1"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.3
4
+ version: 1.16.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sawanoboly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -187,9 +187,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - ">="
190
+ - - ">"
191
191
  - !ruby/object:Gem::Version
192
- version: '0'
192
+ version: 1.3.1
193
193
  requirements: []
194
194
  rubyforge_project:
195
195
  rubygems_version: 2.4.8