Nam*_*yen 25 chef-infra vagrant
我正在尝试使用Chef安装石墨服务器,我遇到错误,说在VM上找不到chef-solo或chef-client.我正在使用Ubuntu 12.04.amd64 LTS,这是服务器版本,所以它不会安装chef-client.我知道13版本将自动安装chef-client但我不能使用13版本.
我用谷歌搜索,看到有人建议ssh到盒子和apt-get install chef-client.
我的问题是:无论如何我可以在厨师开始之前预先安装厨师 - 客户吗?基本上我希望我的厨师程序下载原始图像,无需用户额外的手动步骤即可完成所有操作.可能吗?
我的Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu-12.04-amd64"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.hostname = "graphite"
config.vm.network :forwarded_port, guest: 8080, host: 9090
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.roles_path = "roles"
chef.data_bags_path = "data_bags"
chef.add_role "Graphite-Server"
chef.add_role "StatsD-Server"
end
end
Run Code Online (Sandbox Code Playgroud)
错误日志:
[default] Running provisioner: chef_solo...
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.
Run Code Online (Sandbox Code Playgroud)
谢谢
Nam*_*yen 40
我找到了2个解决方案,两者都按预期工作:
1)方法1: 在你的Vagrantfile中,添加
config.omnibus.chef_version = :latest
这将确保在VM上安装chef-solo或chef-client,并且是厨师配置所必需的.要使用omnibus插件,请确保先安装插件:vagrant plugin install vagrant-omnibus
2)方法2:使用config.vm.provision如下所述的shell内联:https://github.com/mitchellh/vagrant-aws/issues/19#issuecomment-15487131.在您的Vagrantfile中,添加:
config.vm.provision "shell", path: "utils/tools/install_chef.bash"
我写的脚本utils/tools/install_chef.bash看起来像这样:
#!/bin/bash
function error
{
echo -e "\033[1;31m${1}\033[0m" 1>&2
}
function checkRequireRootUser
{
if [[ "$(whoami)" != 'root' ]]
then
error "ERROR: please run this program as 'root'"
exit 1
fi
}
function installChef()
{
if [[ "$(which chef-client)" = '' ]]
then
local chefProfilePath='/etc/profile.d/chef.sh'
curl -s -L 'https://www.opscode.com/chef/install.sh' | bash && \
echo 'export PATH="/opt/chef/embedded/bin:$PATH"' > "${chefProfilePath}" && \
source "${chefProfilePath}"
fi
}
function main()
{
checkRequireRootUser
installChef
}
main
Run Code Online (Sandbox Code Playgroud)
更新:
如果你得到以下错误:Unknown configuration section 'omnibus'.这意味着你缺少了omnibus插件.要安装它,请键入:vagrant plugin install vagrant-omnibus
| 归档时间: |
|
| 查看次数: |
9770 次 |
| 最近记录: |