CHEF commands help ,

泄露秘密 提交于 2019-12-25 16:34:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!