[Puppet Users] variables in variable and class names

zuber@puzzle.ch
Fri, 07 May 2010 10:03:01 -0000

Hi, this may sound a bit strange, so let me tell you first what the
problem is that i try to solve and maybe there is already a better
solution.

Some background: We use 3 different environments on our puppetmaster and
we implemented something like a release management as a workflow for this.
Cause why should you invent something new when you can steal it from
software engineers ;-). The release management is a simple tag convention
in the version management and a post-receive script that makes a checkout
the newest version for each environment. We have a release cycle where we
tag a version for integration that worked without regression for a while
on the testing environment. For production exactly the same.

Now there are sometimes settings, config files or classes that only apply
on a single host and the whole release cycle makes no sense and you really
don''t want to wait some days until the new firewall rule apply on a
production system because there are already other changes in the pipe and
you can''t just "tag it trought".

So my plan is to have a special module that is always checked out from
HEAD in every environment and the classes there, if defined are only
applied on a singe host, never group of hosts. If they are not defined the
host is just uses the defaults. For files this is easy, but for variables
or classes i found no way so far to implement this.

Here is an NON working example that may describe what i want to do:

-----------------------------------------------------------
# Settings i want to overwrite only for "mynewserver".
# This class is only there if i need at least one special settings
class hostconfig::mynewserver::settings {
    $myvar = "overwritten for this host"
}

# Load the settings class if it exists
if defined( hostconfig::${hostname}::settings ) {
    include hostconfig::${hostname}::settings
}

# if we need a variable that can be overwritten i have to check
# if it exists. If it does not we use the default value.
if defined( $hostconfig::${hostname}::settings::myvar ) {
    $var = $hostconfig::${hostname}::settings::myvar
} else {
    $var = "default"
}

notice( $var )

------------------------------------------------------------------

If the host is a standard system i should i want to do absolutely nothing,
cause it gets its classes and settings from regex patterns in the default
node config based on the server name (We only have a hand full of
different servers but many of them).

Any ideas how i can implement this in a way that works?

--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at