knife-rackspace 1.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3424287dbc7b2fc0cacf8f5d59f5f270620f114f
4
- data.tar.gz: 622cf2499996948177d909c495ca9d036a9cf149
2
+ SHA256:
3
+ metadata.gz: 4d076b1123a47563c50cc2113b132fcad24792de369fefda5d879af3def6b6fb
4
+ data.tar.gz: 55fb1c587e13f2a029783891c9cce1585e120fb6f3eb9df2fe5779775fd44982
5
5
  SHA512:
6
- metadata.gz: a55cb84a25d9374ec39003f52312c58960e907eeff6f68612fd63e77d103ac773261c23a384fc12389b1ddcc079d893440228c6f69eac81a529509a550bc57fc
7
- data.tar.gz: c727dbaa60bc04a9f2c5899c193cad18555e2ec9bcbd5493096b83a72a5dab724130bd913775e91b8dc59fd2ddae2b7146a0552f0395677b4fb670ab75027037
6
+ metadata.gz: 445fe503b0d35b9c07151dc45ab08167ed565ff68ad060e83582976ca5b86bbf517640b76e504fc2209fa8e00a009de863382040fe7cf4eaeb985a973214a48f
7
+ data.tar.gz: c9936580b82f1d82cc204697c0644c38cf772ea135aee27b24af1ec00bd9b69e1545d5361ffde45095d569e35640b4fc6ccfad74ebf5e1be6dfa9e07aa6020b6
@@ -37,37 +37,37 @@ class Chef
37
37
  end
38
38
 
39
39
  option :rackspace_api_key,
40
- :short => "-K KEY",
41
- :long => "--rackspace-api-key KEY",
42
- :description => "Your rackspace API key",
43
- :proc => Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
40
+ short: "-K KEY",
41
+ long: "--rackspace-api-key KEY",
42
+ description: "Your rackspace API key",
43
+ proc: Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
44
44
 
45
45
  option :rackspace_username,
46
- :short => "-A USERNAME",
47
- :long => "--rackspace-username USERNAME",
48
- :description => "Your rackspace API username",
49
- :proc => Proc.new { |username| Chef::Config[:knife][:rackspace_username] = username }
46
+ short: "-A USERNAME",
47
+ long: "--rackspace-username USERNAME",
48
+ description: "Your rackspace API username",
49
+ proc: Proc.new { |username| Chef::Config[:knife][:rackspace_username] = username }
50
50
 
51
51
  option :rackspace_version,
52
- :long => "--rackspace-version VERSION",
53
- :description => "Rackspace Cloud Servers API version",
54
- :default => "v2",
55
- :proc => Proc.new { |version| Chef::Config[:knife][:rackspace_version] = version }
52
+ long: "--rackspace-version VERSION",
53
+ description: "Rackspace Cloud Servers API version",
54
+ default: "v2",
55
+ proc: Proc.new { |version| Chef::Config[:knife][:rackspace_version] = version }
56
56
 
57
57
  option :rackspace_auth_url,
58
- :long => "--rackspace-auth-url URL",
59
- :description => "Your rackspace API auth url",
60
- :proc => Proc.new { |url| Chef::Config[:knife][:rackspace_auth_url] = url }
58
+ long: "--rackspace-auth-url URL",
59
+ description: "Your rackspace API auth url",
60
+ proc: Proc.new { |url| Chef::Config[:knife][:rackspace_auth_url] = url }
61
61
 
62
62
  option :rackspace_region,
63
- :long => "--rackspace-region REGION",
64
- :description => "Your rackspace region",
65
- :proc => Proc.new { |region| Chef::Config[:knife][:rackspace_region] = region }
63
+ long: "--rackspace-region REGION",
64
+ description: "Your rackspace region",
65
+ proc: Proc.new { |region| Chef::Config[:knife][:rackspace_region] = region }
66
66
 
67
67
  option :file,
68
- :long => "--file DESTINATION-PATH=SOURCE-PATH",
69
- :description => "File to inject on node",
70
- :proc => Proc.new {|arg|
68
+ long: "--file DESTINATION-PATH=SOURCE-PATH",
69
+ description: "File to inject on node",
70
+ proc: Proc.new { |arg|
71
71
  Chef::Config[:knife][:file] ||= []
72
72
  Chef::Config[:knife][:file] << arg
73
73
  }
@@ -94,14 +94,14 @@ class Chef
94
94
  region_warning_for_v1
95
95
  @connection ||= begin
96
96
  connection = Fog::Compute.new(connection_params({
97
- :version => "v1",
97
+ version: "v1",
98
98
  }))
99
99
  end
100
100
  else
101
101
  Chef::Log.debug("rackspace v2")
102
102
  @connection ||= begin
103
103
  connection = Fog::Compute.new(connection_params({
104
- :version => "v2",
104
+ version: "v2",
105
105
  }))
106
106
  end
107
107
  end
@@ -131,22 +131,22 @@ class Chef
131
131
  end
132
132
 
133
133
  hash = options.merge({
134
- :provider => "Rackspace",
135
- :rackspace_api_key => locate_config_value(:rackspace_api_key),
136
- :rackspace_username => username,
137
- :rackspace_auth_url => auth_endpoint,
138
- :rackspace_region => locate_config_value(:rackspace_region),
134
+ provider: "Rackspace",
135
+ rackspace_api_key: locate_config_value(:rackspace_api_key),
136
+ rackspace_username: username,
137
+ rackspace_auth_url: auth_endpoint,
138
+ rackspace_region: locate_config_value(:rackspace_region),
139
139
  })
140
140
 
141
141
  hash[:connection_options] ||= {}
142
- Chef::Log.debug("https_proxy #{ Chef::Config[:https_proxy] || "<not specified>"} (config)")
143
- Chef::Log.debug("http_proxy #{ Chef::Config[:http_proxy] || "<not specified>"} (config)")
144
- if Chef::Config.has_key?(:https_proxy) || Chef::Config.has_key?(:http_proxy)
145
- hash[:connection_options] = { :proxy => Chef::Config[:https_proxy] || Chef::Config[:http_proxy] }
142
+ Chef::Log.debug("https_proxy #{Chef::Config[:https_proxy] || "<not specified>"} (config)")
143
+ Chef::Log.debug("http_proxy #{Chef::Config[:http_proxy] || "<not specified>"} (config)")
144
+ if Chef::Config.key?(:https_proxy) || Chef::Config.key?(:http_proxy)
145
+ hash[:connection_options] = { proxy: Chef::Config[:https_proxy] || Chef::Config[:http_proxy] }
146
146
  end
147
147
  Chef::Log.debug("using proxy #{hash[:connection_options][:proxy] || "<none>"} (config)")
148
- Chef::Log.debug("ssl_verify_peer #{Chef::Config[:knife].has_key?(:ssl_verify_peer) ? Chef::Config[:knife][:ssl_verify_peer] : "<not specified>"} (config)")
149
- hash[:connection_options][:ssl_verify_peer] = Chef::Config[:knife][:ssl_verify_peer] if Chef::Config[:knife].has_key?(:ssl_verify_peer)
148
+ Chef::Log.debug("ssl_verify_peer #{Chef::Config[:knife].key?(:ssl_verify_peer) ? Chef::Config[:knife][:ssl_verify_peer] : "<not specified>"} (config)")
149
+ hash[:connection_options][:ssl_verify_peer] = Chef::Config[:knife][:ssl_verify_peer] if Chef::Config[:knife].key?(:ssl_verify_peer)
150
150
 
151
151
  hash
152
152
  end
@@ -154,6 +154,7 @@ class Chef
154
154
  def auth_endpoint
155
155
  url = locate_config_value(:rackspace_auth_url)
156
156
  return url if url
157
+
157
158
  (locate_config_value(:rackspace_region) == "lon") ? ::Fog::Rackspace::UK_AUTH_ENDPOINT : ::Fog::Rackspace::US_AUTH_ENDPOINT
158
159
  end
159
160
 
@@ -188,8 +189,8 @@ class Chef
188
189
  if public_ip_address = ip_address(server, "public")
189
190
  @public_dns_name ||= begin
190
191
  Resolv.getname(public_ip_address)
191
- rescue
192
- "#{public_ip_address}.xip.io"
192
+ rescue
193
+ "#{public_ip_address}.xip.io"
193
194
  end
194
195
  end
195
196
  end
@@ -206,11 +207,11 @@ class Chef
206
207
  end
207
208
 
208
209
  def v1_public_ip(server)
209
- server.public_ip_address == nil ? "" : server.public_ip_address
210
+ server.public_ip_address.nil? ? "" : server.public_ip_address
210
211
  end
211
212
 
212
213
  def v1_private_ip(server)
213
- server.addresses["private"].first == nil ? "" : server.addresses["private"].first
214
+ server.addresses["private"].first.nil? ? "" : server.addresses["private"].first
214
215
  end
215
216
 
216
217
  def v2_ip_address(server, network)
@@ -219,7 +220,7 @@ class Chef
219
220
  end
220
221
 
221
222
  def v2_access_ip(server)
222
- server.access_ipv4_address == nil ? "" : server.access_ipv4_address
223
+ server.access_ipv4_address.nil? ? "" : server.access_ipv4_address
223
224
  end
224
225
 
225
226
  def extract_ipv4_address(ip_addresses)
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/knife/rackspace_base"
19
+ require_relative "rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/knife/rackspace_base"
19
+ require_relative "rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -1,4 +1,4 @@
1
- require "chef/knife/rackspace_base"
1
+ require_relative "rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -9,16 +9,16 @@ class Chef
9
9
  banner "knife rackspace network create (options)"
10
10
 
11
11
  option :label,
12
- :short => "-L LABEL",
13
- :long => "--label LABEL",
14
- :description => "Label for the network",
15
- :required => true
12
+ short: "-L LABEL",
13
+ long: "--label LABEL",
14
+ description: "Label for the network",
15
+ required: true
16
16
 
17
17
  option :cidr,
18
- :short => "-C CIDR",
19
- :long => "--cidr CIDR",
20
- :description => "CIDR for the network",
21
- :required => true
18
+ short: "-C CIDR",
19
+ long: "--cidr CIDR",
20
+ description: "CIDR for the network",
21
+ required: true
22
22
 
23
23
  def run
24
24
  if version_one?
@@ -32,7 +32,7 @@ class Chef
32
32
  ]
33
33
  end
34
34
  options = {}
35
- [:cidr, :label].each do |key|
35
+ %i{cidr label}.each do |key|
36
36
  options[key] = config[key]
37
37
  end
38
38
  net = connection.networks.create(options)
@@ -1,4 +1,4 @@
1
- require "chef/knife/rackspace_base"
1
+ require_relative "rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -1,4 +1,4 @@
1
- require "chef/knife/rackspace_base"
1
+ require_relative "rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "chef/knife/rackspace_base"
20
+ require_relative "rackspace_base"
21
21
  require "chef/knife/winrm_base"
22
22
  require "chef/knife"
23
23
 
@@ -41,240 +41,256 @@ class Chef
41
41
  attr_accessor :initial_sleep_delay
42
42
 
43
43
  option :flavor,
44
- :short => "-f FLAVOR",
45
- :long => "--flavor FLAVOR",
46
- :description => "The flavor of server; default is 2 (512 MB)",
47
- :proc => Proc.new { |f| Chef::Config[:knife][:flavor] = f.to_s },
48
- :default => 2
44
+ short: "-f FLAVOR",
45
+ long: "--flavor FLAVOR",
46
+ description: "The flavor of server; default is 2 (512 MB)",
47
+ proc: Proc.new { |f| Chef::Config[:knife][:flavor] = f.to_s },
48
+ default: "2"
49
49
 
50
50
  option :image,
51
- :short => "-I IMAGE",
52
- :long => "--image IMAGE",
53
- :description => "The image of the server",
54
- :proc => Proc.new { |i| Chef::Config[:knife][:image] = i.to_s }
51
+ short: "-I IMAGE",
52
+ long: "--image IMAGE",
53
+ description: "The image of the server",
54
+ proc: Proc.new { |i| Chef::Config[:knife][:image] = i.to_s }
55
55
 
56
56
  option :boot_volume_size,
57
- :long => "--boot-volume-size GB",
58
- :description => "The size of the CBS to use as the server's boot device",
59
- :proc => Proc.new { |i| Chef::Config[:knife][:boot_volume_size] = i.to_s },
60
- :default => 100
57
+ long: "--boot-volume-size GB",
58
+ description: "The size of the CBS to use as the server's boot device",
59
+ proc: Proc.new { |i| Chef::Config[:knife][:boot_volume_size] = i.to_s },
60
+ default: 100
61
61
 
62
62
  option :boot_volume_id,
63
- :short => "-B BOOT_VOLUME_ID",
64
- :long => "--boot-volume-id UUID",
65
- :description => "The image CBS UUID to use as the server's boot device",
66
- :proc => Proc.new { |i| Chef::Config[:knife][:boot_volume_id] = i.to_s }
63
+ short: "-B BOOT_VOLUME_ID",
64
+ long: "--boot-volume-id UUID",
65
+ description: "The image CBS UUID to use as the server's boot device",
66
+ proc: Proc.new { |i| Chef::Config[:knife][:boot_volume_id] = i.to_s }
67
67
 
68
68
  option :server_name,
69
- :short => "-S NAME",
70
- :long => "--server-name NAME",
71
- :description => "The server name"
69
+ short: "-S NAME",
70
+ long: "--server-name NAME",
71
+ description: "The server name"
72
72
 
73
73
  option :chef_node_name,
74
- :short => "-N NAME",
75
- :long => "--node-name NAME",
76
- :description => "The Chef node name for your new node"
74
+ short: "-N NAME",
75
+ long: "--node-name NAME",
76
+ description: "The Chef node name for your new node"
77
77
 
78
78
  option :bootstrap_network,
79
- :long => "--bootstrap-network LABEL",
80
- :description => "Use IP address on this network for bootstrap",
81
- :default => "public"
79
+ long: "--bootstrap-network LABEL",
80
+ description: "Use IP address on this network for bootstrap",
81
+ default: "public"
82
82
 
83
83
  option :private_network,
84
- :long => "--private-network",
85
- :description => "Equivalent to --bootstrap-network private",
86
- :boolean => true,
87
- :default => false
84
+ long: "--private-network",
85
+ description: "Equivalent to --bootstrap-network private",
86
+ boolean: true,
87
+ default: false
88
88
 
89
89
  option :ssh_user,
90
- :short => "-x USERNAME",
91
- :long => "--ssh-user USERNAME",
92
- :description => "The ssh username; default is 'root'",
93
- :default => "root"
90
+ short: "-x USERNAME",
91
+ long: "--ssh-user USERNAME",
92
+ description: "The ssh username; default is 'root'",
93
+ default: "root"
94
94
 
95
95
  option :ssh_password,
96
- :short => "-P PASSWORD",
97
- :long => "--ssh-password PASSWORD",
98
- :description => "The ssh password"
96
+ short: "-P PASSWORD",
97
+ long: "--ssh-password PASSWORD",
98
+ description: "The ssh password"
99
99
 
100
100
  option :ssh_port,
101
- :short => "-p PORT",
102
- :long => "--ssh-port PORT",
103
- :description => "The ssh port",
104
- :default => "22",
105
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
101
+ short: "-p PORT",
102
+ long: "--ssh-port PORT",
103
+ description: "The ssh port",
104
+ default: "22",
105
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
106
106
 
107
107
  option :identity_file,
108
- :short => "-i IDENTITY_FILE",
109
- :long => "--identity-file IDENTITY_FILE",
110
- :description => "The SSH identity file used for authentication"
108
+ short: "-i IDENTITY_FILE",
109
+ long: "--identity-file IDENTITY_FILE",
110
+ description: "The SSH identity file used for authentication"
111
111
 
112
112
  option :prerelease,
113
- :long => "--prerelease",
114
- :description => "Install the pre-release chef gems",
115
- :default => false
113
+ long: "--prerelease",
114
+ description: "Install the pre-release chef gems",
115
+ default: false
116
116
 
117
117
  option :bootstrap_version,
118
- :long => "--bootstrap-version VERSION",
119
- :description => "The version of Chef to install",
120
- :proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
118
+ long: "--bootstrap-version VERSION",
119
+ description: "The version of Chef to install",
120
+ proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
121
121
 
122
122
  option :distro,
123
- :short => "-d DISTRO",
124
- :long => "--distro DISTRO",
125
- :description => "Bootstrap a distro using a template; default is 'chef-full'",
126
- :proc => Proc.new { |d| Chef::Config[:knife][:distro] = d }
123
+ short: "-d DISTRO",
124
+ long: "--distro DISTRO",
125
+ description: "Bootstrap a distro using a template. [DEPRECATED] Use -t / --bootstrap-template option instead.",
126
+ proc: Proc.new { |v|
127
+ Chef::Log.fatal("[DEPRECATED] -d / --distro option is deprecated. Use --bootstrap-template option instead.")
128
+ v
129
+ }
127
130
 
131
+ # @todo When we no longer support Chef 13 this can just go away
128
132
  option :template_file,
129
- :long => "--template-file TEMPLATE",
130
- :description => "Full path to location of template to use",
131
- :proc => Proc.new { |t| Chef::Config[:knife][:template_file] = t },
132
- :default => false
133
+ long: "--template-file TEMPLATE",
134
+ description: "Full path to location of template to use. [DEPRECATED] Use -t / --bootstrap-template option instead.",
135
+ proc: Proc.new { |v|
136
+ Chef::Log.fatal("[DEPRECATED] --template-file option is deprecated. Use --bootstrap-template option instead.")
137
+ v
138
+ }
139
+
140
+ option :bootstrap_template,
141
+ short: "-t TEMPLATE",
142
+ long: "--bootstrap-template TEMPLATE",
143
+ description: "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
133
144
 
134
145
  option :run_list,
135
- :short => "-r RUN_LIST",
136
- :long => "--run-list RUN_LIST",
137
- :description => "Comma separated list of roles/recipes to apply",
138
- :proc => lambda { |o| o.split(/[\s,]+/) },
139
- :default => []
146
+ short: "-r RUN_LIST",
147
+ long: "--run-list RUN_LIST",
148
+ description: "Comma separated list of roles/recipes to apply",
149
+ proc: lambda { |o| o.split(/[\s,]+/) },
150
+ default: []
140
151
 
141
152
  option :first_boot_attributes,
142
- :short => "-j JSON_ATTRIBS",
143
- :long => "--json-attributes",
144
- :description => "A JSON string to be added to the first run of chef-client",
145
- :proc => lambda { |o| JSON.parse(o) },
146
- :default => {}
153
+ short: "-j JSON_ATTRIBS",
154
+ long: "--json-attributes",
155
+ description: "A JSON string to be added to the first run of chef-client",
156
+ proc: lambda { |o| JSON.parse(o) },
157
+ default: {}
147
158
 
148
159
  option :rackspace_metadata,
149
- :short => "-M JSON",
150
- :long => "--rackspace-metadata JSON",
151
- :description => "JSON string version of metadata hash to be supplied with the server create call",
152
- :proc => lambda { |m| JSON.parse(m) },
153
- :default => {}
160
+ short: "-M JSON",
161
+ long: "--rackspace-metadata JSON",
162
+ description: "JSON string version of metadata hash to be supplied with the server create call",
163
+ proc: lambda { |m| JSON.parse(m) },
164
+ default: {}
154
165
 
155
166
  option :rackconnect_wait,
156
- :long => "--rackconnect-wait",
157
- :description => "Wait until the Rackconnect automation setup is complete before bootstrapping chef",
158
- :boolean => true,
159
- :default => false
167
+ long: "--rackconnect-wait",
168
+ description: "Wait until the Rackconnect automation setup is complete before bootstrapping chef",
169
+ boolean: true,
170
+ default: false
160
171
 
161
172
  option :rackconnect_v3_network_id,
162
- :long => "--rackconnect-v3-network-id ID",
163
- :description => "Rackconnect V3 ONLY: Link a new server to an existing network",
164
- :proc => lambda { |o| Chef::Config[:knife][:rackconnect_v3_network_id] = o },
165
- :default => nil
173
+ long: "--rackconnect-v3-network-id ID",
174
+ description: "Rackconnect V3 ONLY: Link a new server to an existing network",
175
+ proc: lambda { |o| Chef::Config[:knife][:rackconnect_v3_network_id] = o },
176
+ default: nil
166
177
 
167
178
  option :rackspace_servicelevel_wait,
168
- :long => "--rackspace-servicelevel-wait",
169
- :description => "Wait until the Rackspace service level automation setup is complete before bootstrapping chef",
170
- :boolean => true,
171
- :default => false
179
+ long: "--rackspace-servicelevel-wait",
180
+ description: "Wait until the Rackspace service level automation setup is complete before bootstrapping chef",
181
+ boolean: true,
182
+ default: false
172
183
 
173
184
  option :hint,
174
- :long => "--hint HINT_NAME[=HINT_FILE]",
175
- :description => "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
176
- :proc => Proc.new { |h|
185
+ long: "--hint HINT_NAME[=HINT_FILE]",
186
+ description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
187
+ proc: Proc.new { |h|
177
188
  Chef::Config[:knife][:hints] ||= {}
178
189
  name, path = h.split("=")
179
- Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : Hash.new
190
+ Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : {}
180
191
  }
181
192
 
182
193
  option :host_key_verify,
183
- :long => "--[no-]host-key-verify",
184
- :description => "Verify host key, enabled by default",
185
- :boolean => true,
186
- :default => true
194
+ long: "--[no-]host-key-verify",
195
+ description: "Verify host key, enabled by default",
196
+ boolean: true,
197
+ default: true
187
198
 
188
199
  option :tcp_test_ssh,
189
- :long => "--[no-]tcp-test-ssh",
190
- :description => "Check that SSH is available using a TCP check directly on port 22, enabled by default",
191
- :boolean => true,
192
- :default => true
200
+ long: "--[no-]tcp-test-ssh",
201
+ description: "Check that SSH is available using a TCP check directly on port 22, enabled by default",
202
+ boolean: true,
203
+ default: true
193
204
 
194
205
  option :ssh_wait_timeout,
195
- :long => "--ssh-wait-timeout TIMEOUT",
196
- :description => "The ssh wait timeout, before attempting ssh",
197
- :default => "0"
206
+ long: "--ssh-wait-timeout TIMEOUT",
207
+ description: "The ssh wait timeout, before attempting ssh",
208
+ default: "0"
198
209
 
199
210
  option :retry_ssh_every,
200
- :long => "--retry-ssh-every TIMEOUT",
201
- :description => "Retry SSH after n seconds (retry each period)",
202
- :default => "5"
211
+ long: "--retry-ssh-every TIMEOUT",
212
+ description: "Retry SSH after n seconds (retry each period)",
213
+ default: "5"
203
214
 
204
215
  option :retry_ssh_limit,
205
- :long => "--retry-ssh-limit COUNT",
206
- :description => "Retry SSH at most this number of times",
207
- :default => "5"
216
+ long: "--retry-ssh-limit COUNT",
217
+ description: "Retry SSH at most this number of times",
218
+ default: "5"
208
219
 
209
220
  option :default_networks,
210
- :long => "--[no-]default-networks",
211
- :description => "Include public and service networks, enabled by default",
212
- :boolean => true,
213
- :default => true
221
+ long: "--[no-]default-networks",
222
+ description: "Include public and service networks, enabled by default",
223
+ boolean: true,
224
+ default: true
214
225
 
215
226
  option :network,
216
- :long => "--network [LABEL_OR_ID]",
217
- :description => "Add private network. Use multiple --network options to specify multiple networks.",
218
- :proc => Proc.new{ |name|
227
+ long: "--network [LABEL_OR_ID]",
228
+ description: "Add private network. Use multiple --network options to specify multiple networks.",
229
+ proc: Proc.new { |name|
219
230
  Chef::Config[:knife][:rackspace_networks] ||= []
220
231
  (Chef::Config[:knife][:rackspace_networks] << name).uniq!
221
232
  }
222
233
 
223
234
  option :bootstrap_protocol,
224
- :long => "--bootstrap-protocol protocol",
225
- :description => "Protocol to bootstrap Windows servers. options: winrm",
226
- :default => nil
235
+ long: "--bootstrap-protocol protocol",
236
+ description: "Protocol to bootstrap Windows servers. options: winrm",
237
+ default: nil
227
238
 
228
239
  option :server_create_timeout,
229
- :long => "--server-create-timeout timeout",
230
- :description => "How long to wait until the server is ready; default is 1200 seconds",
231
- :default => 1200,
232
- :proc => Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v }
240
+ long: "--server-create-timeout timeout",
241
+ description: "How long to wait until the server is ready; default is 1200 seconds",
242
+ default: 1200,
243
+ proc: Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v }
233
244
 
234
245
  option :bootstrap_proxy,
235
- :long => "--bootstrap-proxy PROXY_URL",
236
- :description => "The proxy server for the node being bootstrapped",
237
- :proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_proxy] = v }
246
+ long: "--bootstrap-proxy PROXY_URL",
247
+ description: "The proxy server for the node being bootstrapped",
248
+ proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_proxy] = v }
238
249
 
239
250
  option :rackspace_disk_config,
240
- :long => "--rackspace-disk-config DISKCONFIG",
241
- :description => "Specify if want to manage your own disk partitioning scheme (AUTO or MANUAL)",
242
- :proc => Proc.new { |k| Chef::Config[:knife][:rackspace_disk_config] = k }
251
+ long: "--rackspace-disk-config DISKCONFIG",
252
+ description: "Specify if want to manage your own disk partitioning scheme (AUTO or MANUAL)",
253
+ proc: Proc.new { |k| Chef::Config[:knife][:rackspace_disk_config] = k }
243
254
 
244
255
  option :rackspace_config_drive,
245
- :long => "--rackspace_config_drive CONFIGDRIVE",
246
- :description => "Creates a config drive device in /dev/disk/by-label/config-2 if set to TRUE",
247
- :proc => Proc.new { |k| Chef::Config[:knife][:rackspace_config_drive] = k },
248
- :default => "false"
256
+ long: "--rackspace_config_drive CONFIGDRIVE",
257
+ description: "Creates a config drive device in /dev/disk/by-label/config-2 if set to TRUE",
258
+ proc: Proc.new { |k| Chef::Config[:knife][:rackspace_config_drive] = k },
259
+ default: "false"
249
260
 
250
261
  option :rackspace_user_data_file,
251
- :long => "--rackspace_user_data_file USERDATA",
252
- :description => "User data file will be placed in the openstack/latest/user_data directory on the config drive",
253
- :proc => Proc.new { |k| Chef::Config[:knife][:rackspace_user_data] = k }
262
+ long: "--rackspace_user_data_file USERDATA",
263
+ description: "User data file will be placed in the openstack/latest/user_data directory on the config drive",
264
+ proc: Proc.new { |k| Chef::Config[:knife][:rackspace_user_data] = k }
254
265
 
255
266
  option :ssh_keypair,
256
- :long => "--ssh-keypair KEYPAIR_NAME",
257
- :description => "Name of existing nova SSH keypair. Public key will be injected into the instance.",
258
- :proc => Proc.new { |v| Chef::Config[:knife][:rackspace_ssh_keypair] = v },
259
- :default => nil
267
+ long: "--ssh-keypair KEYPAIR_NAME",
268
+ description: "Name of existing nova SSH keypair. Public key will be injected into the instance.",
269
+ proc: Proc.new { |v| Chef::Config[:knife][:rackspace_ssh_keypair] = v },
270
+ default: nil
271
+
272
+ option :secret,
273
+ long: "--secret",
274
+ description: "The secret key to us to encrypt data bag item values",
275
+ proc: lambda { |s| Chef::Config[:knife][:secret] = s }
260
276
 
261
277
  option :secret_file,
262
- :long => "--secret-file SECRET_FILE",
263
- :description => "A file containing the secret key to use to encrypt data bag item values",
264
- :proc => Proc.new { |sf| Chef::Config[:knife][:secret_file] = sf }
278
+ long: "--secret-file SECRET_FILE",
279
+ description: "A file containing the secret key to use to encrypt data bag item values",
280
+ proc: lambda { |sf| Chef::Config[:knife][:secret_file] = sf }
265
281
 
266
282
  option :bootstrap_vault_file,
267
- :long => "--bootstrap-vault-file VAULT_FILE",
268
- :description => "A JSON file with a list of vault(s) and item(s) to be updated"
283
+ long: "--bootstrap-vault-file VAULT_FILE",
284
+ description: "A JSON file with a list of vault(s) and item(s) to be updated"
269
285
 
270
286
  option :bootstrap_vault_json,
271
- :long => "--bootstrap-vault-json VAULT_JSON",
272
- :description => "A JSON string with the vault(s) and item(s) to be updated"
287
+ long: "--bootstrap-vault-json VAULT_JSON",
288
+ description: "A JSON string with the vault(s) and item(s) to be updated"
273
289
 
274
290
  option :bootstrap_vault_item,
275
- :long => "--bootstrap-vault-item VAULT_ITEM",
276
- :description => 'A single vault and item to update as "vault:item"',
277
- :proc => Proc.new { |i|
291
+ long: "--bootstrap-vault-item VAULT_ITEM",
292
+ description: 'A single vault and item to update as "vault:item"',
293
+ proc: Proc.new { |i|
278
294
  (vault, item) = i.split(/:/)
279
295
  Chef::Config[:knife][:bootstrap_vault_item] ||= {}
280
296
  Chef::Config[:knife][:bootstrap_vault_item][vault] ||= []
@@ -284,20 +300,19 @@ class Chef
284
300
 
285
301
  def load_winrm_deps
286
302
  require "winrm"
287
- require "em-winrm"
303
+ require "chef/knife/winrm"
288
304
  require "chef/knife/bootstrap_windows_winrm"
289
305
  require "chef/knife/core/windows_bootstrap_context"
290
- require "chef/knife/winrm"
291
306
  end
292
307
 
293
308
  def tcp_test_ssh(server, bootstrap_ip)
294
- return true unless locate_config_value(:tcp_test_ssh) != nil
309
+ return true if locate_config_value(:tcp_test_ssh).nil?
295
310
 
296
311
  limit = locate_config_value(:retry_ssh_limit).to_i
297
312
  count = 0
298
313
 
299
314
  begin
300
- Net::SSH.start(bootstrap_ip, "root", :password => server.password ) do |ssh|
315
+ Net::SSH.start(bootstrap_ip, "root", password: server.password ) do |ssh|
301
316
  Chef::Log.debug("sshd accepting connections on #{bootstrap_ip}")
302
317
  break
303
318
  end
@@ -343,16 +358,16 @@ class Chef
343
358
  dest, src = parse_file_argument(arg)
344
359
  Chef::Log.debug("Inject file #{src} into #{dest}")
345
360
  files << {
346
- :path => dest,
347
- :contents => encode_file(src),
361
+ path: dest,
362
+ contents: encode_file(src),
348
363
  }
349
364
  end
350
365
  files
351
366
  end
352
367
 
353
368
  def tcp_test_winrm(hostname, port)
354
- TCPSocket.new(hostname, port)
355
- return true
369
+ tcp_socket = TCPSocket.new(hostname, port)
370
+ true
356
371
  rescue SocketError
357
372
  sleep 2
358
373
  false
@@ -369,20 +384,21 @@ class Chef
369
384
  rescue Errno::ENETUNREACH
370
385
  sleep 2
371
386
  false
387
+ tcp_socket && tcp_socket.close
372
388
  end
373
389
 
374
390
  def run
375
391
  $stdout.sync = true
376
392
 
377
393
  server_create_options = {
378
- :metadata => locate_config_value(:rackspace_metadata),
379
- :disk_config => locate_config_value(:rackspace_disk_config),
380
- :user_data => user_data,
381
- :config_drive => locate_config_value(:rackspace_config_drive) || false,
382
- :personality => files,
383
- :key_name => locate_config_value(:rackspace_ssh_keypair),
384
- :name => get_node_name(config[:chef_node_name] || config[:server_name]),
385
- :networks => get_networks(locate_config_value(:rackspace_networks), locate_config_value(:rackconnect_v3_network_id)),
394
+ metadata: locate_config_value(:rackspace_metadata),
395
+ disk_config: locate_config_value(:rackspace_disk_config),
396
+ user_data: user_data,
397
+ config_drive: locate_config_value(:rackspace_config_drive) || false,
398
+ personality: files,
399
+ key_name: locate_config_value(:rackspace_ssh_keypair),
400
+ name: get_node_name(config[:chef_node_name] || config[:server_name]),
401
+ networks: get_networks(locate_config_value(:rackspace_networks), locate_config_value(:rackconnect_v3_network_id)),
386
402
  }
387
403
 
388
404
  # Maybe deprecate this option at some point
@@ -415,7 +431,7 @@ class Chef
415
431
  else
416
432
  server_create_options[:image_id] = locate_config_value(:image)
417
433
 
418
- if !server_create_options[:image_id]
434
+ unless server_create_options[:image_id]
419
435
  ui.error("Please specify an Image ID for the server with --image (-I)")
420
436
  exit 1
421
437
  end
@@ -430,7 +446,7 @@ class Chef
430
446
  if version_one?
431
447
  server.save
432
448
  else
433
- server.save(:networks => server_create_options[:networks])
449
+ server.save(networks: server_create_options[:networks])
434
450
  end
435
451
 
436
452
  rackconnect_wait = locate_config_value(:rackconnect_wait)
@@ -453,18 +469,18 @@ class Chef
453
469
  # wait for it to be ready to do stuff
454
470
  begin
455
471
  server.wait_for(Integer(locate_config_value(:server_create_timeout))) do
456
- print ".";
472
+ print "."
457
473
  Chef::Log.debug("#{progress}%")
458
474
 
459
475
  if rackconnect_wait && rackspace_servicelevel_wait
460
- Chef::Log.debug("rackconnect_automation_status: #{metadata.all['rackconnect_automation_status']}")
461
- Chef::Log.debug("rax_service_level_automation: #{metadata.all['rax_service_level_automation']}")
476
+ Chef::Log.debug("rackconnect_automation_status: #{metadata.all["rackconnect_automation_status"]}")
477
+ Chef::Log.debug("rax_service_level_automation: #{metadata.all["rax_service_level_automation"]}")
462
478
  ready? && metadata.all["rackconnect_automation_status"] == "DEPLOYED" && metadata.all["rax_service_level_automation"] == "Complete"
463
479
  elsif rackconnect_wait
464
- Chef::Log.debug("rackconnect_automation_status: #{metadata.all['rackconnect_automation_status']}")
480
+ Chef::Log.debug("rackconnect_automation_status: #{metadata.all["rackconnect_automation_status"]}")
465
481
  ready? && metadata.all["rackconnect_automation_status"] == "DEPLOYED"
466
482
  elsif rackspace_servicelevel_wait
467
- Chef::Log.debug("rax_service_level_automation: #{metadata.all['rax_service_level_automation']}")
483
+ Chef::Log.debug("rax_service_level_automation: #{metadata.all["rax_service_level_automation"]}")
468
484
  ready? && metadata.all["rax_service_level_automation"] == "Complete"
469
485
  else
470
486
  ready?
@@ -475,7 +491,7 @@ class Chef
475
491
  msg_pair("Progress", "#{server.progress}%")
476
492
  msg_pair("rackconnect_automation_status", server.metadata.all["rackconnect_automation_status"])
477
493
  msg_pair("rax_service_level_automation", server.metadata.all["rax_service_level_automation"])
478
- Chef::Application.fatal! 'Server didn\'t finish on time'
494
+ Chef::Application.fatal! "Server didn't finish on time"
479
495
  end
480
496
 
481
497
  msg_pair("Metadata", server.metadata)
@@ -584,7 +600,6 @@ class Chef
584
600
  bootstrap.config[:bootstrap_vault_item] = locate_config_value(:bootstrap_vault_item) if locate_config_value(:bootstrap_vault_item)
585
601
  # bootstrap will run as root...sudo (by default) also messes up Ohai on CentOS boxes
586
602
  bootstrap.config[:use_sudo] = true unless locate_config_value(:ssh_user) == "root"
587
- bootstrap.config[:distro] = locate_config_value(:distro) || "chef-full"
588
603
  bootstrap_common_params(bootstrap, server)
589
604
  end
590
605
 
@@ -598,14 +613,13 @@ class Chef
598
613
  end
599
614
  bootstrap.config[:prerelease] = locate_config_value(:prerelease)
600
615
  bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
601
- bootstrap.config[:template_file] = locate_config_value(:template_file)
616
+ bootstrap.config[:bootstrap_template] = locate_config_value(:bootstrap_template)
602
617
  bootstrap.config[:first_boot_attributes] = locate_config_value(:first_boot_attributes)
603
618
  bootstrap.config[:bootstrap_proxy] = locate_config_value(:bootstrap_proxy)
604
- # TODO: Remove dead code. There's no command line parameter for these two.
605
- # bootstrap.config[:encrypted_data_bag_secret] = config[:encrypted_data_bag_secret]
606
- # bootstrap.config[:encrypted_data_bag_secret_file] = config[:encrypted_data_bag_secret_file]
619
+ bootstrap.config[:encrypted_data_bag_secret] = locate_config_value(:secret)
620
+ bootstrap.config[:encrypted_data_bag_secret_file] = locate_config_value(:secret_file)
607
621
  bootstrap.config[:secret] = locate_config_value(:secret)
608
- bootstrap.config[:secret_file] = locate_config_value(:secret_file) || ""
622
+ bootstrap.config[:secret_file] = locate_config_value(:secret_file)
609
623
 
610
624
  Chef::Config[:knife][:hints] ||= {}
611
625
  Chef::Config[:knife][:hints]["rackspace"] ||= {}
@@ -624,10 +638,11 @@ class Chef
624
638
  end
625
639
 
626
640
  end
627
- #v2 servers require a name, random if chef_node_name is empty, empty if v1
641
+ # v2 servers require a name, random if chef_node_name is empty, empty if v1
628
642
  def get_node_name(chef_node_name)
629
643
  return chef_node_name unless chef_node_name.nil?
630
- #lazy uuids
644
+
645
+ # lazy uuids
631
646
  chef_node_name = "rs-" + rand.to_s.split(".")[1] unless version_one?
632
647
  end
633
648
 
@@ -638,10 +653,10 @@ class Chef
638
653
  nets = if rackconnect3
639
654
  [locate_config_value(:rackconnect_v3_network_id)]
640
655
  elsif locate_config_value(:default_networks)
641
- [
642
- "00000000-0000-0000-0000-000000000000",
643
- "11111111-1111-1111-1111-111111111111",
644
- ]
656
+ %w{
657
+ 00000000-0000-0000-0000-000000000000
658
+ 11111111-1111-1111-1111-111111111111
659
+ }
645
660
  else
646
661
  []
647
662
  end