diff --git a/Gemfile b/Gemfile index b1ab462..3de0207 100644 --- a/Gemfile +++ b/Gemfile @@ -10,10 +10,10 @@ group :development do # We depend on Vagrant for development, but we don't add it as a # gem dependency because we expect to be installed within the # Vagrant environment itself using `vagrant plugin`. - gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.7.4' - gem 'dotenv' + gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git' + gem 'bundler', '~>1.10.5' end group :plugins do gem 'vagrant-azure', path: '.' -end +end \ No newline at end of file diff --git a/README.md b/README.md index 4181a1d..fea3408 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,8 @@ For instructions on how to setup an Azure Active Directory Application see: http * `location`: (Optional) Azure location to build the VM -- defaults to 'westus' * `vm_name`: (Optional) Name of the virtual machine * `vm_password`: (Optional for *nix) Password for the VM -- This is not recommended for *nix deployments -* `vm_size`: (Optional) VM size to be used -- defaults to 'Standard_D1'. See: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-sizes/ -* `vm_image_urn`: (Optional) Name of the virtual machine image urn to use -- defaults to 'canonical:ubuntuserver:16.04.0-DAILY-LTS:latest'. See: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-cli-ps-findimage/ +* `vm_size`: (Optional) VM size to be used -- defaults to 'Standard_DS2_v2'. See: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-sizes/ +* `vm_image_urn`: (Optional) Name of the virtual machine image urn to use -- defaults to 'canonical:ubuntuserver:16.04-LTS:latest'. See: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-cli-ps-findimage/ * `virtual_network_name`: (Optional) Name of the virtual network resource * `subnet_name`: (Optional) Name of the virtual network subnet resource * `instance_ready_timeout`: (Optional) The timeout to wait for an instance to become ready -- default 120 seconds. diff --git a/Rakefile b/Rakefile index 9aa8103..f17bb0b 100644 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,7 @@ require 'rubygems' require 'bundler/setup' +require 'rspec/core/rake_task' $stdout.sync = true $stderr.sync = true @@ -11,3 +12,10 @@ $stderr.sync = true Dir.chdir(File.expand_path('../', __FILE__)) Bundler::GemHelper.install_tasks + +# Install the `spec` task so that we can run tests. +RSpec::Core::RakeTask.new(:spec) do |t| + t.rspec_opts = '--order defined' +end +# Default task is to run the unit tests +task :default => :spec diff --git a/dummy.box b/dummy.box index 1c6b98e..d404305 100644 Binary files a/dummy.box and b/dummy.box differ diff --git a/lib/vagrant-azure/action/read_ssh_info.rb b/lib/vagrant-azure/action/read_ssh_info.rb index 33efb27..0017e7b 100644 --- a/lib/vagrant-azure/action/read_ssh_info.rb +++ b/lib/vagrant-azure/action/read_ssh_info.rb @@ -24,9 +24,9 @@ def call(env) def read_ssh_info(azure, env) return nil if env[:machine].id.nil? parsed = parse_machine_id(env[:machine].id) - public_ip = azure.network.public_ipaddresses.get(parsed[:group], "#{parsed[:name]}-vagrantPublicIP").value!.body + public_ip = azure.network.public_ipaddresses.get(parsed[:group], "#{parsed[:name]}-vagrantPublicIP") - {:host => public_ip.properties.dns_settings.fqdn, :port => 22} + {:host => public_ip.dns_settings.fqdn, :port => 22} end end end diff --git a/lib/vagrant-azure/action/read_state.rb b/lib/vagrant-azure/action/read_state.rb index c95ad09..b1a04b4 100644 --- a/lib/vagrant-azure/action/read_state.rb +++ b/lib/vagrant-azure/action/read_state.rb @@ -29,9 +29,9 @@ def read_state(azure, machine) parsed = parse_machine_id(machine.id) vm = nil begin - vm = azure.compute.virtual_machines.get(parsed[:group], parsed[:name], 'instanceView').value!.body + vm = azure.compute.virtual_machines.get(parsed[:group], parsed[:name], 'instanceView') rescue MsRestAzure::AzureOperationError => ex - if vm.nil? || tearing_down?(vm.properties.instance_view.statuses) + if vm.nil? || tearing_down?(vm.instance_view.statuses) # The machine can't be found @logger.info('Machine not found or terminated, assuming it got destroyed.') machine.id = nil @@ -40,7 +40,7 @@ def read_state(azure, machine) end # Return the state - power_state(vm.properties.instance_view.statuses) + power_state(vm.instance_view.statuses) end end diff --git a/lib/vagrant-azure/action/read_winrm_info.rb b/lib/vagrant-azure/action/read_winrm_info.rb index b64d197..e84f6c2 100644 --- a/lib/vagrant-azure/action/read_winrm_info.rb +++ b/lib/vagrant-azure/action/read_winrm_info.rb @@ -28,9 +28,9 @@ def call(env) def read_winrm_info(azure, env) return nil if env[:machine].id.nil? parsed = parse_machine_id(env[:machine].id) - public_ip = azure.network.public_ipaddresses.get(parsed[:group], "#{parsed[:name]}-vagrantPublicIP").value!.body + public_ip = azure.network.public_ipaddresses.get(parsed[:group], "#{parsed[:name]}-vagrantPublicIP") - {:host => public_ip.properties.dns_settings.fqdn, :port => env[:machine].config.winrm.port} + {:host => public_ip.dns_settings.fqdn, :port => env[:machine].config.winrm.port} end end end diff --git a/lib/vagrant-azure/action/run_instance.rb b/lib/vagrant-azure/action/run_instance.rb index 81103f5..bc4c486 100644 --- a/lib/vagrant-azure/action/run_instance.rb +++ b/lib/vagrant-azure/action/run_instance.rb @@ -131,11 +131,11 @@ def call(env) deployment_params = build_deployment_params(template_params, deployment_params.reject{|_,v| v.nil?}) - env[:ui].info('Starting deployment') + env[:ui].info(' -- Starting deployment') env[:metrics]['deployment_time'] = Util::Timer.time do put_deployment(azure, resource_group_name, deployment_params) end - env[:ui].info('Finished deploying') + env[:ui].info(' -- Finished deploying') # Immediately save the ID since it is created at this point. env[:machine].id = serialize_machine_id(resource_group_name, vm_name, location) @@ -176,20 +176,21 @@ def call(env) end def get_image_os(image_details) - image_details.properties.os_disk_image.operating_system + image_details.os_disk_image.operating_system end def get_image_details(azure, location, publisher, offer, sku, version) if version == 'latest' - latest = azure.compute.virtual_machine_images.list(location, publisher, offer, sku).value!.body.last - azure.compute.virtual_machine_images.get(location, publisher, offer, sku, latest.name).value!.body + images = azure.compute.virtual_machine_images.list(location, publisher, offer, sku) + latest = images.sort_by(&:name).last + azure.compute.virtual_machine_images.get(location, publisher, offer, sku, latest.name) else - azure.compute.virtual_machine_images.get(location, publisher, offer, sku, version).value!.body + azure.compute.virtual_machine_images.get(location, publisher, offer, sku, version) end end def put_deployment(azure, rg_name, params) - azure.resources.deployments.create_or_update(rg_name, 'vagrant', params).value!.body + azure.resources.deployments.create_or_update(rg_name, 'vagrant', params) end def put_resource_group(azure, name, location) @@ -197,11 +198,12 @@ def put_resource_group(azure, name, location) rg.location = location end - azure.resources.resource_groups.create_or_update(name, params).value!.body + azure.resources.resource_groups.create_or_update(name, params) end # This method generates the deployment template def render_deployment_template(options) + self_signed_cert_resource = nil if options[:operating_system] == 'Windows' && options[:winrm_install_self_signed_cert] setup_winrm_powershell = Vagrant::Util::TemplateRenderer.render('arm/setup-winrm.ps1', options.merge({template_root: template_root})) encoded_setup_winrm_powershell = setup_winrm_powershell. @@ -216,7 +218,7 @@ def render_deployment_template(options) def build_deployment_params(template_params, deployment_params) params = ::Azure::ARM::Resources::Models::Deployment.new params.properties = ::Azure::ARM::Resources::Models::DeploymentProperties.new - if (template_params[:deployment_template].nil?) + if template_params[:deployment_template].nil? params.properties.template = JSON.parse(render_deployment_template(template_params)) else params.properties.template = JSON.parse(template_params[:deployment_template]) diff --git a/lib/vagrant-azure/action/start_instance.rb b/lib/vagrant-azure/action/start_instance.rb index 61680d6..a915509 100644 --- a/lib/vagrant-azure/action/start_instance.rb +++ b/lib/vagrant-azure/action/start_instance.rb @@ -36,7 +36,7 @@ def call(env) env[:ui].info(I18n.t('vagrant_azure.waiting_for_ready')) task = await_true(env) do |vm| - running?(vm.properties.instance_view.statuses) + running?(vm.instance_view.statuses) end if task.value diff --git a/lib/vagrant-azure/action/stop_instance.rb b/lib/vagrant-azure/action/stop_instance.rb index 42f66bb..b0a184b 100644 --- a/lib/vagrant-azure/action/stop_instance.rb +++ b/lib/vagrant-azure/action/stop_instance.rb @@ -36,7 +36,7 @@ def call(env) env[:ui].info(I18n.t('vagrant_azure.waiting_for_stop')) task = await_true(env) do |vm| - stopped?(vm.properties.instance_view.statuses) + stopped?(vm.instance_view.statuses) end if task.value diff --git a/lib/vagrant-azure/action/terminate_instance.rb b/lib/vagrant-azure/action/terminate_instance.rb index 52724aa..56107b6 100644 --- a/lib/vagrant-azure/action/terminate_instance.rb +++ b/lib/vagrant-azure/action/terminate_instance.rb @@ -21,8 +21,10 @@ def call(env) begin env[:ui].info(I18n.t('vagrant_azure.terminating', parsed)) env[:ui].info('Deleting resource group') - env[:azure_arm_service].resources.resource_groups.delete(parsed[:group]).value!.body - env[:ui].info('Resource group deleted...') + + # Call the begin_xxx_async version to kick off the delete, but don't wait for the resource group to be cleaned up + env[:azure_arm_service].resources.resource_groups.begin_delete_async(parsed[:group]).value! + env[:ui].info('Resource group is deleting... Moving on.') rescue MsRestAzure::AzureOperationError => ex unless ex.response.status == 404 raise ex diff --git a/lib/vagrant-azure/config.rb b/lib/vagrant-azure/config.rb index 80baa23..5f917c9 100644 --- a/lib/vagrant-azure/config.rb +++ b/lib/vagrant-azure/config.rb @@ -147,19 +147,19 @@ def finalize! @vm_name = Haikunator.haikunate(100) if @vm_name == UNSET_VALUE @resource_group_name = Haikunator.haikunate(100) if @resource_group_name == UNSET_VALUE @vm_password = nil if @vm_password == UNSET_VALUE - @vm_image_urn = 'canonical:ubuntuserver:16.04.0-DAILY-LTS:latest' if @vm_image_urn == UNSET_VALUE + @vm_image_urn = 'canonical:ubuntuserver:16.04.0-LTS:latest' if @vm_image_urn == UNSET_VALUE @location = 'westus' if @location == UNSET_VALUE @virtual_network_name = nil if @virtual_network_name == UNSET_VALUE @subnet_name = nil if @subnet_name == UNSET_VALUE @tcp_endpoints = nil if @tcp_endpoints == UNSET_VALUE - @vm_size = 'Standard_D1' if @vm_size == UNSET_VALUE + @vm_size = 'Standard_DS2_v2' if @vm_size == UNSET_VALUE @availability_set_name = nil if @availability_set_name == UNSET_VALUE @instance_ready_timeout = 120 if @instance_ready_timeout == UNSET_VALUE @instance_check_interval = 2 if @instance_check_interval == UNSET_VALUE - @admin_username = ENV['AZURE_VM_ADMIN_USERNAME'] if @admin_username == UNSET_VALUE - @admin_password = ENV['AZURE_VM_ADMIN_PASSWORD'] if @admin_password == UNSET_VALUE + @admin_username = (ENV['AZURE_VM_ADMIN_USERNAME'] || 'vagrant') if @admin_username == UNSET_VALUE + @admin_password = (ENV['AZURE_VM_ADMIN_PASSWORD'] || '$Vagrant(0)') if @admin_password == UNSET_VALUE @winrm_install_self_signed_cert = true if @winrm_install_self_signed_cert == UNSET_VALUE @deployment_template = nil if @deployment_template == UNSET_VALUE end diff --git a/lib/vagrant-azure/provider.rb b/lib/vagrant-azure/provider.rb index f1f53b2..fa1393e 100644 --- a/lib/vagrant-azure/provider.rb +++ b/lib/vagrant-azure/provider.rb @@ -14,6 +14,8 @@ def initialize(machine) # Load the driver machine_id_changed + # turn off nfs functionality by default, so the machine will fall back to rsync by default + @machine.config.nfs.functional = false @machine.config.winrm.password = @machine.provider_config.admin_password @machine.config.winrm.username = @machine.provider_config.admin_username end diff --git a/lib/vagrant-azure/util/vm_await.rb b/lib/vagrant-azure/util/vm_await.rb index 8f8c756..b16468e 100644 --- a/lib/vagrant-azure/util/vm_await.rb +++ b/lib/vagrant-azure/util/vm_await.rb @@ -18,7 +18,7 @@ def await_true(env) end count += 1 - vm = azure.compute.virtual_machines.get(parsed[:group], parsed[:name], 'instanceView').value!.body + vm = azure.compute.virtual_machines.get(parsed[:group], parsed[:name], 'instanceView') if yield(vm) task.shutdown true diff --git a/lib/vagrant-azure/version.rb b/lib/vagrant-azure/version.rb index 4852951..ab37ad5 100644 --- a/lib/vagrant-azure/version.rb +++ b/lib/vagrant-azure/version.rb @@ -4,6 +4,6 @@ module VagrantPlugins module Azure - VERSION = '2.0.0.pre1' + VERSION = '2.0.0.pre2'.freeze end end diff --git a/templates/arm/deployment.json.erb b/templates/arm/deployment.json.erb index 409dc96..72cf5a6 100644 --- a/templates/arm/deployment.json.erb +++ b/templates/arm/deployment.json.erb @@ -32,7 +32,7 @@ }, "vmSize": { "type": "string", - "defaultValue": "Standard_D1", + "defaultValue": "Standard_DS2_v2", "metadata": { "description": "Size of the VM" } @@ -59,7 +59,7 @@ }, "imageSku": { "type": "string", - "defaultValue": "16.04.0-DAILY-LTS", + "defaultValue": "16.04-LTS", "metadata": { "description": "Name of the image sku" } @@ -103,7 +103,7 @@ "nicName": "[concat(parameters('vmName'), '-vagrantNIC')]", "publicIPAddressName": "[concat(parameters('vmName'), '-vagrantPublicIP')]", "publicIPAddressType": "Dynamic", - "storageAccountType": "Standard_LRS", + "storageAccountType": "Premium_LRS", "networkSecurityGroupName": "[concat(parameters('vmName'), '-vagrantNSG')]", "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]", @@ -299,12 +299,6 @@ "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" } ] - }, - "diagnosticsProfile": { - "bootDiagnostics": { - "enabled": "true", - "storageUri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net')]" - } } } } diff --git a/vagrant-azure.gemspec b/vagrant-azure.gemspec index 5b8c72d..58d1927 100644 --- a/vagrant-azure.gemspec +++ b/vagrant-azure.gemspec @@ -8,6 +8,7 @@ require 'vagrant-azure/version' Gem::Specification.new do |s| s.name = 'vagrant-azure' s.version = VagrantPlugins::Azure::VERSION + s.platform = Gem::Platform::RUBY s.authors = %w(Azure) s.description = 'Enable Vagrant to manage machines in Microsoft Azure.' s.summary = 'Enable Vagrant to manage Windows and Linux machines in Microsoft Azure.' @@ -18,15 +19,16 @@ Gem::Specification.new do |s| s.bindir = 'bin' s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } - s.add_runtime_dependency 'azure_mgmt_resources', '~>0.2.1' - s.add_runtime_dependency 'azure_mgmt_compute', '~>0.2.1' - s.add_runtime_dependency 'azure_mgmt_network', '~>0.2.1' - s.add_runtime_dependency 'azure_mgmt_storage', '~>0.2.1' + s.add_runtime_dependency 'azure_mgmt_resources', '~>0.8.0' + s.add_runtime_dependency 'azure_mgmt_compute', '~>0.8.0' + s.add_runtime_dependency 'azure_mgmt_network', '~>0.8.0' + s.add_runtime_dependency 'azure_mgmt_storage', '~>0.8.0' s.add_runtime_dependency 'haikunator', '~>1.1' + s.add_runtime_dependency 'highline', '~>1.7' s.add_development_dependency 'bundler', '~>1.9' s.add_development_dependency 'rake', '~>11.1' s.add_development_dependency 'rspec', '~>3.4' - s.add_development_dependency 'simplecov', '~>0.11.2' + s.add_development_dependency 'simplecov', '~>0.11' s.add_development_dependency 'coveralls', '~>0.8' end