Vagrant Install chef-klient na podstawie obrazu
Próbuję użyć Chef do zainstalowania serwera graphite i napotkałem błędy mówiące, że chef-solo lub Chef-client nie został znaleziony na maszynie wirtualnej. Używam Ubuntu 12.04.amd64 LTS, jest to wersja serwerowa więc nie będzie miał zainstalowanego chef-client. Wiem, że wersja 13 będzie miała zainstalowany chef-client, ale nie mogę użyć wersji 13.
Wygooglowałem i zobaczyłem, że niektórzy sugerują ssh do box i apt-get install chef-client.
Moje pytanie brzmi: czy w ogóle mogę preinstall chef-client zanim chef kopnął w? Zasadniczo chciałbym, aby mój program chef pobierał obraz w formacie raw i robił wszystko bez dodatkowych instrukcji od użytkowników. Czy to możliwe?
Mój 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
Dziennik Błędów:
[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.
Dzięki
2 answers
Znalazłem 2 rozwiązania i oba działają zgodnie z oczekiwaniami:
1) Metoda 1: W Twoim pliku Vagrantfile dodaj
config.omnibus.chef_version = :latest
Spowoduje to, że chef-solo lub chef-client zostanie zainstalowany na maszynie wirtualnej i będzie wymagany do obsługi chef. Aby użyć wtyczki omnibus, upewnij się, że najpierw zainstalujesz wtyczkę: vagrant plugin install vagrant-omnibus
2) Metoda 2: użycie config.vm.provision
powłoka inline jak wspomniano tutaj: https://github.com/mitchellh/vagrant-aws/issues/19#issuecomment-15487131 . w Twoim Vagrantfile dodaj:
config.vm.provision "shell", path: "utils/tools/install_chef.bash"
Skrypt utils / tools / install_chef.bash że napisałem wygląda tak:
#!/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
UPDATE:
Jeśli pojawi się następujący błąd: Unknown configuration section 'omnibus'
. Oznacza to, że brakuje wtyczki omnibus. Aby go zainstalować, wpisz: vagrant plugin install vagrant-omnibus
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-03-11 15:04:08
Mogę polecić Vagrant-omnibus plugin, który w zasadzie wykonuje skrypt install.sh
dla Ciebie, jeśli chef nie jest zainstalowany.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-22 06:49:36