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?
Every resource is associated with a resource type , which determines the kind of configuration it manages. Puppet has built-in resource types such as file , service , and package . See the resource type reference for a complete list and information about the built-in resource types.
The resource type defines the kind of configuration it manages. This section provides information about the resource types that are built into Puppet. This page provides a reference guide for the core Puppet types: package , file , service , notify , exec , cron , user , and group .
A node definition, also known as a node statement, is a block of Puppet code that is included only in matching nodes' catalogs. This allows you to assign specific configurations to specific nodes. Put node definitions in the main manifest, which can be a single site. pp file, or a directory containing many files.
By default, Puppet applies unrelated resources in the order in which they're written in the manifest.
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,...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With