Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

add chef exec command #22

Merged
merged 14 commits into from
May 2, 2014
Merged

add chef exec command #22

merged 14 commits into from
May 2, 2014

Conversation

lamont-granquist
Copy link
Contributor

Add chef exec command to exec a command but with the environment variables overridden to bust out of any rvm/rbenv/chruby whatever environment and do everything relative to the embedded ruby and with all the omnibus stuff first in the path.

@lamont-granquist
Copy link
Contributor Author

this addresses the 'chef exec' part of #18

needs specs and such

banner "Usage: chef exec SYSTEM_COMMAND"

def run(params)
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where this is being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, removed where i was playing around with using that...

@sethvargo
Copy link

👍 super simple and gets the job done

@adamedx
Copy link

adamedx commented Apr 24, 2014

No real feedback, other than to say this is a feature I definitely want.

'GEM_HOME' => ENV['GEM_HOME'],
'GEM_PATH' => Gem.path.join(':'),
}
cmd = Mixlib::ShellOut.new( *params.clone, :env => env, :live_stream => STDOUT )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just exec for real here?

@lamont-granquist
Copy link
Contributor Author

@danielsdeleo updated...

@lamont-granquist lamont-granquist changed the title WIP: adding chef exec add chef exec command Apr 28, 2014
def run(params)
user_bin_dir = File.expand_path(File.join(Gem.user_dir, 'bin'))
env = {
'PATH' => "#{user_bin_dir}:#{omnibus_embedded_bin_dir}:#{ENV['PATH']}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we up-factor this, too, either a method that returns an Array or this String? I'd still like to do the shell-init thing and it'd be best to keep consistent between the two.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the PATH or also the other env vars?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably just the PATH, at least for now. I think if you want to go all-in on ChefDK as your ruby environment, it makes more sense to just disable any rvm or whatever rather than stomping on all the environment variables?

@lamont-granquist
Copy link
Contributor Author

@danielsdeleo i went with an omnibus_env helper so you can get that from omnibus_env['PATH'], or have the other stuff available as well. don't think that'll hurt any and it makes the chef exec code completely trivial.

@ivey
Copy link

ivey commented Apr 29, 2014

selfie-0

👍 I was about to write this, then I saw it was already done.

lamont-granquist added a commit that referenced this pull request May 2, 2014
@lamont-granquist lamont-granquist merged commit 994e4fc into master May 2, 2014
@lamont-granquist lamont-granquist deleted the lcg/chef-exec branch May 2, 2014 20:05
@chef-boneyard chef-boneyard locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants