On Friday, November 2, 2012 2:54:11 PM UTC-5, Erwin Bogaard wrote:
>
> Thanks for your reply. Let me clarify things a little more.
> I use the following class to apply to a certain node:
>
> class sugar::instances {
>
> sugar::definitions_sugar {
> # SugarCRM - ECM2
> 'node1':
> mysql_dbname => 'dbname1',
> mysql_pwd => 'password1';
>
> sugar::definitions_sugar_wp {
> 'node2':
> sugar_admin => 'text1',
> sugar_pwd => 'password2',
> mysql_dbname => 'dbname2',
> mysql_pwd => 'password3';
>
> As I wrote earlier: there are some nodes I like to apply just the
> sugar-defines to, and there are nodes that I like to apply the
> sugar-defines and the wordpress-defines to.
> As you can see, some of the input (mysql_dbname/pwd) is the same for both
> defines. So I would really like to reuse this. As I don't understand how to
> apply multiple defines to one node, I use a workaround where I add the
> information for sugar to both defines. As this isn't really a good idea and
> creates extra work and a source for problems and inconsistency, I would
> really like to have one define for sugar and one for wordpress. In that
> situation I would like to apply only the sugar-define to node1 and both
> defines to node2, when only declaring node2 once.
>
> I hope this makes things clearer, but as you said, maybe I'm using the
> wrong words (or jargon) for the right things.
>
Well, you haven't given any bits that are likely to be causing trouble, so
I can offer only general advice. The main issues to watch out for with
applying multiple instances of the same defined type to one node are
1. The instances must have different titles
2. The instances must not declare duplicate resources (as each other or
as anything else)
As long as you observe those requirements, there is nothing special to what
you say you want to do. There are a variations on how you can express it
in Puppet DSL, but they are all equivalent to this:
sugar::definitions_sugar {
# SugarCRM - ECM2
'node1':
mysql_dbname => 'dbname1',
mysql_pwd => 'password1';
}
sugar::definitions_sugar {
# SugarCRM - ECM2, node2
'node2':
mysql_dbname => 'dbname1',
mysql_pwd => 'password1';
}
If something like that is giving you trouble, then it probably arises from
a violation of my point (2) above. That can arise if their definitions
declare resources that aren't specific to individual instances. For
example,
define sugar::definitions_sugar (
$mysql_dbname,
$mysql_pwd) {
mysql::database { "$mysql_dbname":
password => "$mysql_pwd"
}
# other declarations ...
}
If you want multiple Sugar instances to be able to share the same DB, then
no particular instance owns that DB, hence *none* of them should declare
it. Instead, the DB should be declared separately, in a class, which each
instance can then 'include':
class sugar::database {
mysql::database { "$sugar::params::mysql_dbname":
password => "$sugar::params::mysql_pwd"
}
# other declarations ...
}
define sugar::definitions_sugar {
include 'sugar::database'
# other declarations ...
}
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/TeiYs1auEmMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.