我正在configuration一个带有Chef的Vagrant虚拟机,这真是太棒了,但是我不确定在哪里放置代码来configuration由第三方厨师食谱安装的软件。
例如,我正在用这个配方安装NGINX,但是我需要configuration默认的虚拟主机来为/vagrant/public而不是/var/www/nginx-default 。
我应该更改第三方配方的模板,还是创build另一个重新configuration它的配方?
几件事情:
自从为这个问题撰写以来,Opscode已经将他们的存储库结构分成了一个“每个食谱”,以使项目更清晰。
最新发布的,稳定的nginx食谱可以在这里find: http : //community.opscode.com/cookbooks/nginx
为了从备用容器提供网页:
这样做的惯例是编写一个简单的食谱,利用nginx食谱,但为您提供了一个“做你想做的”的方法。
由于默认的nginx安装会丢弃一个configuration文件并设置源代码目录,我将在“包装”菜谱中执行此操作的方法是:
depends 'nginx'于metadata.rb depends 'nginx' 在我的食谱的attributes/default.rb ,将以下属性设置为false:
default['nginx']['default_site_enabled'] = false
在我的recipes/default.rb ,有:
include_recipe 'nginx' cookbook_file '/etc/nginx/sites-available/mycustomwebapp' nginx_site 'mycustomwebapp' do action :enable end
在files/default/mycustomwebapp创build一个如下所示的nginx conf文件:
server { root /vagrant/public; index index.html index.htm; blah blah... }
那么你应该好好去!