问题
How can I write this command in chef ?
/home/vagrant$ source ~/.rvm/scripts/rvm (->enter)
I tried...
execute "foo" do
command "source ~/.rvm/scripts/rvm"
action :run
end
in short, how can I write a simple command in chef? not installing something. thanks!!!
回答1:
This isn't something Chef supports. source
is a shell builtin, not a command, and it would have no effect on Ruby anyway has that isn't a Ruby script, it is a shell script. You can use a bash resource like this:
bash 'do the needful' do
code <<-EOH
source ~/.rvm/scripts/rvm
foo
EOH
end
回答2:
Aw forgot to get back here:
bash 'do the needful' do
user "target user"
code <<-EOH
echo 'source ~/.rvm/scripts/rvm' >> ${HOME}/.bashrc
EOH
end
I'm a little unsure on what $HOME would give in this case, maybe you'll have to specifiy the full path like /home/"target user"/.bashrc.
give it a try
来源:https://stackoverflow.com/questions/25756486/chef-commands-help