Closed bklang closed 10 years ago
Packer JSON is here: https://gist.github.com/bklang/99f836c58eb7fdc0c5c8
I re-ran this with PACKER_LOG=1. Here is the output: https://gist.github.com/bklang/5735c72bae56a7d6c2e8
Fixed
Unfortunately I'm still getting this error. Though this time my build failed due to a chef error, the knife cleanup still failed with a similar usage message:
virtualbox-iso: Chef Client failed. 110 resources updated in 2290.445683109 seconds
virtualbox-iso: [2014-05-02T02:02:07+00:00] ERROR: deploy_revision[stentofon] (/var/chef/cache/cookbooks/application/providers/default.rb line 123) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
virtualbox-iso: ---- Begin output of git ls-remote "git@github.com:mojolingo/stentofon_demo.git" HEAD ----
virtualbox-iso: STDOUT:
virtualbox-iso: STDERR: Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
virtualbox-iso: Permission denied (publickey).
virtualbox-iso: fatal: The remote end hung up unexpectedly
virtualbox-iso: ---- End output of git ls-remote "git@github.com:mojolingo/stentofon_demo.git" HEAD ----
virtualbox-iso: Ran git ls-remote "git@github.com:mojolingo/stentofon_demo.git" HEAD returned 128
virtualbox-iso: [2014-05-02T02:02:07+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
==> virtualbox-iso: Cleaning up chef node...
virtualbox-iso: USAGE: knife node delete NODE (options)
virtualbox-iso: -s, --server-url URL Chef Server URL
virtualbox-iso: --chef-zero-port PORT Port to start chef-zero on
virtualbox-iso: -k, --key KEY API Client Key
virtualbox-iso: --[no-]color Use colored output, defaults to false on Windows, true otherwise
virtualbox-iso: -c, --config CONFIG The configuration file to use
virtualbox-iso: --defaults Accept default values for all questions
virtualbox-iso: -d, --disable-editing Do not open EDITOR, just accept the data as is
virtualbox-iso: -e, --editor EDITOR Set the editor to use for interactive commands
virtualbox-iso: -E, --environment ENVIRONMENT Set the Chef environment
virtualbox-iso: -F, --format FORMAT Which format to use for output
virtualbox-iso: -z, --local-mode Point knife commands at local repository instead of server
virtualbox-iso: -u, --user USER API Client Username
virtualbox-iso: --print-after Show the data after a destructive operation
virtualbox-iso: -V, --verbose More verbose output. Use twice for max verbosity
virtualbox-iso: -v, --version Show chef version
virtualbox-iso: -y, --yes Say yes to all prompts for confirmation
virtualbox-iso: -h, --help Show this message
virtualbox-iso:
==> virtualbox-iso: Unregistering and deleting virtual machine...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Error cleaning up chef node: exit status 1
==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso: Error cleaning up chef node: exit status 1
==> Builds finished but no artifacts were created.
Makefile:16: recipe for target 'vm' failed
gmake: *** [vm] Error 1
$ packer version
Packer v0.6.0.dev (5c5d62733f25756ec38d8606b91ff1030d144758)
Also, this is still happening on a successful chef-client run:
virtualbox-iso: Chef Client finished, 119/158 resources updated in 2174.047755357 seconds
==> virtualbox-iso: Cleaning up chef node...
virtualbox-iso: USAGE: knife node delete NODE (options)
virtualbox-iso: -s, --server-url URL Chef Server URL
virtualbox-iso: --chef-zero-port PORT Port to start chef-zero on
virtualbox-iso: -k, --key KEY API Client Key
virtualbox-iso: --[no-]color Use colored output, defaults to false on Windows, true otherwise
virtualbox-iso: -c, --config CONFIG The configuration file to use
virtualbox-iso: --defaults Accept default values for all questions
virtualbox-iso: -d, --disable-editing Do not open EDITOR, just accept the data as is
virtualbox-iso: -e, --editor EDITOR Set the editor to use for interactive commands
virtualbox-iso: -E, --environment ENVIRONMENT Set the Chef environment
virtualbox-iso: -F, --format FORMAT Which format to use for output
virtualbox-iso: -z, --local-mode Point knife commands at local repository instead of server
virtualbox-iso: -u, --user USER API Client Username
virtualbox-iso: --print-after Show the data after a destructive operation
virtualbox-iso: -V, --verbose More verbose output. Use twice for max verbosity
virtualbox-iso: -v, --version Show chef version
virtualbox-iso: -y, --yes Say yes to all prompts for confirmation
virtualbox-iso: -h, --help Show this message
virtualbox-iso:
==> virtualbox-iso: Unregistering and deleting virtual machine...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Error cleaning up chef node: exit status 1
==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso: Error cleaning up chef node: exit status 1
==> Builds finished but no artifacts were created.
Makefile:16: recipe for target 'vm' failed
gmake: *** [vm] Error 1
Digging into this further, I'm finding that the node
variable is empty, resulting in a knife command like this: knife node delete -y
. I'm still digging into why it's empty.
I've finally realized the problem, and it was already documented:
node_name (string) - The name of the node to register with the Chef Server. This is optional and by default is empty. If you don't set this, Packer can't clean up the node from the Chef Server using knife.
So first, my apologies for not noticing this before. But may I suggest that this field be made mandatory? Though the setting is described as "optional", because the knife cleanup fails after successful provisioning, the VM build is destroyed. This leads to confusion and (at least in my case) a lot of time wasted trying to figure out why the chef provision is working but the node cleanup is failing. If you want to keep the field optional, then the knife cleanup failure should not destroy the VM.
Also, perhaps the default value could be "localhost", to match chef-client's default behavior? This way the knife cleanup won't fail if the name isn't specified.
The chef-client provisioner successfully creates and provisions the VM, but then fails to clean up with the knife usage message being printed to stdout: