Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples no longer create windows virtual machines #87

Closed
reznet opened this issue Jan 16, 2019 · 6 comments
Closed

Examples no longer create windows virtual machines #87

reznet opened this issue Jan 16, 2019 · 6 comments
Assignees

Comments

@reznet
Copy link

reznet commented Jan 16, 2019

The fixes for #56 changed the string used to determine if the virtual machine should be linux or windows, but the fix did not update the examples in the readme file, so new users (such as myself) were not able to create windows virtual machines -- and could not tell why. The module used to check if vm_os_offer or vm_os_simple equalled "WindowsServer" and if so created windows virtual machines. #73 changed this to simply "Windows" with the goal of matching both server and client windows editions (i.e. Windows-10). However, even after changing vm_os_offer to Windows, the virtual machine creation still fails because this module is passing empty strings to azure for the os disk publisher, sku, and offer:

      storage_image_reference.#:                                             "1"
      storage_image_reference.645692374.id:                                  ""
      storage_image_reference.645692374.offer:                               ""
      storage_image_reference.645692374.publisher:                           ""
      storage_image_reference.645692374.sku:                                 ""
      storage_image_reference.645692374.version:                             "latest"

it passes these in because the default publisher, offer, sku values come from a lookup table whose key is WindowsServer, but we now must specify Windows to create a windows vm.

Strangely, the empty disk values happen even if you specify their values in the module config, though I'm not able to explain why:

In all, I was never able to successfully create a Windows VM using this terraform module.
I recommend rolling back #56 in the short term.

Terraform v0.11.11

  • provider.azurerm v1.21.0
  • provider.random v1.3.1

Steps to reproduce:

run terraform apply this this main.tf:

provider "azurerm" {}

  module "windowsservers" {
    source                        = "Azure/compute/azurerm"
    resource_group_name           = "terraform-advancedvms"
    location                      = "westus2"
    vm_hostname                   = "mywinvm"
    admin_password                = "ComplxP@ssw0rd!"
    public_ip_dns                 = ["winterravmip", "winterravmip1"]
    nb_public_ip                  = "2"
    remote_port                   = "3389"
    nb_instances                  = "2"
    vm_os_publisher               = "MicrosoftWindowsServer"
    vm_os_offer                   = "WindowsServer"
    vm_os_sku                     = "2012-R2-Datacenter"
    vm_size                       = "Standard_DS2_V2"
    vnet_subnet_id                = "${module.network.vnet_subnets[0]}"
    enable_accelerated_networking = "true"
  }

  module "network" {
    source              = "Azure/network/azurerm"
    version             = "~> 1.1.1"
    location            = "westus2"
    allow_rdp_traffic   = "true"
    allow_ssh_traffic   = "true"
    resource_group_name = "terraform-advancedvms"
  }
@reznet reznet changed the title No longer able to create windows virtual machines Examples no longer create windows virtual machines Jan 16, 2019
@reznet
Copy link
Author

reznet commented Jan 16, 2019

In the end, I was able to create windows virtual machines using this modified example. Note I had to specify is_windows_image = "true" to force it to create a windows machine.

module "windowsservers" {
    source                        = "Azure/compute/azurerm"
    resource_group_name           = "terraform-advancedvms"
    location                      = "westus2"
    vm_hostname                   = "mywinvm"
    admin_password                = "ComplxP@ssw0rd!"
    public_ip_dns                 = ["winterravmip", "winterravmip1"]
    nb_public_ip                  = "2"
    remote_port                   = "3389"
    nb_instances                  = "2"
    vm_os_publisher               = "MicrosoftWindowsServer"
    vm_os_offer                   = "WindowsServer"
    is_windows_image              = "true"
    vm_os_sku                     = "2016-Datacenter"
    vm_size                       = "Standard_DS2_V2"
    vnet_subnet_id                = "${module.network.vnet_subnets[0]}"
  }
module "network" {
    source              = "Azure/network/azurerm"
    version             = "~> 1.1.1"
    location            = "westus2"
    allow_rdp_traffic   = "true"
    allow_ssh_traffic   = "true"
    resource_group_name = "terraform-advancedvms"
  }

@sskoklev
Copy link

Hi Jeff
I'm using the same versions and copied the sample script you have above but am getting the following error on init.

Error downloading modules: Error loading modules: error downloading 'file:///home/sskoklev/clouddrive/TestWinServer/.terraform/modules/d71003d1c95d6b7923f4fed52f035836/Azure-terraform-azurerm-compute-a1ea390/os': symlink /home/sskoklev/clouddrive/TestWinServer/.terraform/modules/d71003d1c95d6b7923f4fed52f035836/Azure-terraform-azurerm-compute-a1ea390/os .terraform/modules/bada694310044be46d0f8a72a6cac772: operation not supported

Given it works for you Im curious as to whether its related to configuration on my laptop which is Win10. Are you able to share any config related info on your setup or did you have a similar error and been able to resolve it?

Thanks in advance

@reznet
Copy link
Author

reznet commented Jan 16, 2019

@sskoklev I'm using mac os mojave. that's the only difference i can think of.

@sskoklev
Copy link

@reznet Thanks reinstalling the Azure CLI fixed it.

@SylvainMartel
Copy link

I got the same problem, unless I add is_windows_image = "true" it will always try to build a linux machine, and fail, of course

@yupwei68
Copy link
Contributor

HI @reznet , thanks for opening this issue. In windows cases, we need to add is_windos_image = true, in case some windows vm_os_offer doesn't include "windows"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants