Szef kuchni: dlaczego zasoby w kroku "Dołącz przepis" są pomijane?

Chef wydaje się przetwarzać zasoby w dziwnej kolejności, co powoduje, że moja konstrukcja zawodzi. Mój główny przepis (mytardis-chef/site-cookbooks/recipes/default.rb) zaczyna się tak:

include_recipe "build-essential"
include_recipe "mytardis::deps"
include_recipe "mytardis::nginx"
include_recipe "mytardis::postgresql"

mytardis-chef/cookbooks/build-essential/recipes/default.rb wygląda tak:

case node['platform']
when "ubuntu","debian"
  %w{build-essential binutils-doc}.each do |pkg|
    package pkg do
      action :install
    end
  end
when "centos","redhat","fedora","scientific"
  %w{gcc gcc-c++ kernel-devel make}.each do |pkg|
    package pkg do
      action :install
    end
  end
end

... (to starsza wersja https://github.com/opscode-cookbooks/build-essential/blob/master/recipes/default.rb)

W czasie wykonywania, z powodów, których nie rozumiem, ten przepis build-essential jest ładowany, ale nie wykonywany:

[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- v-root: /vagrant
[default] -- v-csr-3: /tmp/vagrant-chef-1/chef-solo-3/roles
[default] -- v-csc-2: /tmp/vagrant-chef-1/chef-solo-2/cookbooks
[default] -- v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] -- v-csdb-4: /tmp/vagrant-chef-1/chef-solo-4/data_bags
[default] Running provisioner: Vagrant::Provisioners::ChefSolo...
[default] Generating chef JSON and uploading...
[default] Running chef-solo...
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: *** Chef 10.12.0 ***
[Sun, 08 Jul 2012 05:14:32 +0200] DEBUG: Building node object for lucid32
[Sun, 08 Jul 2012 05:14:32 +0200] DEBUG: Extracting run list from JSON attributes provided on command line
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Setting the run_list to ["recipe[mytardis]"] from JSON
[Sun, 08 Jul 2012 05:14:32 +0200] DEBUG: Applying attributes from json file
[Sun, 08 Jul 2012 05:14:32 +0200] DEBUG: Platform is ubuntu version 10.04
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Run List is [recipe[mytardis]]
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Run List expands to [mytardis]
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Starting Chef Run for lucid32
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Running start handlers
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Start handlers complete.
...
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe mytardis via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe default in cookbook mytardis
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe build-essential via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe default in cookbook build-essential
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe mytardis::deps via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe deps in cookbook mytardis
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe mytardis::nginx via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe nginx in cookbook mytardis
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe iptables via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe default in cookbook iptables
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe mytardis::postgresql via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe postgresql in cookbook mytardis
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe postgresql::server via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe server in cookbook postgresql
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe postgresql::client via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe client in cookbook postgresql
[Sun, 08 Jul 2012 05:14:33 +0200] INFO: Processing package[postgresql-client] action install (postgresql::client line 37)
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: package[postgresql-client] checking package status for postgresql-client
....
[Sun, 08 Jul 2012 05:14:45 +0200] ERROR: gem_package[pg] (postgresql::client line 42) has had an error
.
make
sh: make: not found

Oznacza to, że przepis niezbędny do budowania jest "znaleziony" i "załadowany", ale to przepis postgres jest najpierw "przetworzony". I od build-essential (który instaluje kompilator C) nie został uruchomiony, ten drugi nie działa.

Odpowiednia część mojego Vagrantfile wygląda tak:

  config.vm.provision :chef_solo do |chef|
     chef.log_level = :debug
     chef.cookbooks_path = ["mytardis-chef/site-cookbooks", "mytardis-chef/cookbooks"]
     chef.roles_path = "mytardis-chef/roles"
     chef.data_bags_path = "mytardis-chef/data_bags"
     chef.add_recipe "mytardis"    
  end

Używałem wcześniej nieco wcześniejszej wersji Chef (może 10.10.0?) W tej wersji build-essential również nie był uruchamiany, ale mytardis::deps był. Teraz używam Chef 10.12.0. Fizyczna maszyna to OSX, VM to Ubuntu Lucid.

Więc kilka pytań:

  1. dlaczego build-essential nie jest "przetworzony"?
  2. jaki jest właściwy sposób, aby to zrobić? (Nie napisałem tych przepisów, i rozumiem, że mają lub pracowały dla ich autora.)
  3. czy strona-książki kucharskie i książki kucharskie "cieniowanie" funkcja nadal działa? Jest podobno przestarzały: http://tickets.opscode.com/browse/CHEF-2308 (próbowałem zrobić link symboliczny pod ze strony-książki kucharskie / mytardis/przepisy / build-niezbędne, ale bez radości).
Author: Steve Bennett, 2012-07-08

2 answers

Okazuje się, że jest to dość normalna (ale niedostatecznie udokumentowana) część tego, jak działa Chef: kompiluje wszystko, a potem zaczyna działać. Z wyjątkiem niektórych przepisów (takich jak Postgres) przeskakuje kolejkę, aby faktycznie zainstalować w czasie kompilacji, używając kodu takiego jak:

  action :nothing
end.run_action(:run)

Rozwiązaniem jest to, że wszystko, co musi działać przed Postgresem, również musi to zrobić. Na szczęście nowsze wersje Build-essentials na to pozwalają. Można ustawić atrybuty na roli w następujący sposób:

name "myapp"
run_list(
  "recipe[build-essential]",
  "recipe[myapp]"
)
default_attributes(
  "build_essential" => {
    "compiletime" => true
  }
)
 40
Author: Steve Bennett,
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
2012-10-18 02:11:59

Jeśli piszesz książkę kucharską, Dodaj atrybut do pliku atrybutów:

node.default['build_essential']['compiletime'] = true

Dzięki Colin wyżej.

 6
Author: toobulkeh,
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
2013-05-03 20:44:22