I have a running puppet server and want to do following steps on the puppet agent:
/usr/local/rbenv
(success)/etc/profile.d
, so that on every login then rbenv-environment ist loaded (success)rbenv install
(success)rbenv global
(fail for current login)The problem is, rbenv
started from an exec-resource in puppet switches the ruby version in a subshell, and stores that information somewhere. The ruby version for the current shell, where I startet puppet agent --test
is not changed. After logging out and in again, the puppet run is successful, because the environment is successfully loaded again.
So my question is: Is there a possibility to run the package provider in a new subshell? Or do I have to use another exec running gem install
?
So my question is: Is there a possibility to run the package provider in a new subshell? Or do I have to use another exec running gem install?
No. Providers run in the host Ruby instance. They may launch external commands, including shells, but they themselves are not run that way.
Furthermore, you said,
After logging out and in again, the puppet run is successful, because the environment is successfully loaded again.
If it really requires logging out and back in to make the rbenv reconfiguration active (which is unclear), then running the provider in a subshell wouldn't be effective anyway. Neither would running gem install
via an Exec
, unless that Exec
also expressly activated the desired Ruby environment.
If you are using Puppet to swap out the system's default Ruby, out from under itself, then you need to be prepared for inconsistent behavior. You may be able to work around it by employing an appropriate Exec
to perform the gem installation.