this topic is currently being massively discussed so I just would like to share
my pain also.
my intention was to have an array of node's roles and each included role class
would just record into the array its role identificator. then I could write
simple function has_role and then write various condition with role checks.
imho this would be awesome however impossible to implement with variable
scoping.
individual roles would be defined as classes as follows (this is just an
example demonstrating the varscope issue so don't try to find a workaround for
this simple case as I am more interested how to implement this whole idea):
class root_role {
$node_roles = []
}
class role_mysql extends root_role {
$node_roles += [ "role_mysql" ]
include mysql
}
class role_postgres extends root_role {
$node_roles += [ "role_postgres" ]
include mysql
}
class role_basehost {
if has_role("role_postgres") {
<some action>
} else {
<another action>
}
}
node lamp {
include role_postgres
include role_basehost
}
obviously this doesn't work. maybe you have now idea to use directly the
$root_role::node_roles and reference it in all other roles however that
wouldn't work neither cause the qualified variables from other classes are
readonly.
this is pain, pain and again pain!
cry with me,
Antony.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
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.