I am a starter in Chef and want to use Chef to install different versions of an application on different nodes.
Node 1: ant-1.9.2-9.el7.noarch.rpm
Node 2: ant-1.9.4-2.el7.noarch.rpm
in the recipe, I can write:
package 'ant' do
for Node 1 and change version to '1.9.4' for Node 2 for each knife bootstrap.
In such a way, I have to upload my recipe twice to reach my target.
If 'knife bootstrap' could accept "version" as a json parameter and update the recipe, I would only need to upload the recipe once.
This is just an example in my work: I need to frequently install different versions (lots) of a software on different nodes. Is there a way to help me reduce the times of uploading very similar recipes?
You can use Ohai to fetch the node name and apply it in your recipe as a condition for a resource to execute. Just for example -
if node['hostname'] == 'client1'
if node['hostname'] == 'client2'
When you are dealing with multiple nodes at the same time you need to use a different ohai value, say Platform, Platform_version etc.
Thanks for your reply. Yes, it works but is not the best option since I have to add the name of node to the recipe. After some experiments with knife bootstrap, I find 'hint' is what I am looking for: I can pass version info from workstation to client without adding specific info into the recipe.