knife-azure 1.9.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/azure/azure_interface.rb +2 -3
- data/lib/azure/custom_errors.rb +1 -1
- data/lib/azure/helpers.rb +1 -1
- data/lib/azure/resource_management/ARM_deployment_template.rb +157 -162
- data/lib/azure/resource_management/ARM_interface.rb +72 -73
- data/lib/azure/resource_management/vnet_config.rb +11 -10
- data/lib/azure/resource_management/windows_credentials.rb +19 -19
- data/lib/azure/service_management/ASM_interface.rb +6 -5
- data/lib/azure/service_management/ag.rb +11 -11
- data/lib/azure/service_management/certificate.rb +7 -5
- data/lib/azure/service_management/connection.rb +10 -10
- data/lib/azure/service_management/deploy.rb +12 -14
- data/lib/azure/service_management/disk.rb +4 -2
- data/lib/azure/service_management/host.rb +7 -4
- data/lib/azure/service_management/image.rb +4 -4
- data/lib/azure/service_management/loadbalancer.rb +2 -2
- data/lib/azure/service_management/rest.rb +9 -8
- data/lib/azure/service_management/role.rb +67 -70
- data/lib/azure/service_management/storageaccount.rb +5 -3
- data/lib/azure/service_management/utility.rb +1 -1
- data/lib/azure/service_management/vnet.rb +1 -1
- data/lib/chef/knife/azure_ag_create.rb +13 -13
- data/lib/chef/knife/azure_ag_list.rb +1 -1
- data/lib/chef/knife/azure_base.rb +49 -66
- data/lib/chef/knife/azure_image_list.rb +6 -6
- data/lib/chef/knife/azure_internal-lb_create.rb +14 -14
- data/lib/chef/knife/azure_internal-lb_list.rb +1 -1
- data/lib/chef/knife/azure_server_create.rb +233 -268
- data/lib/chef/knife/azure_server_delete.rb +31 -31
- data/lib/chef/knife/azure_server_list.rb +1 -1
- data/lib/chef/knife/azure_server_show.rb +1 -1
- data/lib/chef/knife/azure_vnet_create.rb +15 -19
- data/lib/chef/knife/azure_vnet_list.rb +1 -1
- data/lib/chef/knife/azurerm_base.rb +39 -28
- data/lib/chef/knife/azurerm_server_create.rb +112 -177
- data/lib/chef/knife/azurerm_server_delete.rb +13 -13
- data/lib/chef/knife/azurerm_server_list.rb +1 -1
- data/lib/chef/knife/azurerm_server_show.rb +1 -1
- data/lib/chef/knife/bootstrap/bootstrapper.rb +34 -238
- data/lib/chef/knife/bootstrap/common_bootstrap_options.rb +77 -76
- data/lib/chef/knife/bootstrap_azure.rb +56 -33
- data/lib/chef/knife/bootstrap_azurerm.rb +46 -29
- data/lib/knife-azure/version.rb +18 -1
- metadata +28 -16
- data/lib/chef/knife/bootstrap/bootstrap_options.rb +0 -105
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Barry Davis (barryd@jetstreamsoftware.com)
|
3
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
4
4
|
# Author:: Seth Chisamore (<schisamo@chef.io>)
|
5
|
-
# Copyright:: Copyright
|
5
|
+
# Copyright:: Copyright 2010-2019, Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -33,22 +33,22 @@ class Chef
|
|
33
33
|
banner "knife azurerm server delete SERVER [SERVER] (options)"
|
34
34
|
|
35
35
|
option :purge,
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
36
|
+
short: "-P",
|
37
|
+
long: "--purge",
|
38
|
+
boolean: true,
|
39
|
+
default: false,
|
40
|
+
description: "Destroy corresponding node and client on the Chef Server, in addition to destroying the Windows Azure node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)."
|
41
41
|
|
42
42
|
option :chef_node_name,
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
43
|
+
short: "-N NAME",
|
44
|
+
long: "--node-name NAME",
|
45
|
+
description: "The name of the node and client to delete, if it differs from the server name. Only has meaning when used with the '--purge' option."
|
46
46
|
|
47
47
|
option :delete_resource_group,
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
48
|
+
long: "--delete-resource-group",
|
49
|
+
boolean: true,
|
50
|
+
default: false,
|
51
|
+
description: "Deletes corresponding resource group along with Vitual Machine."
|
52
52
|
|
53
53
|
# Extracted from Chef::Knife.delete_object, because it has a
|
54
54
|
# confirmation step built in... By specifying the '--purge'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright
|
3
|
+
# Copyright:: Copyright 2010-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Meera Navale (meera.navale@msystechnologies.com)
|
3
|
-
# Copyright:: Copyright 2010-
|
3
|
+
# Copyright:: Copyright 2010-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com)
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright 2016-2018 Chef Software, Inc.
|
3
|
+
# Copyright:: Copyright 2010-2019, Chef Software Inc.
|
5
4
|
# License:: Apache License, Version 2.0
|
6
5
|
#
|
7
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -22,209 +21,6 @@ class Chef
|
|
22
21
|
class Bootstrap
|
23
22
|
module Bootstrapper
|
24
23
|
|
25
|
-
def load_winrm_deps
|
26
|
-
require "winrm"
|
27
|
-
require "chef/knife/winrm"
|
28
|
-
require "chef/knife/bootstrap_windows_winrm"
|
29
|
-
end
|
30
|
-
|
31
|
-
def default_bootstrap_template
|
32
|
-
is_image_windows? ? "windows-chef-client-msi" : "chef-full"
|
33
|
-
end
|
34
|
-
|
35
|
-
def tcp_test_ssh(fqdn, sshport)
|
36
|
-
tcp_socket = TCPSocket.new(fqdn, sshport)
|
37
|
-
readable = IO.select([tcp_socket], nil, nil, 5)
|
38
|
-
if readable
|
39
|
-
Chef::Log.debug("sshd accepting connections on #{fqdn}, banner is #{tcp_socket.gets}")
|
40
|
-
yield
|
41
|
-
true
|
42
|
-
else
|
43
|
-
false
|
44
|
-
end
|
45
|
-
rescue SocketError
|
46
|
-
sleep 2
|
47
|
-
false
|
48
|
-
rescue Errno::ETIMEDOUT
|
49
|
-
false
|
50
|
-
rescue Errno::EPERM
|
51
|
-
false
|
52
|
-
rescue Errno::ECONNREFUSED
|
53
|
-
sleep 2
|
54
|
-
false
|
55
|
-
rescue Errno::EHOSTUNREACH
|
56
|
-
sleep 2
|
57
|
-
false
|
58
|
-
ensure
|
59
|
-
tcp_socket && tcp_socket.close
|
60
|
-
end
|
61
|
-
|
62
|
-
def tcp_test_winrm(ip_addr, port)
|
63
|
-
hostname = ip_addr
|
64
|
-
socket = TCPSocket.new(hostname, port)
|
65
|
-
true
|
66
|
-
rescue SocketError
|
67
|
-
sleep 2
|
68
|
-
false
|
69
|
-
rescue Errno::ETIMEDOUT
|
70
|
-
false
|
71
|
-
rescue Errno::EPERM
|
72
|
-
false
|
73
|
-
rescue Errno::ECONNREFUSED
|
74
|
-
sleep 2
|
75
|
-
false
|
76
|
-
rescue Errno::EHOSTUNREACH
|
77
|
-
sleep 2
|
78
|
-
false
|
79
|
-
rescue Errno::ENETUNREACH
|
80
|
-
sleep 2
|
81
|
-
false
|
82
|
-
end
|
83
|
-
|
84
|
-
def bootstrap_exec(server)
|
85
|
-
fqdn = server.publicipaddress
|
86
|
-
|
87
|
-
if is_image_windows?
|
88
|
-
if locate_config_value(:bootstrap_protocol) == "ssh"
|
89
|
-
port = server.sshport
|
90
|
-
print "#{ui.color("Waiting for sshd on #{fqdn}:#{port}", :magenta)}"
|
91
|
-
|
92
|
-
print(".") until tcp_test_ssh(fqdn, port) do
|
93
|
-
sleep @initial_sleep_delay ||= 10
|
94
|
-
puts("done")
|
95
|
-
end
|
96
|
-
|
97
|
-
elsif locate_config_value(:bootstrap_protocol) == "winrm"
|
98
|
-
port = server.winrmport
|
99
|
-
|
100
|
-
print "#{ui.color("Waiting for winrm on #{fqdn}:#{port}", :magenta)}"
|
101
|
-
|
102
|
-
print(".") until tcp_test_winrm(fqdn, port) do
|
103
|
-
sleep @initial_sleep_delay ||= 10
|
104
|
-
puts("done")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
puts("\n")
|
109
|
-
bootstrap_for_windows_node(server, fqdn, port).run
|
110
|
-
else
|
111
|
-
unless server && server.publicipaddress && server.sshport
|
112
|
-
Chef::Log.fatal("server not created")
|
113
|
-
exit 1
|
114
|
-
end
|
115
|
-
|
116
|
-
port = server.sshport
|
117
|
-
|
118
|
-
print ui.color("Waiting for sshd on #{fqdn}:#{port}", :magenta)
|
119
|
-
|
120
|
-
print(".") until tcp_test_ssh(fqdn, port) do
|
121
|
-
sleep @initial_sleep_delay ||= 10
|
122
|
-
puts("done")
|
123
|
-
end
|
124
|
-
|
125
|
-
puts("\n")
|
126
|
-
bootstrap_for_node(server, fqdn, port).run
|
127
|
-
end
|
128
|
-
|
129
|
-
msg_server_summary(server)
|
130
|
-
end
|
131
|
-
|
132
|
-
def load_cloud_attributes_in_hints(server)
|
133
|
-
# Modify global configuration state to ensure hint gets set by knife-bootstrap
|
134
|
-
# Query azure and load necessary attributes.
|
135
|
-
cloud_attributes = {}
|
136
|
-
cloud_attributes["public_ip"] = server.publicipaddress
|
137
|
-
cloud_attributes["vm_name"] = server.name
|
138
|
-
cloud_attributes["public_fqdn"] = server.hostedservicename.to_s + ".cloudapp.net"
|
139
|
-
cloud_attributes["public_ssh_port"] = server.sshport if server.sshport
|
140
|
-
cloud_attributes["public_winrm_port"] = server.winrmport if server.winrmport
|
141
|
-
|
142
|
-
Chef::Config[:knife][:hints] ||= {}
|
143
|
-
Chef::Config[:knife][:hints]["azure"] ||= cloud_attributes
|
144
|
-
end
|
145
|
-
|
146
|
-
def bootstrap_common_params(bootstrap, server)
|
147
|
-
bootstrap.config[:run_list] = locate_config_value(:run_list)
|
148
|
-
bootstrap.config[:prerelease] = locate_config_value(:prerelease)
|
149
|
-
bootstrap.config[:first_boot_attributes] = locate_config_value(:json_attributes) || {}
|
150
|
-
bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
|
151
|
-
bootstrap.config[:distro] = locate_config_value(:distro) || default_bootstrap_template
|
152
|
-
# setting bootstrap_template value to template_file for backward
|
153
|
-
bootstrap.config[:template_file] = locate_config_value(:template_file) || locate_config_value(:bootstrap_template)
|
154
|
-
bootstrap.config[:node_ssl_verify_mode] = locate_config_value(:node_ssl_verify_mode)
|
155
|
-
bootstrap.config[:node_verify_api_cert] = locate_config_value(:node_verify_api_cert)
|
156
|
-
bootstrap.config[:bootstrap_no_proxy] = locate_config_value(:bootstrap_no_proxy)
|
157
|
-
bootstrap.config[:bootstrap_url] = locate_config_value(:bootstrap_url)
|
158
|
-
bootstrap.config[:bootstrap_vault_file] = locate_config_value(:bootstrap_vault_file)
|
159
|
-
bootstrap.config[:bootstrap_vault_json] = locate_config_value(:bootstrap_vault_json)
|
160
|
-
bootstrap.config[:bootstrap_vault_item] = locate_config_value(:bootstrap_vault_item)
|
161
|
-
|
162
|
-
load_cloud_attributes_in_hints(server)
|
163
|
-
bootstrap
|
164
|
-
end
|
165
|
-
|
166
|
-
def bootstrap_for_windows_node(server, fqdn, port)
|
167
|
-
if locate_config_value(:bootstrap_protocol) == "winrm"
|
168
|
-
|
169
|
-
load_winrm_deps
|
170
|
-
if not Chef::Platform.windows?
|
171
|
-
require "gssapi"
|
172
|
-
end
|
173
|
-
|
174
|
-
bootstrap = Chef::Knife::BootstrapWindowsWinrm.new
|
175
|
-
|
176
|
-
bootstrap.config[:winrm_user] = locate_config_value(:winrm_user) || "Administrator"
|
177
|
-
bootstrap.config[:winrm_password] = locate_config_value(:winrm_password)
|
178
|
-
bootstrap.config[:winrm_transport] = locate_config_value(:winrm_transport)
|
179
|
-
bootstrap.config[:winrm_authentication_protocol] = locate_config_value(:winrm_authentication_protocol)
|
180
|
-
bootstrap.config[:winrm_port] = port
|
181
|
-
bootstrap.config[:auth_timeout] = locate_config_value(:auth_timeout)
|
182
|
-
# Todo: we should skip cert generate in case when winrm_ssl_verify_mode=verify_none
|
183
|
-
bootstrap.config[:winrm_ssl_verify_mode] = locate_config_value(:winrm_ssl_verify_mode)
|
184
|
-
elsif locate_config_value(:bootstrap_protocol) == "ssh"
|
185
|
-
bootstrap = Chef::Knife::BootstrapWindowsSsh.new
|
186
|
-
bootstrap.config[:ssh_user] = locate_config_value(:ssh_user)
|
187
|
-
bootstrap.config[:ssh_password] = locate_config_value(:ssh_password)
|
188
|
-
bootstrap.config[:forward_agent] = locate_config_value(:forward_agent)
|
189
|
-
bootstrap.config[:ssh_port] = port
|
190
|
-
bootstrap.config[:identity_file] = locate_config_value(:identity_file)
|
191
|
-
bootstrap.config[:host_key_verify] = locate_config_value(:host_key_verify)
|
192
|
-
else
|
193
|
-
ui.error("Unsupported Bootstrapping Protocol. Supported : winrm, ssh")
|
194
|
-
exit 1
|
195
|
-
end
|
196
|
-
bootstrap.name_args = [fqdn]
|
197
|
-
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.name
|
198
|
-
bootstrap.config[:encrypted_data_bag_secret] = locate_config_value(:encrypted_data_bag_secret)
|
199
|
-
bootstrap.config[:encrypted_data_bag_secret_file] = locate_config_value(:encrypted_data_bag_secret_file)
|
200
|
-
bootstrap.config[:msi_url] = locate_config_value(:msi_url)
|
201
|
-
bootstrap.config[:install_as_service] = locate_config_value(:install_as_service)
|
202
|
-
bootstrap_common_params(bootstrap, server)
|
203
|
-
end
|
204
|
-
|
205
|
-
def bootstrap_for_node(server, fqdn, port)
|
206
|
-
bootstrap = Chef::Knife::Bootstrap.new
|
207
|
-
bootstrap.name_args = [fqdn]
|
208
|
-
bootstrap.config[:ssh_user] = locate_config_value(:ssh_user)
|
209
|
-
bootstrap.config[:ssh_password] = locate_config_value(:ssh_password)
|
210
|
-
bootstrap.config[:ssh_port] = port
|
211
|
-
bootstrap.config[:identity_file] = locate_config_value(:identity_file)
|
212
|
-
bootstrap.config[:chef_node_name] = locate_config_value(:chef_node_name) || server.name
|
213
|
-
bootstrap.config[:use_sudo] = true unless locate_config_value(:ssh_user) == "root"
|
214
|
-
bootstrap.config[:use_sudo_password] = true if bootstrap.config[:use_sudo]
|
215
|
-
bootstrap.config[:environment] = locate_config_value(:environment)
|
216
|
-
# may be needed for vpc_mode
|
217
|
-
bootstrap.config[:host_key_verify] = config[:host_key_verify]
|
218
|
-
Chef::Config[:knife][:secret] = config[:encrypted_data_bag_secret] if config[:encrypted_data_bag_secret]
|
219
|
-
Chef::Config[:knife][:secret_file] = config[:encrypted_data_bag_secret_file] if config[:encrypted_data_bag_secret_file]
|
220
|
-
bootstrap.config[:secret] = locate_config_value(:encrypted_data_bag_secret)
|
221
|
-
bootstrap.config[:secret_file] = locate_config_value(:encrypted_data_bag_secret_file)
|
222
|
-
bootstrap.config[:bootstrap_install_command] = locate_config_value(:bootstrap_install_command)
|
223
|
-
bootstrap.config[:bootstrap_wget_options] = locate_config_value(:bootstrap_wget_options)
|
224
|
-
bootstrap.config[:bootstrap_curl_options] = locate_config_value(:bootstrap_curl_options)
|
225
|
-
bootstrap_common_params(bootstrap, server)
|
226
|
-
end
|
227
|
-
|
228
24
|
def get_chef_extension_name
|
229
25
|
is_image_windows? ? "ChefClient" : "LinuxChefClient"
|
230
26
|
end
|
@@ -233,18 +29,26 @@ class Chef
|
|
233
29
|
"Chef.Bootstrap.WindowsAzure"
|
234
30
|
end
|
235
31
|
|
32
|
+
def default_hint_options
|
33
|
+
%w{
|
34
|
+
vm_name
|
35
|
+
public_fqdn
|
36
|
+
platform
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
236
40
|
# get latest version
|
237
41
|
def get_chef_extension_version(chef_extension_name = nil)
|
238
42
|
if locate_config_value(:azure_chef_extension_version)
|
239
43
|
Chef::Config[:knife][:azure_chef_extension_version]
|
240
44
|
else
|
241
|
-
chef_extension_name
|
45
|
+
chef_extension_name ||= get_chef_extension_name
|
242
46
|
if @service.instance_of? Azure::ResourceManagement::ARMInterface
|
243
|
-
service.get_latest_chef_extension_version(
|
244
|
-
:
|
245
|
-
:
|
246
|
-
:
|
247
|
-
|
47
|
+
service.get_latest_chef_extension_version(
|
48
|
+
azure_service_location: locate_config_value(:azure_service_location),
|
49
|
+
chef_extension_publisher: get_chef_extension_publisher,
|
50
|
+
chef_extension: chef_extension_name
|
51
|
+
)
|
248
52
|
elsif @service.instance_of? Azure::ServiceManagement::ASMInterface
|
249
53
|
extensions = service.get_extension(chef_extension_name, get_chef_extension_publisher)
|
250
54
|
extensions.css("Version").max.text.split(".").first + ".*"
|
@@ -252,28 +56,17 @@ class Chef
|
|
252
56
|
end
|
253
57
|
end
|
254
58
|
|
255
|
-
def default_hint_options
|
256
|
-
%w{
|
257
|
-
vm_name
|
258
|
-
public_fqdn
|
259
|
-
platform
|
260
|
-
}
|
261
|
-
end
|
262
|
-
|
263
59
|
def ohai_hints
|
264
60
|
hint_values = locate_config_value(:ohai_hints)
|
265
|
-
|
266
|
-
|
267
|
-
hints = default_hint_options
|
61
|
+
if hint_values.casecmp("default") == 0
|
62
|
+
default_hint_options
|
268
63
|
else
|
269
|
-
|
64
|
+
hint_values.split(",")
|
270
65
|
end
|
271
|
-
|
272
|
-
hints
|
273
66
|
end
|
274
67
|
|
275
68
|
def get_chef_extension_public_params
|
276
|
-
pub_config =
|
69
|
+
pub_config = {}
|
277
70
|
if locate_config_value(:azure_extension_client_config)
|
278
71
|
pub_config[:client_rb] = File.read(File.expand_path(locate_config_value(:azure_extension_client_config)))
|
279
72
|
else
|
@@ -306,30 +99,32 @@ class Chef
|
|
306
99
|
cli_secret_file = config[:encrypted_data_bag_secret_file]
|
307
100
|
cli_secret = config[:encrypted_data_bag_secret]
|
308
101
|
|
309
|
-
#The value set in knife.rb gets set in config object too
|
310
|
-
#That's why setting cli objects to nil if the values are specified in knife.rb
|
102
|
+
# The value set in knife.rb gets set in config object too
|
103
|
+
# That's why setting cli objects to nil if the values are specified in knife.rb
|
311
104
|
cli_secret_file = nil if cli_secret_file == knife_secret_file
|
312
105
|
cli_secret = nil if cli_secret == knife_secret
|
313
106
|
|
314
|
-
cli_secret_file = Chef::EncryptedDataBagItem.load_secret(cli_secret_file)
|
315
|
-
knife_secret_file = Chef::EncryptedDataBagItem.load_secret(knife_secret_file)
|
107
|
+
cli_secret_file = Chef::EncryptedDataBagItem.load_secret(cli_secret_file) unless cli_secret_file.nil?
|
108
|
+
knife_secret_file = Chef::EncryptedDataBagItem.load_secret(knife_secret_file) unless knife_secret_file.nil?
|
316
109
|
|
317
110
|
cli_secret_file || cli_secret || knife_secret_file || knife_secret
|
318
111
|
end
|
319
112
|
|
320
113
|
def create_node_and_client_pem
|
321
|
-
client_builder
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
114
|
+
client_builder ||= begin
|
115
|
+
require "chef/knife/bootstrap/client_builder"
|
116
|
+
Chef::Knife::Bootstrap::ClientBuilder.new(
|
117
|
+
chef_config: Chef::Config,
|
118
|
+
knife_config: config,
|
119
|
+
ui: ui
|
120
|
+
)
|
121
|
+
end
|
326
122
|
client_builder.run
|
327
123
|
client_builder.client_path
|
328
124
|
end
|
329
125
|
|
330
126
|
def get_chef_extension_private_params
|
331
|
-
pri_config =
|
332
|
-
|
127
|
+
pri_config = {}
|
333
128
|
# validator less bootstrap support for bootstrap protocol cloud-api
|
334
129
|
if Chef::Config[:validation_key] && File.exist?(File.expand_path(Chef::Config[:validation_key]))
|
335
130
|
pri_config[:validation_key] = File.read(File.expand_path(Chef::Config[:validation_key]))
|
@@ -340,7 +135,7 @@ class Chef
|
|
340
135
|
end
|
341
136
|
if config[:server_count].to_i > 1
|
342
137
|
node_name = config[:chef_node_name]
|
343
|
-
0.upto
|
138
|
+
0.upto(config[:server_count].to_i - 1) do |count|
|
344
139
|
config[:chef_node_name] = node_name + count.to_s
|
345
140
|
key_path = create_node_and_client_pem
|
346
141
|
pri_config[("client_pem" + count.to_s).to_sym] = File.read(key_path)
|
@@ -372,6 +167,7 @@ class Chef
|
|
372
167
|
|
373
168
|
pri_config
|
374
169
|
end
|
170
|
+
|
375
171
|
end
|
376
172
|
end
|
377
173
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com)
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright 2016-2018 Chef Software, Inc.
|
3
|
+
# Copyright:: Copyright 2010-2019, Chef Software Inc.
|
5
4
|
# License:: Apache License, Version 2.0
|
6
5
|
#
|
7
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,9 +15,6 @@
|
|
16
15
|
# See the License for the specific language governing permissions and
|
17
16
|
# limitations under the License.
|
18
17
|
#
|
19
|
-
#
|
20
|
-
# Bootstrap options listed here are supported only for cloud-api protocol ARM mode.
|
21
|
-
#
|
22
18
|
|
23
19
|
class Chef
|
24
20
|
class Knife
|
@@ -33,84 +29,89 @@ class Chef
|
|
33
29
|
Chef::Knife::Bootstrap.load_deps
|
34
30
|
end
|
35
31
|
|
36
|
-
option :
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:description => "The Chef node name for your new node"
|
40
|
-
|
41
|
-
option :bootstrap_version,
|
42
|
-
:long => "--bootstrap-version VERSION",
|
43
|
-
:description => "The version of Chef to install",
|
44
|
-
:proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
|
45
|
-
|
46
|
-
option :run_list,
|
47
|
-
:short => "-r RUN_LIST",
|
48
|
-
:long => "--run-list RUN_LIST",
|
49
|
-
:description => "Comma separated list of roles/recipes to apply",
|
50
|
-
:proc => lambda { |o| o.split(/[\s,]+/) },
|
51
|
-
:default => []
|
52
|
-
|
53
|
-
option :json_attributes,
|
54
|
-
:short => "-j JSON",
|
55
|
-
:long => "--json-attributes JSON",
|
56
|
-
:description => "A JSON string to be added to the first run of chef-client",
|
57
|
-
:proc => lambda { |o| JSON.parse(o) }
|
58
|
-
|
59
|
-
option :bootstrap_proxy,
|
60
|
-
:long => "--bootstrap-proxy PROXY_URL",
|
61
|
-
:description => "The proxy server for the node being bootstrapped",
|
62
|
-
:proc => Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
|
63
|
-
|
64
|
-
option :cert_path,
|
65
|
-
:long => "--cert-path PATH",
|
66
|
-
:description => "SSL Certificate Path"
|
67
|
-
|
68
|
-
option :node_ssl_verify_mode,
|
69
|
-
:long => "--node-ssl-verify-mode [peer|none]",
|
70
|
-
:description => "Whether or not to verify the SSL cert for all HTTPS requests.",
|
71
|
-
:proc => Proc.new { |v|
|
72
|
-
valid_values = %w{none peer}
|
73
|
-
unless valid_values.include?(v)
|
74
|
-
raise "Invalid value '#{v}' for --node-ssl-verify-mode. Valid values are: #{valid_values.join(", ")}"
|
75
|
-
end
|
76
|
-
}
|
77
|
-
|
78
|
-
option :node_verify_api_cert,
|
79
|
-
:long => "--[no-]node-verify-api-cert",
|
80
|
-
:description => "Verify the SSL cert for HTTPS requests to the Chef server API.",
|
81
|
-
:boolean => true
|
32
|
+
option :azure_availability_set,
|
33
|
+
long: "--azure-availability-set NAME",
|
34
|
+
description: "Optional. Name of availability set to add virtual machine into."
|
82
35
|
|
83
36
|
option :azure_extension_client_config,
|
84
|
-
:
|
85
|
-
:
|
86
|
-
|
87
|
-
option :
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
37
|
+
long: "--azure-extension-client-config CLIENT_PATH",
|
38
|
+
description: "Optional. Path to a client.rb file for use by the bootstrapped node."
|
39
|
+
|
40
|
+
option :azure_os_disk_name,
|
41
|
+
short: "-o DISKNAME",
|
42
|
+
long: "--azure-os-disk-name DISKNAME",
|
43
|
+
description: "Optional. Specifies the friendly name of the disk containing the guest OS image in the image repository."
|
44
|
+
|
45
|
+
option :azure_service_location,
|
46
|
+
short: "-m LOCATION",
|
47
|
+
long: "--azure-service-location LOCATION",
|
48
|
+
description: "Required if not using an Affinity Group. Specifies the geographic location - the name of the data center location that is valid for your subscription.
|
49
|
+
Eg: West US, East US, East Asia, Southeast Asia, North Europe, West Europe",
|
50
|
+
proc: Proc.new { |lo| Chef::Config[:knife][:azure_service_location] = lo }
|
51
|
+
|
52
|
+
option :azure_storage_account,
|
53
|
+
short: "-a NAME",
|
54
|
+
long: "--azure-storage-account NAME",
|
55
|
+
description: "Required for advanced server-create option.
|
56
|
+
A name for the storage account that is unique within Windows Azure. Storage account names must be
|
57
|
+
between 3 and 24 characters in length and use numbers and lower-case letters only.
|
58
|
+
This name is the DNS prefix name and can be used to access blobs, queues, and tables in the storage account.
|
59
|
+
For example: http://ServiceName.blob.core.windows.net/mycontainer/"
|
60
|
+
|
61
|
+
option :azure_vm_name,
|
62
|
+
long: "--azure-vm-name NAME",
|
63
|
+
description: "Required. Specifies the name for the virtual machine.
|
64
|
+
The name must be unique within the ResourceGroup.
|
65
|
+
The azure vm name cannot be more than 15 characters long"
|
66
|
+
|
67
|
+
option :azure_vm_size,
|
68
|
+
short: "-z SIZE",
|
69
|
+
long: "--azure-vm-size SIZE",
|
70
|
+
description: "Optional. Size of virtual machine. Default is Standard_A1_v2.
|
71
|
+
Eg: Standard_A1_v2, Standard_F2, Standard_G1 etc.",
|
72
|
+
default: "Standard_A1_v2",
|
73
|
+
proc: Proc.new { |si| Chef::Config[:knife][:azure_vm_size] = si }
|
74
|
+
|
75
|
+
deprecated_option :bootstrap_protocol,
|
76
|
+
replacement: :connection_protocol,
|
77
|
+
long: "--bootstrap-protocol PROTOCOL"
|
78
|
+
|
79
|
+
option :cert_passphrase,
|
80
|
+
long: "--cert-passphrase PASSWORD",
|
81
|
+
description: "SSL Certificate Password"
|
91
82
|
|
92
|
-
option :
|
93
|
-
:
|
94
|
-
:
|
95
|
-
|
96
|
-
option :extended_logs,
|
97
|
-
:long => "--extended-logs",
|
98
|
-
:boolean => true,
|
99
|
-
:default => false,
|
100
|
-
:description => "Optional. It shows chef convergence logs in detail."
|
83
|
+
option :cert_path,
|
84
|
+
long: "--cert-path PATH",
|
85
|
+
description: "SSL Certificate Path"
|
101
86
|
|
102
87
|
option :chef_daemon_interval,
|
103
|
-
:
|
104
|
-
:
|
105
|
-
|
88
|
+
long: "--chef-daemon-interval INTERVAL",
|
89
|
+
description: "Optional. Provide this option when --connection-protocol is set to 'cloud-api'.
|
90
|
+
It specifies the frequency (in minutes) at which the chef-service runs.
|
91
|
+
Pass 0 if you don't want the chef-service to be installed on the target machine."
|
106
92
|
|
107
93
|
option :daemon,
|
108
|
-
:
|
109
|
-
:
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
94
|
+
long: "--daemon DAEMON",
|
95
|
+
description: "Optional. Configures the chef-client service for unattended execution. Requires --connection-protocol to be 'cloud-api' and the node platform to be Windows.
|
96
|
+
Options: 'none' or 'service' or 'task'.
|
97
|
+
none - Currently prevents the chef-client service from being configured as a service.
|
98
|
+
service - Configures the chef-client to run automatically in the background as a service.
|
99
|
+
task - Configures the chef-client to run automatically in the background as a scheduled task."
|
100
|
+
|
101
|
+
option :extended_logs,
|
102
|
+
long: "--extended-logs",
|
103
|
+
boolean: true,
|
104
|
+
default: false,
|
105
|
+
description: "Optional. Provide this option when --connection-protocol is set to 'cloud-api'. It shows chef converge logs in detail."
|
106
|
+
|
107
|
+
option :tcp_endpoints,
|
108
|
+
short: "-t PORT_LIST",
|
109
|
+
long: "--tcp-endpoints PORT_LIST",
|
110
|
+
description: "Comma-separated list of TCP local and public ports to open e.g. '80:80,433:5000'"
|
111
|
+
|
112
|
+
option :thumbprint,
|
113
|
+
long: "--thumbprint THUMBPRINT",
|
114
|
+
description: "The thumprint of the ssl certificate"
|
114
115
|
end
|
115
116
|
end
|
116
117
|
end
|