Rex
Rex copied to clipboard
Add chroot support
Two methods have been discussed so far:
run 'command', chroot => { newroot => '/chroot/here' };
and
task "foo", sub {
chroot "/some/path", sub {
pkg "vim";
service "blah", ensure => "running";
};
};
I see three options in relation to original intent of issue.
- Single command. In this one, I am not sure a nested hash is necessary. If the chroot string is present it is a directory. Otherwise, a hash could be available for options:
run 'cmd', chroot => '/chroot/here';
run 'cmd', chroot => { newroot => '/chroot/here', bang => 'diddly' };
- A block of commands (could also be like
LOCAL):
task 'foo', sub {
statement_0;
chroot '/chroot/here', sub {
statement_1;
statement_2;
};
statement_3;
};
- An entire task, in the vein of
no_ssh:
chroot task 'foo', sub {
statement_0;
};
In the first two, it should make sense that some commands could be in a chroot while some commands could be on the target, just like some commands for a remote task could be local. But I think the last case is the least useful. How a task is run is a property of the host it is run against, not of the task.
So I am wondering if "running in a chroot" could be generalized to other connection forms. Connecting via ssh is kind of like setting up a chroot and then entering it.