Execute a recipe on multiple nodes sequentially

Hi Guys, Good morning all.

Recently we have integrated push-jobs with chef to execute recipes from workstation itself. But here my question is how to execute single recipe on multiple nodes sequentially using push-jobs?.

Generally we can execute a recipe on a node with push-jobs using below command
knife job start ‘chef-client’ node-name (on one node).
but if i use like below command

knife job start ‘chef-client’ Node1 Node2 Node3 … the recipe executing on multiple nodes but it is executing parallelly on the multiple nodes.

Thanks in Advance…

Did you find solution for this problem?

No, didn't find a way. Do you have any solution for this.

No. we are just doing it in for loop
for node in (knife search "chef_environment:{environment} AND (role:zookeeper-platform)" | grep FQDN | cut -f2 -d":")
do
echo $node
knife job start chef_client node -q '1' if [[ ( "{ACTION}" == "restart" ) && ( -z "${DRYRUN}" ) ]]
then
echo "restarting zookeeper"
knife job start restart_zookeeper $node -q '1'
sleep 10
fi
done

1 Like

may i know from where you are executing this for loop ?

its inside shell script. we can run it from chef workstation.

1 Like