Re: [Puppet Users] Default Values with External Nodes

Douglas Garstang
Sun, 20 Jun 2010 18:31:18 -0000

On Sun, Jun 20, 2010 at 11:16 AM, Douglas Garstang
<doug.garstang@gmail.com> wrote:
> On Sun, Jun 20, 2010 at 11:10 AM, Dan Bode <dan@puppetlabs.com>
wrote:
>>
>>
>> On Sun, Jun 20, 2010 at 11:05 AM, Douglas Garstang
<doug.garstang@gmail.com>
>> wrote:
>>>
>>> I''m in the process of trying to convert our current node
>>> implementation to external nodes. The definitions that we called
from
>>> our node manifests have been replaced by variables passed back to
>>> classes in modules. When using definitions, we could set default
>>> values in the definition, and therefore we didn''t always
have to pass
>>> every argument. However, now that I am using variables to set data,
>>> and calling definitions from that inside the classes, I have no way
>>> that I can see to set default values.
>>>
>>> Eg:
>>> If the external node has:
>>>
>>> ---
>>> classes:
>>>  - server_role::appServer
>>>  - elements::tfel4
>>> environment: production
>>> parameters:
>>>  tfel4_ClusterDescription:         "Cluster1"
>>>  tfel4_ClusterWebUrl:              "https://qa4.xxx.com"
>>>  tfel4_ClusterDbHost:
 "ora02.xxx.twofish.com"
>>>  tfel4_ClusterDbPort:              1521
>>>  tfel4_ClusterDbType:              oracle
>>>
>>> I would like the option to not to have to set tfel4_ClusterDbType,
and
>>> have it default to Oracle. In the class I have this:
>>>
>>> some_definition {
>>>   key1 => val1,
>>>   dbprov => ${tfel4_ClusterDbType}
>>> }
>>>
>>> As you can see, since classes have no default values, I have to set
it
>>> some way. I tried this:
>>>
>>>    if ! defined($tfel4_ClusterDbType) {
>>>        $tfel4_ClusterDbType = "oracle"
>>>    }
>>
>> if (! $tfel4_ClusterDbType) {
>>   $tfel4_ClusterDbType = "oracle"
>> }
>
> Doesn''t work. Gives error:
> "Could not retrieve catalog: Could not find template
>
/etc/puppet/modules/starterkit/templates/jboss_inst/deploy/eazyedb-xa-ds.xml..erb"
>
> which means that the variable wasn''t set. The manifest at that
line has:
>
>
 "/opt/jboss/current/server/${name}/deploy/eazyedb-xa-ds.xml":
>            content =>
>
template("starterkit/jboss_inst/deploy/eazyedb-xa-ds.xml.${db_prov}.erb"),
>
> and db_prov is set by the definition called immediately after setting
> tfel4_ClusterDbType:
>
>    elements::customer {
>        tfel4:
>            <lots of stuff set here>
>            db_prov                 =>
"${tfel4_ClusterDbType}";
>    }
> }
>
> Doug.
>

Jeez... Even this doesn''t work:

    case $tfel4_ClusterDbType {
        undef: { $tfel4_ClusterDbType = "oracle" }
    }

The use of undef is based on the puppet docs at
http://docs.reductivelabs.com/guides/more_language.html. It just
reports later that the variable tfel4_ClusterDbType has not been set.