On Thursday, September 19, 2013 9:13:59 AM UTC-5, Darin Perusich wrote:
>
> Hello All,
>
> I've run into an issue where an array that's being passed into a
> defined type is being "flattened" when it's inclosed in double quotes
> and I'm not sure how to get around this.
You get around it by not referencing the variable inside double quotes.
Putting the variable reference inside double quotes indicates that you want
to interpolate its (one) string value into the (one) larger string.
> This is happening a the
> pdxcat/amanda module and I've raised an github issues for this but
> wanted to query the community as a whole. The issue and my branch of
> the code are below.
>
> The amanda::server or amanda::configs class/defined type allow you to
> populate amanda configuration directories from files,
> /etc/amanda/$configs, by setting configs => [ "daily", "weekly" ] in
> the manifest. In my defined type, amanda::disklist, the parameter
> $configs needs to be used to set the correct target path to a file
> which I'm using contact::fragment to modify. When $configs is a single
> value, say "daily", everything works as expected. But then $configs is
> an array, "daily" and "weekly", it's flattened to "dailyweekly" which
> results in an "Invalid relationship:" error.
>
What is the desired behavior in this case? Choose the first element? The
last? A random one? Perhaps do something for each element?
>
> Can anyone provide some guidance on how to get around this? I've been
> banging on this for a few days and my heads really starting to hurt.
>
> define amanda::disklist (
> $configs,
> $diskdevice = undef,
> $dumptype,
> $ensure = present,
> $interface = undef,
> $order = 20,
> $spindle = undef
> ) {
> include amanda::params
> include amanda::virtual
>
> concat::fragment { "amanda::disklist/$title":
> target => "$amanda::params::configs_directory/$configs/disklist",
> ensure => $ensure,
> order => $order,
> content => "$fqdn $name $diskdevice $dumptype $spindle
> $interface\n",
> tag => "amanda_dle",
> }
>
> https://github.com/pdxcat/puppet-module-amanda/issues/12
> https://github.com/deadpoint/puppet-amanda/tree/disklist
>
>
Your definition seems generally ill-conceived, or at least ill-named, in
the face of a $configs variable containing multiple elements. The only
sensible thing I can see in that case would be for multiple files to be
managed, whereas your defined type represents only one.
What is the relationship between your defined type and amanda::dle? The
latter appears to be doing about the same thing, but seems to get it
right. The key difference there is that amanda::dle makes use of the
$configs array directly as a resource title. When an array literal or an
array-valued variable is used as a resource title, it serves as shorthand
for multiple resource declarations, one for each array element, all with
the same parameters. This behavior is often leveraged for splitting arrays
into multiple elements, just as amanda::dle does.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.