Sudo -i in bootstrap



Cucumber-chef uses chef to bootstrap a ‘test lab’ - ie an LXC host.
It then installs a container, on which chef also runs.

The way LXC wroks is to provide shell scripts - so-called templates
which set up chroots and perform various bits of configuration. I’ve
modified the default lucid template to install Ruby and Chef and a few
other bits and bobs, and to drop off a validation pem. The trouble is
that this template gets called by chef, as part of a bootstrap, which
uses sudo. The result of this is that $HOME gets passed through as
/home/ubuntu, which breaks gem installation in the container. If I
monkey patch bootstrap.rb to use sudo -i not sudo, it all works.


  1. Can anyone suggest a better approach?
  2. Can anyone think of any drawbacks to having sudo use -i?



Stephen Nelson-Smith,
Principal Consultant,
Atalanta Systems Ltd,
Twitter: @lordcope
Telephone: +44 (0) 1223 969819
Mobile: +44 (0) 7917 101919

Atalanta Systems: The Agile Infrastructure Enablers