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

PowerShell provisioner does not respond (elevated) Windows 10 #10989

Open
HofmeisterAn opened this issue May 3, 2021 · 1 comment
Open

PowerShell provisioner does not respond (elevated) Windows 10 #10989

HofmeisterAn opened this issue May 3, 2021 · 1 comment
Labels

Comments

@HofmeisterAn
Copy link
Contributor

Overview of the Issue

The PowerShell provisioner does not respond while running with extended rights (elevated) in Windows 10. It works for server images.

Reproduction Steps

  1. Create a packer configuration that creates a virtual machine in Azure.
  2. Use following image configuration:
    • image_publisher: MicrosoftWindowsDesktop
    • image_offer: Windows-10
    • image_sku: 19h2-ent-g2
  3. Add an elevated powershell provisioner:
...
{
  "type": "powershell",
  "inline": [
    "net user {{user `install_user`}} {{user `install_password`}} /add /passwordchg:no /passwordreq:yes /active:yes /Y",
    "net localgroup Administrators {{user `install_user`}} /add"
  ]
},
{
  "type": "powershell",
  "inline": [
    "Write-Host Foo"
  ],
  "elevated_user": "{{user `install_user`}}",
  "elevated_password": "{{user `install_password`}}"
}
...
  1. Execute the packer build.

Packer version

  • 1.6.6
  • 1.7.2

Simplified Packer Buildfile

{
  "variables": {
    "client_id": "{{env `ARM_CLIENT_ID`}}",
    "client_secret": "{{env `ARM_CLIENT_SECRET`}}",
    "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
    "tenant_id": "{{env `ARM_TENANT_ID`}}",
    "object_id": "{{env `ARM_OBJECT_ID`}}",
    "install_user": "installer",
    "install_password": "{{env `INSTALL_PASSWORD`}}",
  },
  "builders": [
    {
      "type": "azure-arm",
      "client_id": "{{user `client_id`}}",
      "client_secret": "{{user `client_secret`}}",
      "subscription_id": "{{user `subscription_id`}}",
      "object_id": "{{user `object_id`}}",
      "tenant_id": "{{user `tenant_id`}}",
      "location": "westeurope",
      "vm_size": "Standard_B4ms",
      "os_type": "Windows",
      "image_publisher": "MicrosoftWindowsDesktop",
      "image_offer": "Windows-10",
      "image_sku": "19h2-ent-g2",
      "communicator": "winrm",
      "winrm_use_ssl": "true",
      "winrm_insecure": "true",
      "winrm_username": "packer"
    }
  ],
  "provisioners": [
    {
      "type": "powershell",
      "inline": [
        "net user {{user `install_user`}} {{user `install_password`}} /add /passwordchg:no /passwordreq:yes /active:yes /Y",
        "net localgroup Administrators {{user `install_user`}} /add"
      ]
    },
    {
      "type": "powershell",
      "inline": [
        "Write-Host Foo"
      ],
      "elevated_user": "{{user `install_user`}}",
      "elevated_password": "{{user `install_password`}}"
    }
  ]
}

Operating system and Environment details

-

Log Fragments and crash.log files

-

Relates to #7729, https://groups.google.com/g/packer-tool/c/6ToKPlCpsxM. Please notice - if I use the described workaround or log into the virtual machine, packer starts the script.

@spcaipers-arm
Copy link

Hello, any update on this ticket?

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

No branches or pull requests

2 participants