I have configured workstation up this step in get started (OS redhat 6.5). I have launched a node. I modified a cookbook like that:
myCookbook/metadata.rb
name 'myCookbook'
maintainer 'YOUR_COMPANY_NAME'
maintainer_email 'YOUR_EMAIL'
license 'All rights reserved'
description 'Installs/Configures myCookbook'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'maven'
E.g. only depends 'maven'
string was added after knife cookbook create myCookbook
was executed.
myCookbook/recipes/default.rb
maven 'spring-context' do
group_id 'org.springframework'
version '4.0.4.RELEASE'
dest '/root/chef-repo/'
repositories ['http://repo.maven.apache.org/maven2/']
end
Then I run:
knife cookbook upload myCookbook
Now I am trying:
knife bootstrap 192.168.1.37 --ssh-user root --ssh-password '123456' --sudo --use-sudo-password --node-name node-with-maven-run --run-list 'recipe[myCookbook]'
And get:
ERROR: Cookbook myCookbook depends on cookbooks which are not currently
ERROR: being uploaded and cannot be found on the server.
ERROR: The missing cookbook(s) are: 'maven' version '>= 0.0.0'
How install all cookbook to chef server from that mtCookbook depends?
See here
Or just type knife cookbook upload --help
and it will show you the following line (along others):
--include-dependencies Also upload cookbook dependencies
So knife cookbook upload myCookbook --include-dependencies
is your answer
You'll need to have the maven
cookbook on your workstation too, by knife cookbook site install maven
or any other way to have a directory called maven
in your local cookbook_path
containing a cookbook where the metatada.rb
file as a key name
with value maven
@rastasheep has described how the berkshelf tool is now bundled with the chefdk package.
It's really easy to use and worth learning. It's designed to work like the gem bundler tool.
Example
└── myCookbook
├── Berksfile <-- Berkshelf configuration file
├── Berksfile.lock <-- Lock file generated by Berkshelf
├── metadata.rb
├── README.md
└── recipes
└── default.rb
Berksfile
source "https://supermarket.getchef.com"
metadata
The "source" directive tells berkshelf where to download dependencies from. The "metadata" directive tells berkshelf to take dependencies from the cookbook metadata.
Using Berkshelf
The "install" command will download the cookbook dependencies (Cached under ~/.berkshelf)
$ cd myCookbook
$ berks install
Resolving cookbook dependencies...
Fetching 'myCookbook' from source at .
Fetching cookbook index from https://supermarket.getchef.com...
Installing maven (1.2.0)
Installing 7-zip (1.0.2)
Installing ark (0.9.0)
Installing chef_handler (1.1.6)
Installing java (1.29.0)
Installing windows (1.34.8)
Using myCookbook (0.1.0) from source at .
Berkshelf can also upload all the cookbooks into your chef server
$ berks upload
Uploaded 7-zip (1.0.2) to: 'http://127.0.0.1:8889/'
Uploaded ark (0.9.0) to: 'http://127.0.0.1:8889/'
Uploaded chef_handler (1.1.6) to: 'http://127.0.0.1:8889/'
Uploaded java (1.29.0) to: 'http://127.0.0.1:8889/'
Uploaded maven (1.2.0) to: 'http://127.0.0.1:8889/'
Uploaded myCookbook (0.1.0) to: 'http://127.0.0.1:8889/'
Uploaded windows (1.34.8) to: 'http://127.0.0.1:8889/'
There is a few other options for managing cookbook cookbook and dependencies, such Berkshelf or Librarian-chef, where Berkshelf is more popular, and it's even included in Chef Development Kit, so if you use it you do not need to install it separately.
After defining sources you just need to define which cookbooks you want their versions and cookbook manager will resolve dependencies for all defined cookbooks and it will install them for you, and if you want you can vendor them too. Beside that they have an option to upload specific cookbook, without worrying about upload dependencies.
For more info how to use those tools consult official websites:
- http://berkshelf.com
- https://github.com/applicationsonline/librarian-chef
In general for managing small projects you can use knife's upload flag for uploading dependencies.
-d, --include-dependencies
Use to ensure that when a cookbook has a dependency on one (or more) cookbooks, those cookbooks will also be uploaded.