【发布时间】:2018-08-23 16:15:54
【问题描述】:
我正在尝试使用 Chef Cookbook 在 CentOS 7 上安装 Java JDK 1.8。
我在 Windows 10 上使用 Chef DK,并从 https://downloads.chef.io/chefdk 下载
在我的Berksfile 我已经
source 'https://supermarket.chef.io'
metadata
我的Kitchen.yml是关注
---
driver:
name: vagrant
provisioner:
name: chef_zero
# You may wish to disable always updating cookbooks in CI or other testing environments.
# For example:
# always_update_cookbooks: <%= !ENV['CI'] %>
always_update_cookbooks: true
verifier:
name: inspec
platforms:
- name: centos-7
suites:
- name: default
run_list:
- recipe[test::default]
verifier:
inspec_tests:
- test/integration/default
attributes:
我的metadata.rb是关注
name 'test'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'All Rights Reserved'
description 'Installs/Configures test'
long_description 'Installs/Configures test'
version '0.1.0'
chef_version '>= 12.14' if respond_to?(:chef_version)
depends 'java', '~> 2.2.0'
我的recipes/default.rb
node.default["java"]["install_flavor"] = "oracle"
node.default["java"]["jdk_version"] = "8"
node.default['java']['oracle']['accept_oracle_download_terms'] = true
include_recipe "java"
及其attributes/recipe.rb
default['java']['install_flavor'] = 'oracle'
default['java']['jdk_version'] = '8'
default['java']['oracle']['accept_oracle_download_terms'] = true
当我尝试执行 kitchen converge 时,输出是
-----> Starting Kitchen (v1.22.0)
-----> Converging <default-centos-7>...
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 7.0.4...
Removing non-cookbook files before transfer
Preparing validation.pem
Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to <default-centos-7>
Starting Chef Client, version 14.3.37
resolving cookbooks for run list: ["test::default"]
Synchronizing Cookbooks:
- windows (5.0.0)
- homebrew (5.0.4)
- test (0.1.0)
- java (2.2.0)
Installing Cookbook Gems:
Compiling Cookbooks...
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/test/recipes/default.rb
================================================================================
NoMethodError
-------------
undefined method `java_oracle_install' for cookbook: java, recipe: oracle :Chef::Recipe
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/java/recipes/oracle.rb:40:in `from_file'
/tmp/kitchen/cache/cookbooks/java/recipes/default.rb:22:in `from_file'
/tmp/kitchen/cache/cookbooks/test/recipes/default.rb:8:in `from_file'
Relevant File Content:
----------------------
/tmp/kitchen/cache/cookbooks/java/recipes/oracle.rb:
33: version = node['java']['jdk_version'].to_s
34: tarball_url = node['java']['jdk'][version][arch]['url']
35: tarball_checksum = node['java']['jdk'][version][arch]['checksum']
36: bin_cmds = node['java']['jdk'][version]['bin_cmds']
37:
38: include_recipe 'java::set_java_home'
39:
40>> java_oracle_install 'jdk' do
41: url tarball_url
42: default node['java']['set_default']
43: checksum tarball_checksum
44: app_home java_home
45: bin_cmds bin_cmds
46: alternatives_priority node['java']['alternatives_priority']
47: retries node['java']['ark_retries']
48: retry_delay node['java']['ark_retry_delay']
49: connect_timeout node['java']['ark_timeout']
System Info:
------------
chef_version=14.3.37
platform=centos
platform_version=7.5.1804
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/opt/chef/bin/chef-client
executable=/opt/chef/bin/chef-client
Running handlers:
[2018-08-21T17:23:54+00:00] ERROR: Running exception handlers
[2018-08-21T17:23:54+00:00] ERROR: Running exception handlers
Running handlers complete
[2018-08-21T17:23:54+00:00] ERROR: Exception handlers complete
[2018-08-21T17:23:54+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 04 seconds
[2018-08-21T17:23:54+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2018-08-21T17:23:54+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2018-08-21T17:23:54+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-08-21T17:23:54+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-08-21T17:23:54+00:00] FATAL: NoMethodError: undefined method `java_oracle_install' for cookbook: java, recipe: oracle :Chef::Recipe
[2018-08-21T17:23:54+00:00] FATAL: NoMethodError: undefined method `java_oracle_install' for cookbook: java, recipe: oracle :Chef::Recipe
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Converge failed on instance <default-centos-7>. Please see .kitchen/logs/default-centos-7.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
有什么建议吗?
【问题讨论】:
-
我试图重现您的错误,但没有运气,centos 7.5(我认为它与 centos 7 的图像相同),java cookbook 2.2.0,chef 14.3.37:/ 唯一的区别在我的情况下是新版本的测试厨房(1.23.2)。您是否尝试过不同版本的 chefdk?我在 chefdk 或 test-kitchen 变更日志中没有看到任何特别之处,但我没有想法。
-
我在 Windows 上使用 Chef DK,并且我已经从官方网站下载了它...如何更新我的测试厨房版本?
-
我不确定,我不使用 chefdk。您可以尝试在Chef's slack #chef-dk or #general channel 上提问。
标签: java java-8 chef-infra devops cookbook