knife-azure 1.5.2 → 1.6.0.rc.0

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: 611f6298817cb44acba68217bb0f4cb494ce8ec5
4
- data.tar.gz: 6ae5e4ece790fef2169048b65cc8cce43b6d1a33
3
+ metadata.gz: 0d3c8d33de70a5a13ab8266a296901adc92470ce
4
+ data.tar.gz: e96796e88386edfea3100daf1248d025eaff0610
5
5
  SHA512:
6
- metadata.gz: 00339f1a2006e09aa8f293d41bca859e9bf69e2010b8bd0ed671ca3bd46b16c9aaad83d1dd69c473777a7d70fc5000eff2b77b374ba5865016ce9e4ebc698735
7
- data.tar.gz: 4147e95dc4f060bae0f3ad6924e9cd26a81041e6167547b8f7741fd3c571447d72a278316c868bc4cd2be6273e2878e5fc187cc1f4cfb40064d9036ae64b983a
6
+ metadata.gz: 83df38d52600057e3b877bb03c46a28da6614c166a0286f66dd3bb0ac0d657e3f68875cffb2c917e438f20581e5e9cbcf174e0d5673b2ba6ac73386a4ab0e652
7
+ data.tar.gz: aae9e02a525a0f023632a5335b509a95fb7a8f8ad4d2c9fc436f587f9b8b76620310ec330288deb8ab0dbecd077416ad13217163bb234287cbe313aa8e3b210a
data/README.md CHANGED
@@ -7,14 +7,14 @@ delete, and enumerate
7
7
  resources to be managed by Chef.
8
8
 
9
9
  ## Installation
10
- Be sure you are running the latest version of Chef, which can be installed
10
+ Be sure you are running the latest version of Chef DK, which can be installed
11
11
  via:
12
12
 
13
- gem install chef
13
+ https://downloads.chef.io/chef-dk/
14
14
 
15
15
  This plugin is distributed as a Ruby Gem. To install it, run:
16
16
 
17
- gem install knife-azure
17
+ chef gem install knife-azure
18
18
 
19
19
  Depending on your system's configuration, you may need to run this command
20
20
  with root/administrator privileges.
@@ -272,8 +272,20 @@ In general, systems bootstrapped via `cloud-api` do not require incoming or outg
272
272
  --bootstrap-protocol 'cloud-api'
273
273
  --delete-chef-extension-config
274
274
 
275
+ We have also added cloud-api support for Centos now, for this you just need to select centos image in above example.
276
+
275
277
  `--delete-chef-extension-config` determines if Chef configuration files should be removed when Azure removes the Chef resource extension from the VM or not. This option is only valid for the 'cloud-api' bootstrap protocol. The default value is false. This is useful when `update` and `uninstall` commands are run for the extension on the VM created.
276
278
 
279
+ #### Azure Server Create with Domain Join
280
+ Following options are used for creating server with domain join
281
+
282
+ :azure_domain_name Specifies the domain name to join. If the domains name is not specified, --azure-domain-user must specify the user principal name (UPN) format (user@fully-qualified-DNS-domain) or the fully-qualified-DNS-domain\\username format
283
+ :azure_domain_user Specifies the username who has access to join the domain.Supported format: username(if domain is already specified in --azure-domain-name option),fully-qualified-DNS-domain\username, user@fully-qualified-DNS-domain
284
+ :azure_domain_passwd Specifies the password for domain user who has access to join the domain
285
+
286
+ Command:
287
+ knife azure server create -I a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-20151022-en.us-127GB.vhd --azure-vm-size Medium -x 'azure' -P 'admin@123' --azure-domain-passwd 'admin@123' --azure-domain-user 'some.domain.com\user' --azure-domain-name 'some.domain.com' -c '~\chef-repo\.chef\knife.rb' --azure-network-name 'mynetwork' --azure-subnet-name 'subnet1' --azure-service-location 'West US'
288
+
277
289
 
278
290
  ### Azure Server Delete Subcommand
279
291
  Deletes an existing server in the currently configured Azure account. By
data/lib/azure/role.rb CHANGED
@@ -305,6 +305,7 @@ class Azure
305
305
  end
306
306
 
307
307
  def setup(params)
308
+ azure_user_domain_name = params[:azure_user_domain_name] || params[:azure_domain_name]
308
309
  builder = Nokogiri::XML::Builder.new do |xml|
309
310
  xml.PersistentVMRole(
310
311
  'xmlns'=>'http://schemas.microsoft.com/windowsazure',
@@ -345,7 +346,7 @@ class Azure
345
346
  if params[:azure_domain_name]
346
347
  xml.DomainJoin {
347
348
  xml.Credentials {
348
- xml.Domain params[:azure_domain_name]
349
+ xml.Domain azure_user_domain_name
349
350
  xml.Username params[:azure_domain_user]
350
351
  xml.Password params[:azure_domain_passwd]
351
352
  }
data/lib/azure/vnet.rb CHANGED
@@ -104,15 +104,31 @@ class Azure
104
104
  vnet = Nokogiri::XML::Node.new('VirtualNetworkSite', response) if add
105
105
  vnet['name'] = params[:azure_vnet_name]
106
106
  vnet['AffinityGroup'] = params[:azure_ag_name]
107
- addr_space = Nokogiri::XML::Node.new('AddressSpace', response)
107
+ if add || !vnet.at_css('AddressSpace') ## create a new AddressSpace block in XML if VNet or AddressSpace block does not already exist
108
+ addr_space = Nokogiri::XML::Node.new('AddressSpace', response)
109
+ else ## retrieve object of existing AddressSpace if VNet or AddressSpace already exist
110
+ addr_space = vnet.at_css('AddressSpace')
111
+ end
108
112
  addr_prefix = Nokogiri::XML::Node.new('AddressPrefix', response)
109
113
  addr_prefix.content = params[:azure_address_space]
114
+ if add || !vnet.at_css('Subnets') ## create a new Subnets block in XML if VNet or Subnets block does not already exist
115
+ subnets = Nokogiri::XML::Node.new('Subnets', response)
116
+ else ## retrieve object of existing Subnets if VNet or Subnets already exist
117
+ subnets = vnet.at_css('Subnets')
118
+ end
119
+ saddr_prefix = Nokogiri::XML::Node.new('AddressPrefix', response)
120
+ saddr_prefix.content = params[:azure_address_space]
121
+ subnet = Nokogiri::XML::Node.new('Subnet', response)
122
+ subnet['name'] = params[:azure_subnet_name]
123
+ subnet.children = saddr_prefix
124
+ subnets.children = subnet
125
+ vnet.add_child(subnets) if add || !vnet.at_css('Subnets')
110
126
  addr_space.children = addr_prefix
111
- vnet.children = addr_space
127
+ vnet.add_child(addr_space) if add || !vnet.at_css('AddressSpace')
112
128
  vnets.last.add_next_sibling(vnet) if add
113
129
  puts("Updating existing Virtual Network: #{params[:azure_vnet_name]}...")
114
130
  end
115
131
  @connection.query_azure('networking/media', 'put', response.to_xml)
116
132
  end
117
133
  end
118
- end
134
+ end
@@ -139,6 +139,11 @@ class Chef
139
139
  :description => "Verify the SSL cert for HTTPS requests to the Chef server API.",
140
140
  :boolean => true
141
141
 
142
+ option :bootstrap_proxy,
143
+ :long => "--bootstrap-proxy PROXY_URL",
144
+ :description => "The proxy server for the node being bootstrapped",
145
+ :proc => Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
146
+
142
147
  option :bootstrap_no_proxy,
143
148
  :long => "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]",
144
149
  :description => "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode",
@@ -349,12 +354,18 @@ class Chef
349
354
 
350
355
  option :azure_domain_user,
351
356
  :long => "--azure-domain-user DOMAIN_USER_NAME",
352
- :description => "Optional. Specifies the username who has access to join the domain."
357
+ :description => 'Optional. Specifies the username who has access to join the domain.
358
+ Supported format: username(if domain is already specified in --azure-domain-name option),
359
+ fully-qualified-DNS-domain\username, user@fully-qualified-DNS-domain'
353
360
 
354
361
  option :azure_domain_passwd,
355
362
  :long => "--azure-domain-passwd DOMAIN_PASSWD",
356
363
  :description => "Optional. Specifies the password for domain user who has access to join the domain."
357
364
 
365
+ option :azure_extension_client_config,
366
+ :long => "--azure-extension-client-config CLIENT_PATH",
367
+ :description => "Optional. Path to a client.rb file for use by the bootstrapped node. Only honored when --bootstrap-protocol is set to `cloud-api`."
368
+
358
369
  def strip_non_ascii(string)
359
370
  string.gsub(/[^0-9a-z ]/i, '')
360
371
  end
@@ -873,22 +884,6 @@ class Chef
873
884
  :winrm_max_timeout => locate_config_value(:winrm_max_timeout).to_i * 60 * 1000, #converting minutes to milliseconds
874
885
  :winrm_max_memoryPerShell => locate_config_value(:winrm_max_memory_per_shell)
875
886
  }
876
- # If user is connecting a new VM to an existing dns, then
877
- # the VM needs to have a unique public port. Logic below takes care of this.
878
- if is_image_windows? && locate_config_value(:bootstrap_protocol) == 'winrm'
879
- if locate_config_value(:azure_connect_to_existing_dns)
880
- port = locate_config_value(:winrm_port) || Random.rand(64000) + 1000
881
- else
882
- port = locate_config_value(:winrm_port) || '5985'
883
- end
884
- elsif locate_config_value(:bootstrap_protocol) == 'ssh'
885
- if locate_config_value(:azure_connect_to_existing_dns)
886
- port = locate_config_value(:ssh_port) || Random.rand(64000) + 1000
887
- else
888
- port = locate_config_value(:ssh_port) || '22'
889
- end
890
- end
891
- server_def[:port] = port
892
887
 
893
888
  if locate_config_value(:bootstrap_protocol) == 'cloud-api'
894
889
  server_def[:chef_extension] = get_chef_extension_name
@@ -925,6 +920,7 @@ class Chef
925
920
  end
926
921
  end
927
922
  end
923
+
928
924
  if is_image_windows?
929
925
  server_def[:os_type] = 'Windows'
930
926
  server_def[:admin_password] = locate_config_value(:winrm_password)
@@ -938,24 +934,37 @@ class Chef
938
934
  server_def[:identity_file_passphrase] = locate_config_value(:identity_file_passphrase)
939
935
  end
940
936
 
937
+ azure_connect_to_existing_dns = locate_config_value(:azure_connect_to_existing_dns)
938
+ if is_image_windows? && server_def[:bootstrap_proto] == 'winrm'
939
+ port = locate_config_value(:winrm_port) || '5985'
940
+ port = locate_config_value(:winrm_port) || Random.rand(64000) + 1000 if azure_connect_to_existing_dns
941
+ elsif server_def[:bootstrap_proto] == 'ssh'
942
+ port = locate_config_value(:ssh_port) || '22'
943
+ port = locate_config_value(:ssh_port) || Random.rand(64000) + 1000 if azure_connect_to_existing_dns
944
+ end
945
+
946
+ server_def[:port] = port
947
+
941
948
  server_def[:is_vm_image] = connection.images.is_vm_image(locate_config_value(:azure_source_image))
949
+ server_def[:azure_domain_name] = locate_config_value(:azure_domain_name) if locate_config_value(:azure_domain_name)
942
950
 
943
- if locate_config_value(:azure_domain_name)
944
- server_def[:azure_domain_name] = locate_config_value(:azure_domain_name)
945
- server_def[:azure_domain_user] = locate_config_value(:azure_domain_user)
946
- elsif locate_config_value(:azure_domain_user)
951
+ if locate_config_value(:azure_domain_user)
947
952
  # extract domain name since it should be part of username
948
953
  case locate_config_value(:azure_domain_user)
949
954
  when /(\S+)\\(.+)/ # format - fully-qualified-DNS-domain\username
950
- server_def[:azure_domain_name] = $1
955
+ server_def[:azure_domain_name] = $1 if locate_config_value(:azure_domain_name).nil?
956
+ server_def[:azure_user_domain_name] = $1
951
957
  server_def[:azure_domain_user] = $2
952
958
  when /(.+)@(\S+)/ # format - user@fully-qualified-DNS-domain
953
- server_def[:azure_domain_name] = $2
959
+ server_def[:azure_domain_name] = $2 if locate_config_value(:azure_domain_name).nil?
960
+ server_def[:azure_user_domain_name] = $2
954
961
  server_def[:azure_domain_user] = $1
955
962
  else
956
- # Format error.
957
- ui.error("Format error for --azure-domain-user option. Supported format are user principal name (UPN) format (user@fully-qualified-DNS-domain) or the fully-qualified-DNS-domain\\username format")
958
- exit 1
963
+ if locate_config_value(:azure_domain_name).nil?
964
+ ui.error('--azure-domain-name should be specified if --azure-domain-user is not in one of the following formats: fully-qualified-DNS-domain\username, user@fully-qualified-DNS-domain')
965
+ exit 1
966
+ end
967
+ server_def[:azure_domain_user] = locate_config_value(:azure_domain_user)
959
968
  end
960
969
  end
961
970
  server_def[:azure_domain_passwd] = locate_config_value(:azure_domain_passwd)
@@ -983,7 +992,12 @@ class Chef
983
992
 
984
993
  def get_chef_extension_public_params
985
994
  pub_config = Hash.new
986
- pub_config[:client_rb] = "chef_server_url \t #{Chef::Config[:chef_server_url].to_json}\nvalidation_client_name\t#{Chef::Config[:validation_client_name].to_json}"
995
+ if(locate_config_value(:azure_extension_client_config))
996
+ pub_config[:client_rb] = File.read(locate_config_value(:azure_extension_client_config))
997
+ else
998
+ pub_config[:client_rb] = "chef_server_url \t #{Chef::Config[:chef_server_url].to_json}\nvalidation_client_name\t#{Chef::Config[:validation_client_name].to_json}"
999
+ end
1000
+
987
1001
  pub_config[:runlist] = locate_config_value(:run_list).empty? ? "" : locate_config_value(:run_list).join(",").to_json
988
1002
  pub_config[:autoUpdateClient] = locate_config_value(:auto_update_client) ? "true" : "false"
989
1003
  pub_config[:deleteChefConfig] = locate_config_value(:delete_chef_extension_config) ? "true" : "false"
@@ -997,6 +1011,9 @@ class Chef
997
1011
  pub_config[:bootstrap_options][:chef_server_url] = Chef::Config[:chef_server_url] if Chef::Config[:chef_server_url]
998
1012
  pub_config[:bootstrap_options][:validation_client_name] = Chef::Config[:validation_client_name] if Chef::Config[:validation_client_name]
999
1013
  pub_config[:bootstrap_options][:node_verify_api_cert] = locate_config_value(:node_verify_api_cert) ? "true" : "false" if config.key?(:node_verify_api_cert)
1014
+ pub_config[:bootstrap_options][:bootstrap_version] = locate_config_value(:bootstrap_version) if locate_config_value(:bootstrap_version)
1015
+ pub_config[:bootstrap_options][:node_ssl_verify_mode] = locate_config_value(:node_ssl_verify_mode) if locate_config_value(:node_ssl_verify_mode)
1016
+ pub_config[:bootstrap_options][:bootstrap_proxy] = locate_config_value(:bootstrap_proxy) if locate_config_value(:bootstrap_proxy)
1000
1017
  Base64.encode64(pub_config.to_json)
1001
1018
  end
1002
1019
 
@@ -1023,6 +1040,16 @@ class Chef
1023
1040
  else
1024
1041
  pri_config[:validation_key] = File.read(Chef::Config[:validation_key])
1025
1042
  end
1043
+
1044
+ # SSL cert bootstrap support
1045
+ if locate_config_value(:cert_path)
1046
+ if File.exist?(File.expand_path(locate_config_value(:cert_path)))
1047
+ pri_config[:chef_server_crt] = File.read(locate_config_value(:cert_path))
1048
+ else
1049
+ ui.error('Specified SSL certificate does not exist.')
1050
+ exit 1
1051
+ end
1052
+ end
1026
1053
  Base64.encode64(pri_config.to_json)
1027
1054
  end
1028
1055
 
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Azure
3
- VERSION = "1.5.2"
3
+ VERSION = "1.6.0.rc.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-azure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.6.0.rc.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barry Davis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-06 00:00:00.000000000 Z
12
+ date: 2015-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri