# Any module to run chroot commands?

I have to install few packages, libraries, and run some shell commands inside a chroot. Currently I am confined to use the 'exec' because, for all commands I have to invoke 'chroot' for running them inside chroot_dir. Eg:

exec { 'command':
command => "/usr/bin/sudo chroot $chroot_dir/ apt-get -y install package_name; /usr/bin/sudo chroot$chroot_dir/ apt-get update",
}


I have to use quite a lot of 'exec'(s) in my puppet script which doesn't look clean and makes the file unfriendly for the user to understand. Is there any other way of doing it more cleanly, or is there any puppet module which can assist?

You can quite easily write your own exec wrapper: https://puppet.com/docs/puppet/latest/lang_defined_types.html and with a splat you don't have to repeat all attributes https://puppet.com/docs/puppet/latest/lang_resources_advanced.html#setting-attributes-from-a-hash .