dracoblue.net

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.

So:

bash_exec { "echo $PATH":
}

returns a path, which contains RVM.

And:

bash_exec { "rvm current":
}

works as expected.

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

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About