Điểm:1

Run script in Windows Azure VM after launch during packer build to configure WinRM and the firewall

lá cờ sm

Background: Apparently Packer has major issues configuring WinRM on Azure VMs created from the Microsoft Windows Server publisher. This is only one of the several issues and threads I've found on this and it dates back several years. Because of this I'm unable to connect to an instance with Packer in order to provision and prepare our own Windows images for use within our company. I've tried altering timeouts, I've tried different VM sizes, none of it works. Packer's ARM template is just garbage at configuring WinRM. And they are not willing to fix the problem. In a suggestion to provide a way to run a script on Azure in the same way as AWS' userdata, Hashicorp's asinine "solution" is to "prepare a custom image to process the custom-data script so you can prepare a custom image with packer". They even suggest it can't be done by their code which is outright false.

I already do this myself in AWS by configuring a userdata script to run, which configures WinRM and the firewall. I was able to find that Azure has a similar feature called custom-data, and while I can set this using the azure-arm source, for some "lovely" reason Windows does not have a way to run it, only Linux does via cloud-init. I can run what I need using Invoke-AzVMRunCommand (whether it's custom-data or not which FIXES THE PROBLEM! HUZZAH! Except Packer does not (that I can find) provide a way to run "pre-connection" commands from builder, you only have this option once you hit the provisioner. My provisioner code will not run until the connection to WinRM is established. Chicken, meet egg (or is it the other way around?)

So I am unable automate this with Packer in its current state unless I am missing something. Yet, I am unable to use a different tool here for image building due to internal politics and procedures. I apologize if this background comes off a bit ranty, I am extremely tired and frustrated with this issue.


The question: Are there any ideas out there that don't involve creating an intermediary custom image via some other process that will allow me to run a script at provisioning time against a Windows Azure VM? Are there alternate Azure builders for use with Packer that might help? Or perhaps an Azure publisher who publishes Windows images which already have the capability of running custom-data on launch? Or perhaps is there a trick of Packer I haven't considered here yet? If I could just run an Azure CLI command from the builder once the VM is created I could solve this quickly.

My other thoughts are to fork the azure-arm builder and add the capability I need myself, or write my own provider entirely. The former solution might be feasible, and I could contribute the code back (if Hashicorp won't reject it because "it's not their way"), but the latter seems heavy-handed for the situation. In addition, I don't know Go so I'd have to pick it up and it's... different from many. In either event, I would like to avoid developing my own code for a solution if there is already a real solution to this scenario.

Many thanks in advance for consideration of this issue.

Đăng câu trả lời

Hầu hết mọi người không hiểu rằng việc đặt nhiều câu hỏi sẽ mở ra cơ hội học hỏi và cải thiện mối quan hệ giữa các cá nhân. Ví dụ, trong các nghiên cứu của Alison, mặc dù mọi người có thể nhớ chính xác có bao nhiêu câu hỏi đã được đặt ra trong các cuộc trò chuyện của họ, nhưng họ không trực giác nhận ra mối liên hệ giữa câu hỏi và sự yêu thích. Qua bốn nghiên cứu, trong đó những người tham gia tự tham gia vào các cuộc trò chuyện hoặc đọc bản ghi lại các cuộc trò chuyện của người khác, mọi người có xu hướng không nhận ra rằng việc đặt câu hỏi sẽ ảnh hưởng—hoặc đã ảnh hưởng—mức độ thân thiện giữa những người đối thoại.