The Chef version properties will only work if you install Chef directly from the Chef gems. Support or versions when using omnibus was added in the latest snapshot so it is not available in 1.7.3.
You can instruct jclouds to install Chef directly from the Chef gems by configuring the Chef properties mentioned here (look at the end, in the "Customize how Chef is installed" section): http://jclouds.apache.org/guides/chef You can start trying with the following properties, and play with the rest (such as the ruby version, and the update gem system ones) if these properties alone don't work. overrides.setProperty(ChefProperties.USE_OMNIBUS, "false"); overrides.setProperty(ChefProperties.CHEF_VERSION, "11.16.4"); On 9 February 2015 at 13:21, Subhadip Bagui <i.ba...@gmail.com> wrote: > Hi Ignasi, > > Changing the JClouds version will be difficult for me as the code is there > in production. I will check with changing the chef version properties and > let u know. > > > Regards, > Subhadip > > ------------------------------------------------------------------------------------------------------------------- > > On Mon, Feb 9, 2015 at 4:22 PM, Ignasi Barrera <n...@apache.org> wrote: > >> The configuration seems correct. Can you try using version >> 2.0.0-SNAPSHOT and set the chef version I suggested, and see if it >> works? Just to isolate the issue and see if it is actually a package >> version. >> >> On 9 February 2015 at 11:43, Subhadip Bagui <i.ba...@gmail.com> wrote: >> > Hi Ignasi, >> > >> > Thanks for your reply. >> > >> > I'm using jclouds version 1.7.3 and I'm not setting any chef version in >> > code. Default it's taking that opscode-omnibus chef. >> > I have cleaned the /var/chef dir and tried but getting the same issue. >> > >> > Here is my code for ChefService creation. Please let me know what needs >> to >> > be done. >> > >> > `private ChefService initChefServiceAWS(String client, String validator) >> { >> > ChefContext context = null; >> > try { >> > >> > String organization = "chef"; >> > String pemFile = MessageTranslator.getMessage("user.home") >> > + "/.chef/" + client + ".pem"; >> > String credential = Files.toString(new File(pemFile), >> > Charsets.UTF_8); >> > >> > // Provide the validator information to let the nodes to >> > // auto-register themselves >> > // in the Chef server during bootstrap >> > String validatorPemFile = MessageTranslator.getMessage("user.home") >> > + "/.chef/" + validator + ".pem"; >> > String validatorCredential = Files.toString(new File( >> > validatorPemFile), Charsets.UTF_8); >> > >> > Properties chefConfig = new Properties(); >> > chefConfig.put(ChefProperties.CHEF_VALIDATOR_NAME, validator); >> > chefConfig.put(ChefProperties.CHEF_VALIDATOR_CREDENTIAL, >> > validatorCredential); >> > >> > ContextBuilder builder = ContextBuilder >> > .newBuilder(organization) >> > .credentials(client, credential) >> > .overrides(chefConfig); >> > >> > LOG.debug(" initializing Chef Service " + builder.getApiMetadata()); >> > >> > context = builder.buildView(ChefContext.class); >> > >> > } catch (Exception e) { >> > LOG.warn("error reading private key ", e); >> > return null; >> > } >> > return context.getChefService(); >> > }` >> > >> > Regards, >> > Subhadip >> > >> ------------------------------------------------------------------------------------------------------------------- >> > >> > On Mon, Feb 9, 2015 at 1:53 PM, Ignasi Barrera <n...@apache.org> wrote: >> > >> >> Could you also share the code you use to create the ChefContext? Just >> >> to make sure the credentials and validator certificates are properly >> >> configured. Thanks! >> >> >> >> On 9 February 2015 at 09:18, Ignasi Barrera <ignasi.barr...@gmail.com> >> >> wrote: >> >> > It seems to be failing to install the Chef RPM (and that would be an >> >> > issue with the Chef package itself). To debug what is going on, you >> >> > can: >> >> > >> >> > * Log in to the node after the script execution failure. >> >> > * Remove the "/etc/chef" directory, to cleanup everything jclouds has >> >> > created there. >> >> > * In the user's home directory you'll find a symlink pointing to the >> >> > bootstrap script. >> >> > * That bootstrap script leaves the stdout and stderr outputs in >> >> > "/tmp". You can read them and see if you find more details about the >> >> > error. >> >> > * Or you can manually run the script and see if you can see more >> details. >> >> > >> >> > jclouds by default installs Chef using the Omnibus installer and >> >> > installs the latest version of Chef. You can also try to force a >> >> > concrete version of the Chef Client to be installed. To do that: >> >> > >> >> > * You must use jclouds 2.0.0-SNAPSHOT version (there is not a release >> >> > with the version support when using Omnibus). >> >> > * Create the ChefContext adding the following property (this is a >> >> > version of the Chef client I've tested recently): >> >> > overrides.setProperty(ChefProperties.CHEF_VERSION, "11.16.4-1"); >> >> > >> >> > >> >> > HTH! >> >> > >> >> > I. >> >> > >> >> > On 8 February 2015 at 19:07, Subhadip Bagui <i.ba...@gmail.com> >> wrote: >> >> >> Hi, >> >> >> >> >> >> I'm trying to bootstrap one predefined recipe as runlist through >> JClouds >> >> >> boot strap. The issue I'm facing is the authentication and >> >> chef-validator >> >> >> pem file all the generating correctly in ec2 node, but it's failing >> to >> >> >> create the client.pem in the new node. For that the recipe is not >> able >> >> to >> >> >> run. Below is my code part following the example from link >> >> >> >> >> >> https://github.com/jclouds/jclouds-examples/blob/master/chef-basics/src/main/java/org/apache/jclouds/examples/chef/basics/MainApp.java >> >> >> >> >> >> Please let me know the whats the issue here. >> >> >> >> >> >> >> >> >> private String createBootstrapAWS(String userName, String password, >> >> >>> InstanceBean instance, ComputeService computeService) >> >> >>> throws IOException { >> >> >>> String status = Constants.SUCCESS; >> >> >>> List<String> runlist = new ArrayList<String>(); >> >> >>> String recipe = INITIAL_UPDATE_VM; >> >> >>> // initialising chef >> >> >>> ChefContext chefContext = AriServiceConfiguration >> >> >>> .chefServerConfigurationCloudWise(instance); >> >> >>> Iterable<? extends CookbookVersion> cookbookVersions = chefContext >> >> >>> .getChefService().listCookbookVersions(); >> >> >>> if (any(cookbookVersions, containsRecipe(recipe))) { >> >> >>> runlist = new RunListBuilder().addRecipe(recipe).build(); >> >> >>> } >> >> >>> if (instance.isAutoDeploy()) { >> >> >>> runlist = new RunListBuilder().addRecipes( >> >> >>> instance.getRecipes().toArray( >> >> >>> new String[instance.getRecipes().size()])).build(); >> >> >>> } >> >> >>> LoginCredentials login = getLoginForCommandExecution(userName, >> >> >>> password, instance.getCloudType()); >> >> >>> LOG.info("got the login as :" + login); >> >> >>> ChefService chefService = initChefServiceAWS( >> >> >>> MessageTranslator.getMessage("chef.client"), >> >> >>> MessageTranslator.getMessage("chef.validator")); >> >> >>> BootstrapConfig build = null; >> >> >>> try { >> >> >>> build = BootstrapConfig.builder().runList(runlist).build(); >> >> >>> chefService.updateBootstrapConfigForGroup(instance.getGroupName(), >> >> >>> build); >> >> >>> // Build the script that will bootstrap the node >> >> >>> Statement bootstrap = chefService >> >> >>> .createBootstrapScriptForGroup(instance.getGroupName()); >> >> >>> LOG.info("bootstrap created..."); >> >> >>> LOG.debug("Running run script"); >> >> >>> status = runScriptOnGroup(computeService, login, instance, >> >> >>> bootstrap); >> >> >>> } catch (Exception e) { >> >> >>> LOG.warn("error thrown for bootstrap.." + e.getMessage()); >> >> >>> return "failure"; >> >> >>> } finally { >> >> >>> chefContext.close(); >> >> >>> } >> >> >>> return status; >> >> >>> } >> >> >> >> >> >> >> >> >> >> >> >> The response I'm getting from JClouds for ExecResponse is below. >> It's >> >> not >> >> >> creating the client.pem. Please let me know what is the issue here. >> >> >> >> >> >> ExecResponse execResponses1 = compute.runScriptOnNode( >> >> >>> instance.getInstanceId(), command, >> >> >>> overrideLoginCredentials(login).runAsRoot(true)); >> >> >> >> >> >> >> >> >> {output=Downloading Chef for el... >> >> >> downloading >> >> >> >> >> >> https://www.opscode.com/chef/metadata?v=&prerelease=false&nightlies=false&p=el&pv=6&m=x86_64 >> >> >> to file /tmp/install.sh.2830/metadata.txt >> >> >> trying wget... >> >> >> url >> >> >> >> >> >> https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-12.0.3-1.x86_64.rpm >> >> >> md5 3634d1a3b6ae2e5977361075da0f44cc >> >> >> sha256 >> 0ec6162b9d0ca2b2016ff02781d84905f712d64c7a81d01b0df88f977832f310 >> >> >> downloaded metadata file looks valid... >> >> >> downloading >> >> >> >> >> >> https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-12.0.3-1.x86_64.rpm >> >> >> to file /tmp/install.sh.2830/chef-12.0.3-1.x86_64.rpm >> >> >> trying wget... >> >> >> Comparing checksum with sha256sum... >> >> >> Installing Chef >> >> >> installing with rpm... >> >> >> Preparing... >> >> >> ################################################## >> >> >> chef >> >> >> ################################################## >> >> >> Thank you for installing Chef! >> >> >> [2015-02-08T17:41:25+00:00] INFO: Forking chef instance to >> converge... >> >> >> [2015-02-08T17:41:25+00:00] INFO: *** Chef 12.0.3 *** >> >> >> [2015-02-08T17:41:25+00:00] INFO: Chef-client pid: 7023 >> >> >> [2015-02-08T17:41:28+00:00] INFO:* Client key /etc/chef/client.pem is >> >> not >> >> >> present - registering* >> >> >> *, error=warning: /tmp/install.sh.2830/chef-12.0.3-1.x86_64.rpm: >> Header >> >> V4 >> >> >> DSA/SHA1 Signature, key ID 83ef826a: NOKEY* >> >> >> *, exitStatus=1}* >> >> >> >> >> >> >> >> >> Regards, >> >> >> Subhadip >> >> >> >> >> >> >> >> >> ------------------------------------------------------------------------------------------------------------------- >> >> >>