sprinkle-tool / sprinkle

Sprinkle is a software provisioning tool you can use to build remote servers with. eg. to install a Rails, or Sinatra stack on a brand new slice directly after its been created
https://github.com/sprinkle-tool/sprinkle
MIT License
1.15k stars 138 forks source link

Local installation in chroot environment (e. g. for vmbuilder) #72

Closed mbartosch closed 11 years ago

mbartosch commented 12 years ago

I am currently working on a script that automatically creates a VM appliance for a project via Ubuntu vmbuilder (see http://manpages.ubuntu.com/manpages/precise/man1/vmbuilder.1.html)

The vmbuilder script creates a build directoy in which the target VM file system is prepared. This already works fine.

Now my installation procedure is going to be horridly complex, much too complex for the mechanisms provided by vmbuilder. For example I need install a plethora of packages, then I need to modify a lot of configuration files (partly using templates) and run a lot of commands to initialize the database and LDAP directory within the VM (the goal is to create an appliance including a fully configured PKI environment using http://www.openxpki.org as a showcase for the project)

vmbuilder provides a postinstall script hook which can be used to run commands chrooted in the target directory.

Now my idea is to use Sprinkle to perform the deployment work once the base installation has been prepared in the build directory. I would like to have Sprinkle copy files to the target directory (which can be done with the "local" actor) and more importantly run chrooted commands to perform tasks within the target environment.

Questions: is Sprinkle the right tool for the task? And do you think it is both sensible and possible to have a "chroot" actor that executes commands within the target environment?

My ruby knowledge is very limited, but I'd be willing to develop a chroot actor and contribute a pull request is somebody with insight tells me that Sprinkle is in principle capable of doing this.

joshgoebel commented 12 years ago

No idea. The local support has always seemed silly to me (much better ways to do things locally, IMHO)... so I only use the remote SSH/Cap support... not sure how well it might suit your purpose or not.

joshgoebel commented 11 years ago

I think if you did this you'd want to enhance the local actor to support a chroot option, not create a whole new actor... since all you're wanting is to use the local actor inside a chroot... no?

joshgoebel commented 11 years ago

If you ever get around to writing this please open another issue or submit a pull request and we'll have a look. I don't feel this would be generally useful for most Sprinkle users though so I'm going to close this for now. It could be all you need to do is subclass Local and then hack all commands to run via chroot.

class ChrootLocal < Local

def process(name, commands, roles, opts = {})
  commands = commands.map {|x| "chroot /rooted/ #{x}" }
  super(name, commands, roles, opts = {})
end

I doubt it's quite that simple, but just an idea to get you started.