Reputation: 23
I am pretty new to Chef. I wanted to install Java on my Chef Nodes through recipes. This is what I tried:
default.rb looks like this:
root@user:/chef-repo/cookbooks/java/recipes#cat default.rb
#
# Cookbook Name:: java
# Recipe:: default
#
# Copyright 2016, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
include_recipe "java"
metadata.rb looks like this:
root@user:~/chef-repo/cookbooks/java# cat metadata.rb
name 'java'
maintainer 'YOUR_COMPANY_NAME'
maintainer_email 'YOUR_EMAIL'
license 'All rights reserved'
description 'Installs/Configures java'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends "java", "~> 1.39.0"
And then I upload this cookbook by the following command:
root@user:~/chef-repo/cookbooks/java/recipes# knife cookbook upload java
WARN: Ignoring self-dependency in cookbook java, please remove it (in the future this will be fatal).
Uploading java [0.1.0]
Uploaded 1 cookbook.
Then I log into my Chef-client node and execute this recipe:
root@client:/usr/share/java# sudo chef-client
Starting Chef Client, version 12.11.18
resolving cookbooks for run list: ["java"]
Synchronizing Cookbooks:
- java (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 0 resources
Running handlers:
Running handlers complete
Chef Client finished, 0/0 resources updated in 02 seconds
It looks like this has not installed anything. I try and check java version and I get nothing.
root@client:~# java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.8-jre-headless
* openjdk-7-jre-headless
* gcj-4.6-jre-headless
* openjdk-6-jre-headless
Try: apt-get install <selected package>
Can someone please let me know what am I missing here?
Upvotes: 0
Views: 1787
Reputation: 54267
To be a bit more specific than the other answers: you need to rename your wrapper cookbook something like mycompany-java
.
Upvotes: 0
Reputation: 78021
You have created a cookbook called "java" that depends on another cookbook called "java". I suspect what you're trying to do is consume the community "java" cookbook:
I highly recommend you install Chefdk locally and start using tools like test kitchen to test your cookbook locally and Berkshelf to manage the upload of your cookbook and all its dependencies into your chef server.
The following is an example of installing Java:
Upvotes: 3