Puppet Bash Provider with Login Shell

While I was working on puppet-rvm, I noticed that the shell providers of puppet do not run as login shell.

This means:

exec { "echo $PATH"
  provider => "shell"

will have an empty path, because the .bashrc and others have not been loaded.

So if you install rvm for this user, the command rvm will not available.

A fix MIGHT be:

exec { "source ~/.rvm/scripts/rvm ; rvm current"
  provider => "shell",

what looks ugly. And in this case the PATH is not set, too. So you will source bashrc and others, too.

A solution is, to run bash with the --login parameter. This is my shortcut type: bash_exec.pp.

The new bash_exec should behave exactly like the exec type of puppet, with the difference, that the user's bash is started with --login parameter.


bash_exec { "echo $PATH":

returns a path, which contains RVM.


bash_exec { "rvm current":

works as expected.

In bash, open source, puppet by
@ 30 Mar 2014, Comments at Reddit & Hackernews