Search code examples
javarubymavenchef-infracookbook

How configure cookbook maven in chef node?


The source for question can be easy found this question. So I run knife cookbook site install maven and then knife cookbook upload myCookbook --include-dependencie

But after run

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]'

I got

No such file or directory - mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DgroupId=org.springframework -DartifactId=spring-context -Dversion=4.0.4.RELEASE -Dpackaging=jar  -Ddest=/tmp/chef_maven_lwrp20141212-27453-ocmoxb/spring-context-4.0.4.RELEASE.jar -DremoteRepositories=http://repo.maven.apache.org/maven2/ -Dtransitive=false

It turns out that maven simply not installed on 192.168.1.37. How can I install maven before run maven cookbook?

P.S.

It is very strange that cookbook does not test itself whether maven is installed or not.


Solution

  • Having a depends 'maven' in the metadata.rb file won't do anything more than load the cookbook.

    You'll have to include the recipe too in your cookbook recipe.

    Something like include_recipe 'maven' at top of your myCookbook default recipe should do.