openstack builder shutdown command?

371 views
Skip to first unread message

Blake Garner

unread,
Mar 23, 2017, 6:46:45 PM3/23/17
to Packer
I'm starting to work with the OpenStack builder and noticed that no shutdown_command or shutdown_timeout exist. Am I missing something here? Using the shutdown commands is how I trigger windows images to shutdown and run sysprep. Doing sysprep at shutdown is key for getting cloudbase-init to work as desired. 

Has anybody worked this out yet or do I need to make some feature requests? 

Thanks,
Blake

Rickard von Essen

unread,
Mar 24, 2017, 2:39:54 AM3/24/17
to packe...@googlegroups.com
Shutdown is initiated by an api towards openstack. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/3586fb47-584d-4434-a613-c3e64ebd45a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lorena Lobato

unread,
Mar 24, 2017, 12:26:50 PM3/24/17
to Packer
Same case but with Linux images. When I reboot the machine in the provisioner stops without any error and skipping the post commands.

Is there anyway to avoid this? Need to reboot the machine during provisioning time to make effective some puppet changes.



El viernes, 24 de marzo de 2017, 7:39:54 (UTC+1), Rickard von Essen escribió:
Shutdown is initiated by an api towards openstack. 
On Mar 23, 2017 23:46, "Blake Garner" <bl...@netjibbing.com> wrote:
I'm starting to work with the OpenStack builder and noticed that no shutdown_command or shutdown_timeout exist. Am I missing something here? Using the shutdown commands is how I trigger windows images to shutdown and run sysprep. Doing sysprep at shutdown is key for getting cloudbase-init to work as desired. 

Has anybody worked this out yet or do I need to make some feature requests? 

Thanks,
Blake

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Blake Garner

unread,
Mar 24, 2017, 2:52:18 PM3/24/17
to packe...@googlegroups.com
It seems like any of the builders could send a shutdown command to the OS. Why does the OpenStack one do this instead of working the same as vmware-iso or qemu? 

Windows OpenStack images need to run sysprep at shutdown. For that to work we need to run a script that kills the winrm connection and wait for the OS to power itself off. I don't see a clear way to do this with packer currently...



You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/YNwRJD6R60I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/6755b43a-d111-47d3-88bd-51651b537bb0%40googlegroups.com.

Rickard von Essen

unread,
Mar 24, 2017, 2:58:04 PM3/24/17
to packe...@googlegroups.com
None of the cloud based builders have a shutdown_command, there is a difference on how they are operated. 

Azure ARM have a example under Deprovision - Windows on how to run sysprep on Azure, but I assume the same thing works for OpenStack.

// Rickard

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAGA5xXVUEMd06ch2JDuTChx6M5CiNGCdCs5rcY2EQ%2Bp5qZ1_Aw%40mail.gmail.com.

Blake Garner

unread,
Mar 24, 2017, 4:20:03 PM3/24/17
to packe...@googlegroups.com
OK I'll give that run sysprep as the last provisioner and hope things shutdown correctly a try. 

Rickard von Essen

unread,
Mar 24, 2017, 4:45:16 PM3/24/17
to Packer
To reboot a Linux machine do something like:

  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "sudo reboot"
      ]
    },
    {
      "type": "shell",
      "inline": [
         "uptime"
      ],
      "pause_before": "15s"
    }
  ]

This allow the shutdown command to stop the machine before the next (uptime) is executed and that will wait for the ssh connection to re-establish, after the reboot.

Lorena Lobato

unread,
Mar 27, 2017, 9:31:38 AM3/27/17
to Packer
I will give a try and let you know, thanks

Lorena Lobato

unread,
Mar 27, 2017, 5:17:11 PM3/27/17
to Packer
In my case, it does not help. After the reboot, it suppose to run a second puppet agent which usually takes around 20 min to be completed and, a couple of single commands.

When I try to reboot it, packer finishes without any error, though without executing the following steps as indicated before. Strange..

Is there another way for OpenStack builder and CentOS images ?

Rickard von Essen

unread,
Mar 28, 2017, 12:29:22 AM3/28/17
to packe...@googlegroups.com
Lorena reply with a template that reproduce your problem (and all necessary files). And it would be good if you start a new thread instead of hijacking this. 

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/fa9ea392-6394-4fb5-8e99-22accf3e6b23%40googlegroups.com.

Lorena Lobato

unread,
May 8, 2017, 9:16:56 AM5/8/17
to Packer
Hi,

Sorry for the late response, I was away long time. It has been solved :)

Thanks for the tips!

Cheers
Lore

Blake Garner

unread,
Jun 21, 2017, 1:12:06 PM6/21/17
to Packer
Hi Rickard,
Sorry for reviving zombie thread but after a lot of effort I'm right back to this same issue. I started by looking at the Azure ARM documetnation and specifically the sysprep block in this example. https://github.com/hashicorp/packer/blob/master/examples/azure/windows.json

In the example sysprep is done last by a standard powershell provisioner with the /shutdown option. So sysprep starts off and does it's thing eventually shutting down the instance itself. Based on discussion and research the Azure ARM builder then sends a shutdown command to the instance. How that is handled is the key difference between this case and attempting to do the same thing on OpenStack builder. Also of note is that sysprep ends the winrm connection before it's completed work. 

When I do the same approach with OpenStack builder a couple of outcomes happen. 

1. Matching the example just start sysprep as the last provisioner results in the provisioner ending before sysprep is done. Packer then powers off the VM before sysprep is completed. 

2. Matching the example but adding a local shell provisioner that just adds 15 minute wait then shutting down. The OpenStack builder fails because the instance is shutdown when it attempts to shut it down with an invalid state error. This specific behaviour I'm crafting a bug report for currently. 

3. Running sysprep with a /quit option instead of shutdown then allowing the builder to power off the system after 15min pause. This is currently what I'm doing but it's still causing the VM to be shutdown in an invalid state. Windows needs to do some kind of process at shutdown and the method openstack/packer builder does this is to abrupt. 

In my view the use case of sysprep for windows images merits adding the shutdown_command capability as an option for "cloud" style packer builders. The normal cloud style shutdown can run after the timeout or if the shutdown_command detects the instance is down. It seems likely the documented technique for azure-arm works because of how that builder and platform deal with windows instance power off is optimized for windows.

 I'm open to other suggestions but having packer handle the sysprep shutdown use case directly seems best for the long term. 

Cheers,
Blake
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Rickard von Essen

unread,
Jul 6, 2017, 4:06:14 PM7/6/17
to packe...@googlegroups.com
> 3. Running sysprep with a /quit option instead of shutdown then allowing the builder to power off the system after 15min pause. This is currently what I'm doing but it's still causing the VM to be shutdown in an invalid state.

Could you specify what is in the wrong state? 

At least this ref [1] runs without shutdown. 


To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/df3f8c87-9def-42f3-93d0-12081bc5a5c3%40googlegroups.com.

Blake Garner

unread,
Jul 10, 2017, 2:12:02 PM7/10/17
to packe...@googlegroups.com

Just returned from vacation…

 

In the example below they are running the cloudbase-init installer and then manually shutting down the system. The invalid state I mentioned happened when sysprep was only partially done running and the power off command was sent by OpenStack to the OS.

 

For now I have a new workaround that waits for sysprep to finish and then the PowerShell provisioner will complete successfully. What I observed that the windows OS was already shutting down when OpenStack sends the power off command to the virtual hardware. This is basically what the Azure ARM example shows but I have a wrapper powershell script for sysprep because of a number of other steps that are needed with recent windows 10 build.

 

Thanks,

Blake

--

This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/YNwRJD6R60I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages