On Sunday, December 9, 2012 11:46:58 AM UTC-6, Smashed
wrote:>
> Has anyone found an elegant solution for working with puppet and rvm? Im
> using the following module: https://github.com/blt04/puppet-rvm and I
> keep finding myself having to prefix all of my Exec resources with
"''su
> root -c "source /etc/profile.d/rvm.sh && something". Any
ideas?
>
You shouldn''t need the "su root -c" part. All that does in
this context is
spawn a shell to parse and run the command. Instead, add "provider =>
''shell''" as a parameter of your Execs.
Alternatively, you only need a shell because your command is a pipeline,
and you only need a pipeline because you want to load the RVM environment
configuration. You can avoid doing that explicitly by opening a login
shell instead of a plain one: "su -l -c ''some
command''". Be warned,
however, that that will do a full environment setup, not just RVM.
More generally, Puppet Execs are intentionally run in a very sparse
environment, and those using the ''shell'' provider avoid
automatically
processing shell initialization scripts. If that''s not sufficient then
it
is the manifest author''s responsibility to ensure that an appropriate
environment is provided, one way or another. In addition to using the
''command'' property to do that as discussed above, the
''path'' and
''environment'' attributes can help.
To achieve more elegance than that allows, don''t exec commands that
rely on
RVM (or anything else that requires complex environment configuration). Of
course, if I were feeling catty then I would say that any real hope of
elegance requires avoiding RVM altogether. But I''m not feeling catty
this
morning. :-)
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/97GWiaqKNXwJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.