Skip to content

Instantly share code, notes, and snippets.

@mapyo
Created October 27, 2014 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapyo/21c686b31a3ccd674649 to your computer and use it in GitHub Desktop.
Save mapyo/21c686b31a3ccd674649 to your computer and use it in GitHub Desktop.
rbenv.shを/etc/profile.dに置いて、それをsourceコマンドで読み込ませる。
file { 'rbenv/profile.d/rbenv.sh':
path => '/etc/profile.d/rbenv.sh',
content => '## rbenv setting
export RBENV_ROOT="/usr/local/rbenv"
export PATH="/usr/local/rbenv/bin:$PATH"
eval "$(rbenv init -)"
',
require => Exec['clone rbenv']
}
~>
exec { 'source /etc/profile.d/rbenv.sh':
command => "bash -c 'source /etc/profile.d/rbenv.sh'",
path => ['/bin', '/usr/bin', '/usr/local/rbenv/bin', '/usr/local/rbenv/plugins/ruby-build/bin/'],
user => 'vagrant',
refreshonly => true,
require => File['rbenv/profile.d/rbenv.sh']
}
@mapyo
Copy link
Author

mapyo commented Oct 27, 2014

やりたい事としては、
vagrant上でsudo puppet applyした後に、
そのまま、vagrantユーザでsource /etc/profile.d/rbenv.shが実行された状態にしたい。

でも、これだと、今実行中のvagrantユーザでsourceコマンドが実行された状態にはならない。。。

@lamanotrama
Copy link

普通にはむりじゃないかな。
puppet applyをシェルスクリプトでラップしたらいいのでは。

#!/bin/sh
set -e
sudo puppet apply "$@"
exec $SHELL -l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment