2012-03-28 8 views
1

Ich bin frisches Fleisch mit Koch. Ich benutze Koch, um eine ec2-Instanz zu verwalten und scheint zu arbeiten. Wenn ich mich in der Box anmelde, führe ich Folgendes aus, damit ich sehen kann, was passiert.Chef-Kunde hält Neuinstallation Rezept

Ich bemerke, dass meine Installation für Pytimer immer wieder installiert wird. Wie ändere ich das Rezept, um sicherzustellen, dass es nur einmal installiert wird, wenn das Rezept nicht geändert wird?

[Thu, 29 Mar 2012 00:28:01 +0000] INFO: Processing easy_install_package[hash_ring] action install (nginx_base::default line 107) 
[Thu, 29 Mar 2012 00:28:02 +0000] INFO: Processing bash[compile_proto_source_source] action run (PyTimer::default line 8) 
[Thu, 29 Mar 2012 00:28:02 +0000] INFO: bash[compile_proto_source_source] sh("bash" "/tmp/chef-script20120329-23998-1te88gz-0") 
timeout-0.1.2/ 
timeout-0.1.2/PKG-INFO 
timeout-0.1.2/setup.py 
timeout-0.1.2/timeout.py 
running install 
running build 
running build_py 
copying timeout.py -> build/lib.linux-x86_64-2.7 
running install_lib 
copying build/lib.linux-x86_64-2.7/timeout.py -> /usr/local/lib/python2.7/dist-packages 
byte-compiling /usr/local/lib/python2.7/dist-packages/timeout.py to timeout.pyc 
running install_egg_info 
Removing /usr/local/lib/python2.7/dist-packages/timeout-0.1.2.egg-info 
Writing /usr/local/lib/python2.7/dist-packages/timeout-0.1.2.egg-info 




version = node[:PyTimer][:version] 

remote_file "#{Chef::Config[:file_cache_path]}/timeout-#{version}.tar.gz" do 
    source "http://pypi.python.org/packages/source/t/timeout/timeout-#{version}.tar.gz" 
    #action :create_if_missing 
end 

bash "compile_proto_source_source" do 
    cwd Chef::Config[:file_cache_path] 
    code <<-EOH 
    tar -xvf timeout-#{version}.tar.gz 
    cd timeout-#{version} 
    sed 's/signal.alarm(self.timeout)/signal.setitimer(signal.ITIMER_REAL,self.timeout)/g' -i timeout.py 
    python setup install 
    EOH 
end 

Antwort

1

Verwenden Sie einen only_if oder not_if Zustand (die entweder Shell-Skripten oder beliebige Blöcke von Ruby-Code sein können), um den Fall zu identifizieren, wo die Arbeit durch das Skript getan wird bereits erreicht. Sie können auch veranlassen, dass Ihr Skript bei erfolgreicher Ausführung eine Datei erstellt und das creates-Argument für exec nur dann verwendet, wenn diese Datei nicht vorhanden ist.

Alle diese in der documentation for the exec resource abgedeckt.

Verwandte Themen