Chef infra 如何在厨师食谱中转换以下shell命令?

Chef infra 如何在厨师食谱中转换以下shell命令?,chef-infra,vagrant,chef-recipe,Chef Infra,Vagrant,Chef Recipe,如何在厨师食谱中转换以下shell命令 安装 sudo easy_install pygments sudo echo 'export RAILS_ENV=production' >> ~/.bash_profile sudo adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git ssh-keygen -t rsa

如何在厨师食谱中转换以下shell命令

安装

sudo easy_install pygments
sudo echo 'export RAILS_ENV=production' >> ~/.bash_profile
sudo adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git
ssh-keygen -t rsa
sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

echo "gem: --no-rdoc --no-ri" > ~/.gemrc
rvmsudo gem install passenger
rvmsudo passenger-install-nginx-module
重新启动虚拟机

sudo shutdown -r now
验证nginx是否正在运行

sudo initctl list | grep nginx

这不一定是实现这一点的完美方法,但它应该可以工作(注意,我还没有测试过)

在烹饪书的元数据中,首先确保您具有以下内容:

depends "python"
然后,您的食谱可以如下所示:

pip_package "pygments"

execute "echo 'export RAILS_ENV=production' >> ~/.bash_profile" do
  not_if "grep RAILS_ENV ~/.bash_profile"
end

user "git" do
  system True
end

execute "ssh-keygen -N '' -f ~/.ssh/id_rsa"
  user "git"
  not_if "test -f /home/git/.ssh/id_rsa"
end

execute "gitosis-init < ~/.ssh/id_rsa.pub && chmod 755 ~/repositories/gitosis-admin.git/hooks/postupdate"
  #not sure how do check if this has been run, maybe this is right:
  not_if "test -f /home/git/repositories/gitosis-admin.git/hooks/post-update"
end

gem_package "passenger" do
  action :install
end

#Instead of creating your own upstart service, why not use the stock nginx config.
include_recipe "nginx"

execute "passenger-install-nginx-module" do
  #I'm not familiar with this, so I don't know how to check if it's already been run.
  notifies :restart, "service[nginx]"
end
pip_包“pygments”
执行“echo”export RAILS\u ENV=production'>>~/.bash\u profile“do”
如果是“grep RAILS\u ENV~/.bash\u profile”,则不是
结束
用户“git”do
系统正确
结束
执行“ssh keygen-N'-f~/.ssh/id\u rsa”
用户“git”
如果“test-f/home/git/.ssh/id\u rsa”,则不可用
结束
执行“gitosis init<~/.ssh/id\u rsa.pub&&chmod 755~/repositories/gitosis admin.git/hooks/postapdate”
#不确定如何检查是否已运行,也许这是正确的:
如果“test-f/home/git/repositories/gitosis admin.git/hooks/post update”,则不是
结束
gem_套餐“乘客”吗
操作:安装
结束
#与其创建自己的upstart服务,不如使用股票nginx配置。
包括配方“nginx”
执行“乘客安装nginx模块”do
#我不熟悉这个,所以我不知道如何检查它是否已经运行过。
通知:重新启动,“服务[nginx]”
结束

顺便说一句,大部分信息应该可以从chef docs中访问。

您可以将其包装在一个bash语句中:bash“总体任务描述”do user“root”cwd“/tmp”code/home/username/。bash\u profile。。。EOH端
pip_package "pygments"

execute "echo 'export RAILS_ENV=production' >> ~/.bash_profile" do
  not_if "grep RAILS_ENV ~/.bash_profile"
end

user "git" do
  system True
end

execute "ssh-keygen -N '' -f ~/.ssh/id_rsa"
  user "git"
  not_if "test -f /home/git/.ssh/id_rsa"
end

execute "gitosis-init < ~/.ssh/id_rsa.pub && chmod 755 ~/repositories/gitosis-admin.git/hooks/postupdate"
  #not sure how do check if this has been run, maybe this is right:
  not_if "test -f /home/git/repositories/gitosis-admin.git/hooks/post-update"
end

gem_package "passenger" do
  action :install
end

#Instead of creating your own upstart service, why not use the stock nginx config.
include_recipe "nginx"

execute "passenger-install-nginx-module" do
  #I'm not familiar with this, so I don't know how to check if it's already been run.
  notifies :restart, "service[nginx]"
end