كتاب الطبخ المتشرد والشيف سولو وجافا:حدث خطأ أثناء تنفيذ الإجراء "التثبيت" على المورد "java_ark[jdk]"

StackOverflow https://stackoverflow.com//questions/21016295

  •  21-12-2019
  •  | 
  •  

سؤال

لقد قمت بإعداد مربع Vagrant بدقة 64 وأحاول تثبيت Oracle Java 7 باستخدام كتاب Java Cookbook (http://community.opscode.com/cookbooks/java) ولكني أتلقى خطأ:

Error executing action `install` on resource 'java_ark[jdk]'

انا اجري متشرد يصل واحصل على الإخراج التالي في المحطة الطرفية:

Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 80 => 8080 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
prevent things such as shared folders from working properly. If you see
shared folder errors, please make sure the guest additions within the
virtual machine match the version of VirtualBox you have installed on
your host and reload your VM.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.3
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /tmp/vagrant-chef-1/chef-solo-2/roles
[default] -- /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
stdin: is not a tty
[2014-01-09T09:25:53+00:00] INFO: *** Chef 10.14.2 ***
[2014-01-09T09:25:55+00:00] INFO: Setting the run_list to ["role[myrecipes]"] from JSON
[2014-01-09T09:25:55+00:00] INFO: Run List is [role[myrecipes]]
[2014-01-09T09:25:55+00:00] INFO: Run List expands to [java]
[2014-01-09T09:25:55+00:00] INFO: Starting Chef Run for precise64
[2014-01-09T09:25:55+00:00] INFO: Running start handlers
[2014-01-09T09:25:55+00:00] INFO: Start handlers complete.
[2014-01-09T09:25:56+00:00] INFO: ruby_block[set-env-java-home] called
[2014-01-09T09:25:56+00:00] INFO: file[/etc/profile.d/jdk.sh] mode changed to 755
[2014-01-09T09:25:56+00:00] INFO: file[/etc/profile.d/jdk.sh] created file /etc/profile.d/jdk.sh
[2014-01-09T09:25:56+00:00] INFO: Adding jdk to /usr/lib/jvm/jdk1.7.0_45

================================================================================
Error executing action `install` on resource 'java_ark[jdk]'
================================================================================

NoMethodError
-------------
undefined method `headers' for Chef::Resource::RemoteFile

Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/java/providers/ark.rb:70:in `download_direct_from_oracle'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/java/providers/ark.rb:67:in `download_direct_from_oracle'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/java/providers/ark.rb:108:in `class_from_file'

Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/java/recipes/oracle.rb

 46: 
 47: java_ark "jdk" do
 48:   url tarball_url
 49:   checksum tarball_checksum
 50:   app_home java_home
 51:   bin_cmds bin_cmds
 52:   alternatives_priority 1062
 53:   action :install
 54: end
 55: 

Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/java/recipes/oracle.rb:47:in `from_file'

java_ark("jdk") do
  app_home "/usr/lib/jvm/java-7-oracle-amd64"
  checksum "bea330fcbcff77d31878f21753e09b30"
  retry_delay 2
  owner "root"
  default true
  url "http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz"
  retries 0
  alternatives_priority 1062
  recipe_name "oracle"
  action [:install]
  bin_cmds ["appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac", "javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb", "jhat", "jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm", "keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry", "schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc"]
  cookbook_name :java
  supports {:exception=>true, :report=>true}
end

[2014-01-09T09:25:56+00:00] ERROR: Running exception handlers
[2014-01-09T09:25:56+00:00] ERROR: Exception handlers complete
[2014-01-09T09:25:56+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-01-09T09:25:56+00:00] FATAL: NoMethodError: java_ark[jdk] (java::oracle line 47) had an error: NoMethodError: undefined method `headers' for Chef::Resource::RemoteFile
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

ملف المتشرد الخاص بي

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"

  config.vm.network :forwarded_port, guest: 80, host: 8080

  # Chef-solo
  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = ["site-cookbooks", "cookbooks"]
    chef.roles_path = "roles"
    chef.add_role "myrecipes"
  end

end

الأدوار/myrecipes.rb

name "myrecipes"

default_attributes(
    "java" => {
        "install_flavor" => "oracle",
        "jdk_version" => 7,
        "oracle" => {
                "accept_oracle_download_terms" => true
        }
    }
)

run_list(
    "recipe[apt]",
    "recipe[openssl]",
    "recipe[java]"
)
هل كانت مفيدة؟

المحلول

أعتقد أن المشكلة تكمن في عدم التطابق بين إصدار الشيف الذي تستخدمه (10.14.2) وإصدار java كتاب الطبخ.

تنفيذ java_ark يحاول موفر الموارد في كتاب الطبخ استخدام ملف header طريقة الشيف remote_file المورد عند تنزيل برنامج تثبيت Oracle.المشكلة هي أن header تم تطبيق الطريقة فقط على remote_file المصدر في Chef 11.6.0 (من خلال قراءتي لكود مصدر الشيف على Github).

الحل هو إما الترقية إلى أحدث إصدار من Chef، أو استخدام إصدار أقدم من java كتاب الطبخ الذي يعمل مع الشيف 10.x.(ربما تكون الأخيرة فكرة سيئة ...إلا إذا كنت مستعدًا لتعيين أحدث عنوان URL لتنزيل Oracle يدويًا والمجموع الاختباري في السمات ذات الصلة ...)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top