[packer] Reusing the state of a failed provisioned system

2018-02-11 Thread tushar mathur
Hi,

I am trying to provision my ami using a set of custom shell scripts. Sadly 
every time they fail I have to recreate an ec2 instance from scratch. This 
makes sense when I am deploying in production but at the time of debugging 
and trying out different commands it becomes really slow. 

Is there a way for me to actually reuse the state in which ec2 instance is 
currently and keep running the provisioners again and again?

I tried the --on-error argument but that only runs on the last failed step 
where as what I really want is to run the provisioning again from scratch.

packer build --debug  -on-error=ask packer-aws.json

Thanks!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/bcb7f49c-7225-4bbd-8cec-5caa2d863aba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [packer] Reusing the state of a failed provisioned system

2018-02-11 Thread Rickard von Essen
Usually I add a null builder to the template. Then you can either A) add a
inline "sleep 3600" start a build with "packer build -only amazon-ebs
template.json". And when it pauses the provisioning in another terminal run
"packer build -only null -var debug_ip=IP -var private_key...
template.json" and iterate over your provisioning scripts quickly. Or B)
just launch a EC2 instance manually and run the null builder against that.


{
"variables": {
"debug_ip": "",
"private_key": "",
"keypair": ""
},
"builders": [
{
"type": "amazon-ebs",
   [...]
},
{
"type": "null",
"ssh_host": "{{ user `debug_ip`}}",
"ssh_username": "{{ user `username`}}",
"ssh_private_key_file": "{{ user `private_key`}}"
}
],
}


On 11 February 2018 at 12:11, tushar mathur  wrote:

> Hi,
>
> I am trying to provision my ami using a set of custom shell scripts. Sadly
> every time they fail I have to recreate an ec2 instance from scratch. This
> makes sense when I am deploying in production but at the time of debugging
> and trying out different commands it becomes really slow.
>
> Is there a way for me to actually reuse the state in which ec2 instance is
> currently and keep running the provisioners again and again?
>
> I tried the --on-error argument but that only runs on the last failed step
> where as what I really want is to run the provisioning again from scratch.
>
> packer build --debug  -on-error=ask packer-aws.json
>
> Thanks!
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/packer-tool/bcb7f49c-7225-4bbd-8cec-5caa2d863aba%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt-Jy75tgnKLHWaubrW1w_sGifM%3DW0xae6c7vHUd8Trp0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[packer] Re: WinRM communicator: "Failed to send shutdown command: unknown error"

2018-02-11 Thread Chaim Eliyah
Shoot, my current status is "unable to reproduce" when I tried `packer 
build` a second time just now. If I see the issue again I'll re-post. If 
this is an issue for anyone else I left a link to this page on the GitHub 
issue, feel free to chime in.

On Sunday, February 11, 2018 at 1:18:37 PM UTC-8, Chaim Eliyah wrote:
>
> Full error message:
>
> ==> virtualbox-iso: Failed to send shutdown command: unknown error Post 
> http://127.0.0.1:3497/wsman: EOF
>
> I opened an issue here: https://github.com/hashicorp/packer/issues/5857
>
> I was redirected to this group.
>
> As for WinRM being "configured incorrectly" it's not; here's my JSON:
>
> {
>
>   "variables": {
>
> "cloud_token": "{{ env `ATLAS_TOKEN` }}"
>
>   },
>
>   "builders": [
>
> {
>
>   "type": "virtualbox-iso",
>
>   "boot_wait": "1m",
>
>   "communicator": "winrm",
>
>   "disk_size": "6",
>
>   "guest_additions_mode": "attach",
>
>   "guest_os_type": "Windows10_64",
>
>   "headless": true,
>
>   "iso_url": 
> "en_windows_10_multi-edition_version_1709_updated_sept_2017_x64_dvd_100090817.iso",
>
>   "iso_checksum": "5e8bdef20c4b468f868f1f579197f7cf",
>
>   "iso_checksum_type": "md5",
>
>   "output_directory": "windows-base",
>
>   "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer 
> Shutdown\"",
>
>   "vm_name": "Windows10_64-base",
>
>   "winrm_username": "vagrant",
>
>   "winrm_password": "vagrant",
>
>   "floppy_files": [
>
> "./answer_files/10/Autounattend.xml",
>
> "./scripts/fixnetwork.ps1",
>
> "./scripts/microsoft-updates.bat",
>
> "./scripts/win-updates.ps1",
>
> "./scripts/openssh.ps1"
>
>   ],
>
>   "vboxmanage": [
>
> ["modifyvm", "{{.Name}}", "--memory", "4096"],
>
> ["modifyvm", "{{.Name}}", "--cpus", "2"],
>
> ["modifyvm", "{{.Name}}", "--vram", "128"]
>
>   ],
>
>   "virtualbox_version_file": ""
>
> }
>
>   ],
>
>   "post-processors": [[
>
> {
>
>   "type": "vagrant",
>
>   "keep_input_artifact": true,
>
>   "output": "build/windows.box",
>
>   "vagrantfile_template": "vagrantfile-windows.template"
>
> },
>
> {
>
>   "type": "vagrant-cloud",
>
>   "box_tag": "shiftwise/windows-base",
>
>   "access_token": "{{user `cloud_token`}}",
>
>   "version": "0.0.2"
>
> }
>
>   ]]
>
> }
>
> ...so most of the configuration is the default configuration outlined at:
>
> https://www.packer.io/docs/templates/communicator.html
>
> The port it's attempting to communicate on is "3497" when the WinRM 
> default is "5986" according to the documentation.
>
> I tried the workaround indicated in the GitHub issue, but that didn't 
> solve the issue.
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/e4269a7a-b661-4669-b0ef-4194ed6116c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[packer] WinRM communicator: "Failed to send shutdown command: unknown error"

2018-02-11 Thread Chaim Eliyah
Full error message:

==> virtualbox-iso: Failed to send shutdown command: unknown error Post 
http://127.0.0.1:3497/wsman: EOF

I opened an issue here: https://github.com/hashicorp/packer/issues/5857

I was redirected to this group.

As for WinRM being "configured incorrectly" it's not; here's my JSON:

{

  "variables": {

"cloud_token": "{{ env `ATLAS_TOKEN` }}"

  },

  "builders": [

{

  "type": "virtualbox-iso",

  "boot_wait": "1m",

  "communicator": "winrm",

  "disk_size": "6",

  "guest_additions_mode": "attach",

  "guest_os_type": "Windows10_64",

  "headless": true,

  "iso_url": 
"en_windows_10_multi-edition_version_1709_updated_sept_2017_x64_dvd_100090817.iso",

  "iso_checksum": "5e8bdef20c4b468f868f1f579197f7cf",

  "iso_checksum_type": "md5",

  "output_directory": "windows-base",

  "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer 
Shutdown\"",

  "vm_name": "Windows10_64-base",

  "winrm_username": "vagrant",

  "winrm_password": "vagrant",

  "floppy_files": [

"./answer_files/10/Autounattend.xml",

"./scripts/fixnetwork.ps1",

"./scripts/microsoft-updates.bat",

"./scripts/win-updates.ps1",

"./scripts/openssh.ps1"

  ],

  "vboxmanage": [

["modifyvm", "{{.Name}}", "--memory", "4096"],

["modifyvm", "{{.Name}}", "--cpus", "2"],

["modifyvm", "{{.Name}}", "--vram", "128"]

  ],

  "virtualbox_version_file": ""

}

  ],

  "post-processors": [[

{

  "type": "vagrant",

  "keep_input_artifact": true,

  "output": "build/windows.box",

  "vagrantfile_template": "vagrantfile-windows.template"

},

{

  "type": "vagrant-cloud",

  "box_tag": "shiftwise/windows-base",

  "access_token": "{{user `cloud_token`}}",

  "version": "0.0.2"

}

  ]]

}

...so most of the configuration is the default configuration outlined at:

https://www.packer.io/docs/templates/communicator.html

The port it's attempting to communicate on is "3497" when the WinRM default 
is "5986" according to the documentation.

I tried the workaround indicated in the GitHub issue, but that didn't solve 
the issue.


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/76d1a04e-30d2-4dd5-83ed-69b0168a44d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.