Running chef-client on node through shell script


#1

I am trying to run chef client on node remotely by placing knife ssh command in a shell script.
How can I identify whether chef client executed successfully or it failed for that execution.
The command i am using to run chef client remotely through a shell script is:-
knife ssh -m “nodename” ‘sudo chef-client’


#2

You should be able to use the --exit-on-error option

knife ssh -m 'nodename' 'sudo chef-client' --exit-on-error
echo $?

#3

My objective is to update the master table based on the result that if the chef-client execution was successfull then update the table with success else failure.
Will this command be able to do so?

Now the scenario is , i am passing multiple node names in knife ssh -m “node1,node2” so if chef-client succeeds on node 1 but fails on node 2 so will this --exit-on-error option tell me that it failed on node 2 and passed on node 1