vagrant-azure icon indicating copy to clipboard operation
vagrant-azure copied to clipboard

support azure custom-script extension for windows guests

Open rysweet opened this issue 8 years ago • 4 comments

Enhancement proposal:

User Story: As a developer leveraging Windows guests OSes, I want to use vagrant to define an initial script to deliver into the VM, using Azure IaaS VM Custom Script Extension, so that I can perform bootstrap tasks on my VM.

Note: this is scoped to windows guests - should probably open a separate feature for Linux guests.

References: https://blogs.technet.microsoft.com/uktechnet/2016/02/12/create-a-custom-script-extension-for-an-azure-resource-manager-vm-using-powershell/ http://www.powershellmagazine.com/2014/04/30/understanding-azure-custom-script-extension/ https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-extensions-customscript/

Proposed configuration UX (similar to vagrant-aws)

config.vm.provider :azure do |azure, override|
  # specify a URI for the custom script file - takes precedence
  azure.custom_script_uri = "https://github.com/Azure/vagrant-azure/tree/v2.0/example_box/scripts/bootsrap.ps1"

  # alternately - specify the script in a file which we will stage to the storage account of the vm
  azure.custom_script = File.read("bootstrap.ps1")

  # execution command
  azure.custom_script_command = "powershell.exe -ExecutionPolicy Unrestricted -File bootstrap.ps1"
end

rysweet avatar May 05 '16 18:05 rysweet

Could that be currently done via provisioner shell?

avishnyakov avatar May 30 '16 05:05 avishnyakov

@avishnyakov it might be able to depending on the configuration of your base image.

The Azure provisioning script provides a hook to run some script on the machine via the Azure provisioning fabric. That gets executed even if the box doesn't have an outside connection. For example, if you have an image that isn't setup for WinRM or SSH communication by default and you need to enable prior to executing Ansible provisioning.

devigned avatar May 30 '16 16:05 devigned

Azure provisioning fabric showed to be slow and unreliable sometimes. Seems getting image with WinRM setup in the first place is a better option right now?

avishnyakov avatar May 30 '16 23:05 avishnyakov

In general, should most Azure VMs already have WinRM enabled with a self signed SSL cert? If not I think using an extension is the right thing to do.

I still haven't been able to get any samples to work, I always fail at "Waiting for WinRM to become available"

My other goal is to eventually get https://github.com/PowerShell/Win32-OpenSSH deployed through an extension so that I can use Vagrant's ssh provider instead

PatrickLang avatar Oct 27 '17 22:10 PatrickLang