3

I haven't found a decent way to get a Windows instance in Azure started up using the azure_rm_virtualmachine module with remote PowerShell enabled from first boot.

What is the typical approach to get started with Azure Windows instances provisioned with Ansible ready to run PowerShell remote commands?

There's another Ansible module called simply azure, but appears to be deprecated by azure_rm_virtualmachine.

2
  • Do you mean you want to get VM status by using PowerShell. If yes, you could use Azure PowerShell. (Get-AzureRmVM -ResourceGroupName $ResourceGroup -Name $RmVM -Status).Statuses.Code[1] Commented May 18, 2017 at 1:37
  • I mean using ansible to provision a host that has remote power shell enabled from first boot to be usable by ansible. I'll clarify the question
    – barrymac
    Commented May 18, 2017 at 16:07

1 Answer 1

4

After creating the VM, use azure_rm_deployment module to create a deployment for a Custom Script Extension.

In the template specify:

{
  "publisher": "Microsoft.Compute",
  "type": "CustomScriptExtension",
  "typeHandlerVersion": "1.4",
  "settings": {
    "fileUris": [
      "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
    ],
    "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File ConfigureRemotingForAnsible.ps1"
  }
}

Then run a play against the VM.

1
  • Much appreciated @techraf , thanks also for question edits!
    – barrymac
    Commented Jun 4, 2017 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .