1

Can someone help me with puppet node ordering, I know how to control sequence inside classes using require, before, subscribe etc but I need to be 100% sure that my node2 will be executed only after node1 because my node2 can't work without node1.

Roman Iuvshin
  • 131
  • 2
  • 8
  • It feels like you should built your node2 as robust to not too heavily depend upon node1. If it cannot be provisioned without node1, how will it handle outages of node1? – Michuelnik Nov 18 '13 at 20:40

2 Answers2

2

It isn't possible to do this within puppet. If you need to perform puppet runs across servers in a specific order, you need to use another tool to orchestrate the runs.

sciurus
  • 12,493
  • 2
  • 30
  • 49
  • Possible tools to orchestrate the puppet runs: ansible and pdsh. – Mark Wagner Nov 19 '13 at 00:38
  • It would seem a little odd to use ansible (a complete CM tool like puppet) to orchestrate puppet. – sciurus Nov 20 '13 at 01:20
  • Not really. ansible patterns for selecting hosts are very useful, even if you don't use all the other stuff. Nevertheless ansible is great for adhoc commands as well. – Mark Wagner Nov 20 '13 at 18:13
0

Assuming you are using Linux hosts, but then you could also do the same with Windows host using alternative approach to bash. A somewhat generalized approach could be the following...

  1. At the very end of puppet run for node1, create a specific file on node2. Use ssh to accomplish this as a command in a puppet resource. Ssh can be used to execute a command at a remote host to create a file--quite easy to accomplish. You would place this in an exec resource near the very end of the puppet run on node1.

  2. Create a bash script on node 2 which basically waits for the file to show up and then returns successful when it is present. This script can be created using a file resource early in the puppet run on node2. Simple bash scripting.

  3. Near the beginning of the puppet run for node 2, after you have created the bash script, run the very same bash script within a puppet exec resource. It will wait for the file to be created--basically waiting for the puppet run to complete on node 1 before progressing.

The steps above should provide the effect of having the puppet run on node 2 stop and wait very early in the process for the puppet run on node 1 to complete. Adjust as necessary to fit the particular host systems involved.

zman58
  • 41
  • 2