【发布时间】:2015-10-25 18:52:33
【问题描述】:
我正在尝试使用 Chef 配置一个 vagrant VM,但我不断收到以下消息:
“错误:未找到食谱 sis。如果您从另一个食谱加载 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
知道如何解决这个问题吗?
【问题讨论】:
-
执行和 bash 步骤应该是厨师食谱中的例外。包资源例如处理 yum。
-
“sis”实际出现在您的代码中的什么位置?你只显示在食谱描述中,这不会引发错误。
-
我在 cookbooks/sis 中有 sis 文件夹。 sis 文件夹包含 recipes 文件夹。
-
那么,这个姐姐本身?即您粘贴在 cookbooks/sis/recipes/default.rb 中?你在用 berkshelf 吗?
-
好的,所以首先我的依赖“sis”解决了 nada。我假设你在 使用 sis,而不是你在 on sis。其次,您的整个 recipes/default.rb 也有点离题 - 问题更可能在于您配置 Chef 和 Vagrant 的更广泛的方式。你的 Vagrantfile 是什么样的?您的 Berksfile 是什么样的(假设您使用的是 Berks)。事实上,在你的命令行上运行 chef --v 并将结果粘贴到你的帖子中,它会告诉我们你正在使用什么 Chef。
标签: vagrant chef-infra provisioning