简体   繁体   中英

installing java using chef solo on ec2

I am trying my first recipe with chef-solo - a simple recipe that is trying to install java before doing anything. I want to install Oracle version of java, but I have come across multiple failure messages. How do I fix this? Here's my configuration -

 sudo chef-solo -c solo.rb -j web.json

My solo.rb looks like this

cookbook_path "/home/ubuntu/chef-repo/cookbooks"

and web.json

{
    "java": {
        "jdk_version": "7",
        "java_home": "opt/java",
        "oracle" : {
            "accept_oracle_download_terms": true
        }
    },
    "run_list" :  [ "recipe[testapp]" ]
}

My testapp recipe default.rb

include_recipe "java::default"

I've specified java as dependency in metadata.rb. This is what I get when I run the above on a fresh ec2 node.

Starting Chef Client, version 11.8.2
Compiling Cookbooks...
[2015-05-08T20:50:41+00:00] WARN: Using java::default instead is recommended.
Converging 7 resources
Recipe: java::openjdk
  * package[openjdk-7-jdk] action install
================================================================================
Error executing action `install` on resource 'package[openjdk-7-jdk]'
================================================================================


Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '100'
---- Begin output of apt-get -q -y install openjdk-7-jdk=7u79-2.5.5-0ubuntu0.14.04.2 ----
STDOUT:
STDERR: E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
---- End output of apt-get -q -y install openjdk-7-jdk=7u79-2.5.5-0ubuntu0.14.04.2 ----
Ran apt-get -q -y install openjdk-7-jdk=7u79-2.5.5-0ubuntu0.14.04.2 returned 100


Resource Declaration:
---------------------
# In /home/ubuntu/chef-repo/cookbooks/java/recipes/openjdk.rb

 46:   package pkg do
 47:     version node['java']['openjdk_version'] if node['java']['openjdk_version']
 48:   end
 49: end



Compiled Resource:
------------------
# Declared in /home/ubuntu/chef-repo/cookbooks/java/recipes/openjdk.rb:46:in `block in from_file'

package("openjdk-7-jdk") do
  action :install
  retries 0
  retry_delay 2
  package_name "openjdk-7-jdk"
  version "7u79-2.5.5-0ubuntu0.14.04.2"
  cookbook_name :java
  recipe_name "openjdk"
end



[2015-05-08T20:50:41+00:00] ERROR: Running exception handlers
[2015-05-08T20:50:41+00:00] ERROR: Exception handlers complete
[2015-05-08T20:50:41+00:00] FATAL: Stacktrace dumped to /home/ubuntu/chef-solo/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2015-05-08T20:50:41+00:00] ERROR: package[openjdk-7-jdk] (java::openjdk line 46) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '100'
---- Begin output of apt-get -q -y install openjdk-7-jdk=7u79-2.5.5-0ubuntu0.14.04.2 ----
STDOUT:
STDERR: E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
---- End output of apt-get -q -y install openjdk-7-jdk=7u79-2.5.5-0ubuntu0.14.04.2 ----
Ran apt-get -q -y install openjdk-7-jdk=7u79-2.5.5-0ubuntu0.14.04.2 returned 100
[2015-05-08T20:50:41+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

sudo dpkg --configure -a做到了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM