Any module to run chroot commands?

asked 2017-11-10 01:08:29 -0600

updated 2017-11-13 05:12:22 -0600

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?

Thanks in advance. (Mayank71d)

edit retag flag offensive close merge delete

Comments

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 .

Kai Burghardt gravatar imageKai Burghardt ( 2017-11-13 07:50:27 -0600 )edit