It only makes sense to export resources that are somehow specific to or characteristic of the node whose catalog is being compiled. If you have such a resource to export, then structure your manifests so that no more than one declaration of the resource can be evaluated during any catalog compilation. No need for any tests in that case. If different nodes may export similar resources, then do ensure that they all have distinct titles (and names) across all nodes.
On the other hand, if your resources are not characteristic of any particular node, then they are not suited for export. We might be able to suggest specific alternatives if you explained what you are trying to achieve in more detail.
We have something quite similar - as we use hiera extensively we managed
to have a common yaml file with a list of databases in a hash, and used
create_resources to create the databases (and users, and haproxy
listeners) on the database/haproxy nodes.
The application nodes that want to register with a load balancer export
resources for themselves only, which are collected on the load balancer
only.
An alternative is to have a manifest that ensures there is a suitable
database available, creating it if not, running on the web application
servers - you've got a db client there already which should be able to
access the db server. That approach also allows you to ensure there's a
database created before attempting to populate it and start the app,
exported resources mean you'll need several runs before everything is
clean.
On Thursday, January 23, 2014 2:59:29 PM UTC+1, jcbollinger wrote:It only makes sense to export resources that are somehow specific to or characteristic of the node whose catalog is being compiled. If you have such a resource to export, then structure your manifests so that no more than one declaration of the resource can be evaluated during any catalog compilation. No need for any tests in that case. If different nodes may export similar resources, then do ensure that they all have distinct titles (and names) across all nodes.
On the other hand, if your resources are not characteristic of any particular node, then they are not suited for export. We might be able to suggest specific alternatives if you explained what you are trying to achieve in more detail.
Basically my situation is the following:
- A database server
- Several web application servers.
The whole managed using foreman/puppet
My Web applications each need a database, so I would like to just export on the web application nodes the databases I need, and collect them on the database server. However, several nodes that run the same web application of course need the same database. What do I do when I have two nodes, that both need the same database?
The logical, intuitive solution would be to export it on all of them, but only collect it once on the database server.
Other situations are : backends to a loadbalancer that export both frontend and backend URLs. The loadbalancer collects both, and creates it's configuration based on them.
On Thursday, January 23, 2014 7:25:47 PM UTC+1, Xav Paice wrote:
We have something quite similar - as we use hiera extensively we managed
to have a common yaml file with a list of databases in a hash, and used
create_resources to create the databases (and users, and haproxy
listeners) on the database/haproxy nodes.
The application nodes that want to register with a load balancer export
resources for themselves only, which are collected on the load balancer
only.
We don't use Hiera. We use foreman as ENC.
Thus we also don't have per node manifests.
What we do have is our own module, with classes we assign to host groups in foreman. We define a host group for or different categories of servers, and assign hosts to a host group based on what they are supposed to do.
So if we for example want to add another backend we just create a new host in foreman, add it to the right host group, and then flip a switch. It powers on, bootstraps itself, installs all it needs, and exports what it needs from other servers. However we run in to the problem of duplicate external resources, which I have for the moment resolved through some ugly hacks.
An alternative is to have a manifest that ensures there is a suitable
database available, creating it if not, running on the web application
servers - you've got a db client there already which should be able to
access the db server. That approach also allows you to ensure there's a
database created before attempting to populate it and start the app,
exported resources mean you'll need several runs before everything is
clean.
For security reason we only allow root access to the mysql database from the host it runs on, via a unix socket. That is why the DB server needs to collect the databases and then create them.
But that problem seems solvable also. But I am still interested in a general solution-
We have "virtual resources". This has allowed me to for example declare all the different VLANs in one class that all nodes include, but then only realize the lans needed on a per service basis. Something like "exported virtual resources" would be convenient.