Puppet: relationship between resources on different nodes

configuration, puppet

Solution

In a distributed "puppet" setup, the apply order isn't guaranteed.

Puppet don't do orchestration across multiple nodes. At best, your changes will get applied multiple times on the machines and finally will converge to the desired state.

Dependencies only work in a same node. You can actually get values of resources exported by others nodes (for eg to configure the firewall of your db to allow the web server to do sql) Or cheat with hiera to know who have the "db" and "app" roles.

For orchestration see tools like mcollective, capistrano, ansible,...

Problem

I know that we can specify relationship between resources, which determines the deployment order. But is it possible to create relationship between resources on different nodes in Puppet? For example, I have apache web server in node A and mysql server in node B. I want to start mysql first before starting apache web server. How could I express this in Puppet language? I have tried the following codes: ``` node ‘host1’ { @@service { ‘mysql’: ensure => running, tag => ‘host1-mysql’, } } node ‘host2’ { service { ‘apache2’: ensure => running, } Service<<| tag == ‘host1-mysql’ |>> -> Service[‘apache2’] } ``` But it didn't work - produced a compile error. Any other solution?

Original source