Where can I find the deployed cookbook version? It seems that the automatic attributes do not listen the versions.
Is there a way to access the cookbook_version somewhere in a recipe or template?
If you can ssh into the box you can look under /var/chef/cache/cookbooks/<cookbook name>/metadata. json to find the version. Also, you can access it during a chef run by looking at @run_context.
On the stack's page, click Run Command and select the Update Custom Cookbooks command. Add a comment if desired. Optionally, specify a custom JSON object for the command to add custom attributes to the stack configuration and deployment attributes that AWS OpsWorks Stacks installs on the instances.
Step 1 − Install the cookbook using the following command. Step 2 − Run the knife cookbook test commands on the working cookbook. Step 3 − Break something in the cookbook and test again. Step 4 − Run the knife test command again.
You have to access the cookbook collection that the Chef run knows about.
run_context.cookbook_collection[cookbook_name].metadata.version
The run context is an object that tracks the context of the Chef run.
The cookbook_collection method returns a hash-like object of all the cookbooks that Chef has in the local cache.
The cookbook_name method returns the name of "this" cookbook, so it looks up the cookbook in the collection. The collection has all the metadata in the cookbooks, which can be selected via accessors. In this case since you want "version", use the "version" accessor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With