Vagrant Instala chef-client en la parte superior de la imagen base


Estoy tratando de usar Chef para instalar graphite server y me encontré con errores que decían que chef-solo o chef-client no se encontró en la máquina virtual. Estoy usando Ubuntu 12.04.amd64 LTS, esta es la versión del servidor por lo que no tendrá instalado chef-client. Sé que la versión 13 tendrá instalado automáticamente chef-client, pero no puedo usar la versión 13.

Busqué en Google y vi a algunas personas sugerir a ssh a la caja y apt-get install chef-client.

Mi pregunta es: ¿hay de todos modos que pueda preinstalar chef-cliente antes de chef pateado en? Básicamente me gustaría que mi programa chef descargue la imagen raw y haga todo sin pasos manuales adicionales de los usuarios. Es posible?

Mi 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

Registro de errores:

[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.

Gracias

Author: Nam Nguyen, 2014-01-22

2 answers

Encontré 2 soluciones y ambas funcionan como se esperaba:

1) Método 1: En su Vagrantfile, agregue

config.omnibus.chef_version = :latest

Esto asegurará que chef-solo o chef-client esté instalado en la máquina virtual y sea necesario para el aprovisionamiento de chef. Para usar el complemento omnibus, asegúrese de instalar el complemento primero: vagrant plugin install vagrant-omnibus

2) Método 2: Uso config.vm.provision shell en línea como se mencionó aquí: https://github.com/mitchellh/vagrant-aws/issues/19#issuecomment-15487131 . En su Vagrantfile, agregue:

config.vm.provision "shell", path: "utils/tools/install_chef.bash"

El script utils/tools/install_chef.bash que escribí se ve así:

#!/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

ACTUALIZACIÓN:

Si obtiene el siguiente error: Unknown configuration section 'omnibus'. Significa que le falta el complemento omnibus. Para instalarlo, escriba: vagrant plugin install vagrant-omnibus

 40
Author: Nam Nguyen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-11 15:04:08

Puedo recomendar el complemento vagrant-omnibus que básicamente ejecuta el script install.sh si chef no está instalado.

 8
Author: StephenKing,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-22 06:49:36