我对厨师来说有点新鲜,并且已经接受了教程,但我开始认为我不是那个有错误的人:
我正在尝试在CentOS 7.2上安装Java。它无法安装(显然) - 但是在正确的位置提取tarball,但添加了一个非常不准确(我认为)的符号链接,并且没有正确设置模式。
这是我的LWRP:
#
# Cookbook Name:: install_java
# Recipe:: default
#
# Copyright (c) 2016 The Authors, All Rights Reserved.
# Used to define which OS to install and thus, which installer to use
op_sys = node['os']
# Used to get the required java update from the environment file
java_ver_update = node['java_ver']
# Logic for each OS
if op_sys == 'linux'
# Java_ark, which is used to define the correct install attributes for each OS type (win/linux)
java_ark "jdk" do
url 'http://sv-dc01.sv.local/install_artifacts/java/oracle/JRE/jre-'+"#{java_ver_update}"+'-linux-x64.tar.gz'
app_home '/applications/JAVA/SomePath'
owner 'root'
group 'wheel'
app_home_mode 774
bin_cmds ['java', 'javaws', 'jcontrol', 'jjs', 'keytool', 'orbd', 'pack200', 'policytool', 'rmid', 'rmiregistry', 'servertool', 'tnameserv', 'unpack200']
action :install
end
# Same again but the logic for winows install
elsif op_sys == 'windows'
java_ark "jdk" do
url 'http://sv-dc01.sv.local/install_artifacts/java/oracle/JRE/jre-'+"#{java_ver_update}"+'-windows-x64.tar.gz'
action :install
end
end
include_recipe 'java'
现在,我还在环境文件中定义了一些默认值
name 'env_workstation'
description "Environment Workstation Dubbo"
cookbook_versions({
"ohai" => "> 0.0.1",
"java" => "> 0.1.0",
"install_java" => "> 0.0.1"
})
$environment = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }
$override = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }
$override['java']['jdk_version'] = '8'
$override['java']['install_flavor'] = 'oracle'
$override['java_ver'] = '8u77'
default_attributes(Chef::Mixin::DeepMerge.merge($_default_environment, $environment))
override_attributes($override)
但是即使将tarball提取到正确的位置,运行也会失败,但是我最后在一个奇怪的位置找到了一个符号链接,这个位置以我的java_ark' / applications / JAVA'的最终文件夹命名。 (所以JAVA)。
这是运行失败:
Starting Chef Client, version 12.16.42
resolving cookbooks for run list: ["install_java"]
Synchronizing Cookbooks:
- install_java (0.1.0)
- java (1.42.0)
- windows (2.1.1)
- ohai (4.2.2)
- compat_resource (12.16.2)
- homebrew (2.1.2)
- build-essential (7.0.2)
- seven_zip (2.0.2)
- mingw (1.2.4)
- ark (2.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 7 resources
Recipe: install_java::default
* java_ark[jdk] action install
- create dir /applications/JAVA and change owner to root:wheel
* remote_file[/var/chef/cache/jre-8u77-linux-x64.tar.gz] action create_if_missing
- create new file /var/chef/cache/jre-8u77-linux-x64.tar.gz
- update content in file /var/chef/cache/jre-8u77-linux-x64.tar.gz from none to edd9db
(file sizes exceed 10000000 bytes, diff output suppressed)
- change mode from '' to '0755'
- restore selinux security context
- extract compressed data into Chef file cache path and
move extracted data to /applications/JAVA/jre1.8.0_77
- Symlink /applications/JAVA/jre1.8.0_77 to /applications/JAVA/SomePath
Recipe: java::notify
* log[jdk-version-changed] action write
* remote_file[/var/chef/cache/jre-8u77-linux-x64.tar.gz] action nothing (skipped due to action :nothing)
* java_alternatives[set-java-alternatives] action set
- Add alternative for java
- Add alternative for javaws
- Add alternative for jcontrol
- Add alternative for jjs
- Add alternative for keytool
- Add alternative for orbd
- Add alternative for pack200
- Add alternative for policytool
- Add alternative for rmid
- Add alternative for rmiregistry
- Add alternative for servertool
- Add alternative for tnameserv
- Add alternative for unpack200
* log[jdk-version-changed] action nothing (skipped due to action :nothing)
Recipe: java::set_java_home
* ruby_block[set-env-java-home] action run
- execute the ruby block set-env-java-home
* directory[/etc/profile.d] action create (up to date)
* template[/etc/profile.d/jdk.sh] action create
- create new file /etc/profile.d/jdk.sh
- update content in file /etc/profile.d/jdk.sh from none to 5b75c4
--- /etc/profile.d/jdk.sh 2016-12-06 17:01:08.234396652 +1300
+++ /etc/profile.d/.chef-jdk20161206-4077-1pw7fk4.sh 2016-12-06 17:01:08.234396652 +1300
@@ -1 +1,2 @@
+export JAVA_HOME=/usr/lib/jvm/java
- change mode from '' to '0755'
- restore selinux security context
Recipe: java::oracle
* yum_package[tar] action install (up to date)
* java_ark[jdk] action install
- create dir /usr/lib/jvm and change owner to root:wheel[2016-12-06T17:01:22+13:00] FATAL: You must set the attribute node['java']['oracle']['accept_oracle_download_terms'] to true if you want
to download directly from the oracle site!
================================================================================
Error executing action `install` on resource 'java_ark[jdk]'
================================================================================
SystemExit
----------
exit
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/java/providers/ark.rb:86:in `download_direct_from_oracle'
/var/chef/cache/cookbooks/java/providers/ark.rb:125:in `block in class_from_file'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/java/recipes/oracle.rb
59: java_ark 'jdk' do
60: url tarball_url
61: default node['java']['set_default']
62: checksum tarball_checksum
63: app_home java_home
64: bin_cmds bin_cmds
65: alternatives_priority node['java']['alternatives_priority']
66: retries node['java']['ark_retries']
67: retry_delay node['java']['ark_retry_delay']
68: connect_timeout node['java']['ark_timeout']
69: use_alt_suffix node['java']['use_alt_suffix']
70: reset_alternatives node['java']['reset_alternatives']
71: download_timeout node['java']['ark_download_timeout']
72: action :install
73: notifies :write, 'log[jdk-version-changed]', :immediately
74: end
75:
76: if node['java']['set_default'] && platform_family?('debian')
77: include_recipe 'java::default_java_symlink'
78: end
79:
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/java/recipes/oracle.rb:59:in `from_file'
java_ark("jdk") do
action [:install]
supports {:report=>true, :exception=>true}
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :java_ark
cookbook_name "java"
recipe_name "oracle"
url "http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.tar.gz"
app_home "/usr/lib/jvm/java"
owner "root"
group "wheel"
app_home_mode 774
bin_cmds ["appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac", "javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontro
l", "jdb", "jdeps", "jhat", "jinfo", "jjs", "jmap", "jmc", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm", "keytool", "native2ascii", "orbd", "pack200", "policytool", "r
mic", "rmid", "rmiregistry", "schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc"]
default true
checksum "467f323ba38df2b87311a7818bcbf60fe0feb2139c455dfa0e08ba7ed8581328"
alternatives_priority 1062
connect_timeout 600
use_alt_suffix true
reset_alternatives true
download_timeout 600
end
Platform:
---------
x86_64-linux
Running handlers:
[2016-12-06T17:01:22+13:00] ERROR: Running exception handlers
Running handlers complete
[2016-12-06T17:01:22+13:00] ERROR: Exception handlers complete
Chef Client failed. 6 resources updated in 40 seconds
[2016-12-06T17:01:23+13:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-12-06T17:01:23+13:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-12-06T17:01:23+13:00] ERROR: java_ark[jdk] (java::oracle line 59) had an error: SystemExit: exit
[2016-12-06T17:01:23+13:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
这是堆栈跟踪:
Generated at 2016-12-06 17:01:23 +1300
SystemExit: java_ark[jdk] (java::oracle line 59) had an error: SystemExit: exit
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:367:in `exit'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:367:in `fatal!'
/var/chef/cache/cookbooks/java/providers/ark.rb:86:in `download_direct_from_oracle'
/var/chef/cache/cookbooks/java/providers/ark.rb:125:in `block in class_from_file'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/provider/lwrp_base.rb:86:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/provider/lwrp_base.rb:86:in `block in action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/provider.rb:145:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource.rb:622:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:69:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:97:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:97:in `each'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:97:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:96:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:669:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:664:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:664:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:703:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:283:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:294:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:282:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:282:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:247:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:235:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:450:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:450:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:434:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/bin/chef-client:26:in `<top (required)>'
/bin/chef-client:54:in `load'
/bin/chef-client:54:in `<main>'
>>>> Caused by SystemExit: exit
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:367:in `exit'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:367:in `fatal!'
/var/chef/cache/cookbooks/java/providers/ark.rb:86:in `download_direct_from_oracle'
/var/chef/cache/cookbooks/java/providers/ark.rb:125:in `block in class_from_file'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/provider/lwrp_base.rb:86:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/provider/lwrp_base.rb:86:in `block in action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/provider.rb:145:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource.rb:622:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:69:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:97:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:97:in `each'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:97:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/runner.rb:96:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:669:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:664:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:664:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:703:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/client.rb:283:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:294:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:282:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:282:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:247:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:235:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:450:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:450:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application/client.rb:434:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.16.42/bin/chef-client:26:in `<top (required)>'
/bin/chef-client:54:in `load'
/bin/chef-client:54:in `<main>'[sysadmin@node1 ~]$
答案 0 :(得分:3)
由于您的FATAL
日志消息指示
致命:如果你想直接从oracle网站下载,你必须将属性node ['java'] ['oracle'] ['accept_oracle_download_terms']设置为true!
您必须接受Oracle的Java SE Archive License。要主动表明你这样做,
$override['java']['jdk_version'] = '8'
$override['java']['install_flavor'] = 'oracle'
$override['java_ver'] = '8u77'
$override['java']['oracle']['accept_oracle_download_terms'] = true
您也可以考虑更新到更新版本的Java(如8u111
)。