0

I'm trying to deploy with chef-solo which is run by the vagrant-aws plugin for Vagrant. vagrant-aws is successful in launching an EC2 instances, rsyncing chef cookbooks and then starting a chef run. I'm using mostly stock cookbooks downloaded through the librarian-chef gem. There is one application-specific cookbook that configures the app's settings. The sudo cookbook is v2.7.0.

The issue is that every time I try to provision an instance, chef gets stuck editing /etc/sudoers. If I ssh into the instance, I find that the chef process is not running. It seems to exit without any return code because vagrant-aws never finishes running either.

Here is the --debug output from vagrant up production --provider=aws:

==> production: [2014-08-21T02:02:46+00:00] INFO: template[/etc/sudoers] backed up to /var/chef/backup/etc/sudoers.chef-20140821020246.492236
DEBUG ssh: stdout: [2014-08-21T02:02:46+00:00] INFO: template[/etc/sudoers] updated file contents /etc/sudoers

 INFO interface: info: [2014-08-21T02:02:46+00:00] INFO: template[/etc/sudoers] updated file contents /etc/sudoers
 INFO interface: info: ==> production: [2014-08-21T02:02:46+00:00] INFO: template[/etc/sudoers] updated file contents /etc/sudoers
==> production: [2014-08-21T02:02:46+00:00] INFO: template[/etc/sudoers] updated file contents /etc/sudoers
DEBUG ssh: Sending SSH keep-alive...

Then it just repeats the last line over and over. After a while, the chef-solo process dies but without cleaning up /var/chef/cache/chef-client-running.pid. If I run chef-solo again manually on the instance it finishes normally.

Reed G. Law
  • 3,897
  • 1
  • 41
  • 78
  • It looks like it is more hanging up after the sudoers change as the log state it has updated the file. What is the next resource in the runlist? you may also try to change the sudoers file adding a comment and run chef manually to see if it does the same thing) – Tensibai Aug 21 '14 at 14:20
  • Can you run with `log_level :debug` please? – sethvargo Aug 21 '14 at 14:38
  • @sethvargo I only encounter this problem when running chef through vagrant-aws. I already append `--debug` to the vagrant command. If I run chef manually on the server it runs fine. – Reed G. Law Aug 22 '14 at 12:34
  • It sounds like an AWS-specific issue then? – sethvargo Aug 22 '14 at 15:02

1 Answers1

0

Try disabling:

config.ssh.pty

option from your Vagrantfile. Usually it's the common reason for that kind of hangs.

In Vagrant docs for config.ssh.pty we can read that:

This setting is an advanced feature that should not be enabled unless absolutely necessary. It breaks some other features of Vagrant, and is really only exposed for cases where it is absolutely necessary. If you can find a way to not use a pty, that is recommended instead.

As I had similar issue with apt-get.


Troubleshooting vagrant hangs

  • on Unix/OS X you can press Ctrl+T to check the process state (why it's handing)
  • run (install lldb if needed):

    echo "call (void)rb_backtrace()" | lldb -p $(pgrep -fn ruby)
    

    to print Ruby backtrace on the foreground (you can use gdb as well)

  • perform logging, e.g.: vagrant --debug up 2> frozen.log and the working configuration to works.log, then compare with a diff tool

  • on Unix/OS X run: sudo dtruss -fn ruby (or vagrant), on Linux use strace/ltrace to debug the process
  • see: Check why ruby script hangs for more suggestions
Community
  • 1
  • 1
kenorb
  • 155,785
  • 88
  • 678
  • 743