我正在尝试使用厨师配置一个流浪汉VM,但我不断收到以下消息:
“错误:未找到食谱。如果您正在从其他食谱中加载sis,请确保在元数据中配置依赖项。”
我当前的default.rb文件如下:
bash "apt update" do
code "apt-get update"
end
# manually install php 5.5....
execute "yum install -y --skip-broken php55w php55w-devel php55w-cli php55w-snmp php55w-soap php55w-xml php55w-xmlrpc php55w-process php55w-mysqlnd php55w-pecl-memcache php55w-opcache php55w-pdo php55w-imap php55w-mbstring"
bash "install mysql-server 5.1.69" do
user "root"
cwd "/tmp"
code <<-EOH
groupadd mysql
useradd -r -g mysql mysql
cd /usr/local
wget http://cdn.mysql.com/Downloads/MySQL-5.1/mysql-5.1.69-linux-i686-glibc23.tar.gz
tar zxvf mysql-5.1.69-linux-i686-glibc23.tar.gz
rm mysql-5.1.69-linux-i686-glibc23.tar.gz
ln -s mysql-5.1.69-linux-i686-glibc23 mysql
cd mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql.server
EOH
not_if do
File.exists?("/etc/my.cnf")
end
end
bash "start mysql-server 5.1.69" do
user "root"
code <<-EOH
sudo /etc/init.d/mysql.server start
/usr/local/mysql/bin/mysql -e 'GRANT ALL ON *.* TO root;'
EOH
end
我的元数据文件如下:
name "Test Machine"
maintainer "Claudio"
maintainer_email "******"
license "All rights reserved"
description "Installs/Configures sis"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.1"
我目前的Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.customize ["modifyvm", :id, "--memory", 512]
config.vm.network :hostonly, "192.168.100.10"
#config.vm.provision :shell, path: "bootstrap.sh"
# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "./cookbooks"
chef.roles_path = "./roles"
chef.data_bags_path = "./data_bags"
#hef.add_recipe "sis"
#chef.add_role "web"
# You may also specify custom JSON attributes:
chef.json = { :mysql_password => "foo" }
end
end
关于如何解决这个问题的任何想法?
答案 0 :(得分:0)
您的metadata.rb状态:
name "Test Machine"
您的食谱应位于名为“Test Machine”的文件夹中,而不是“sis”。或者你的metadata.rb必须更新。
花些时间learning chef来了解食谱写作的基础知识。
你没有说你正在使用哪个版本的厨师,所以我无法提供更多建议。
答案 1 :(得分:0)
元数据中的name
应显示食谱的名称。文件夹名称是什么并不重要,你的食谱所在的位置。
您的问题是您在食谱中有“测试机器”食谱,但在Vagrantfile中包含“sis”食谱。在metadata.rb中将名称更改为“sis”或在Vagrantfile中将chef.add_recipe "sis"
更改为chef.add_recipe "Test Machine"
。
答案 2 :(得分:0)
如果您的食谱位于cookbooks/sis/recipes/default.rb
然后使用像:
chef.cookbooks_path = "cookbooks"
chef.add_recipe "sis::default"
如果您有多个文件,例如cookbooks/sis/recipes/file1.rb...file2.rb
,请使用:
chef.add_recipe "sis::file1"
chef.add_recipe "sis::file2"
也保持正确的cookbook路径,你可以给像食谱的完整路径:
chef.cookbooks_path = "/home/user/fullpath/cookbooks"
cookbooks_path(字符串或数组) - 烹饪书的路径列表 存储。默认情况下,这是#34; cookbooks&#34;,期待一本烹饪书 相对于Vagrantfile位置的文件夹。