On 9/19/13 4:13 PM, 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. 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.
>
> 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
>
> --
> Later,
> Darin
>
This is an issue with type casting. The target parameter[1] is using a
string and I think that you believe that multiple concat::fragments
should get called, one for each element in the array, which is not going
to happen.
If that is the functionality you want, then $configs[2] should stay a
string and not allow arrays. You can use create_resources()[3] to call
amanda::disklist multiple times, which from your issue[4], is what I
believe your intention is.
Here is a gist[5] to demonstrate with YAML files that you might place in
Hiera.
[1] -
https://github.com/deadpoint/puppet-amanda/blob/disklist/manifests/disklist.pp#L14
[2] -
https://github.com/deadpoint/puppet-amanda/blob/disklist/manifests/disklist.pp#L2
[3] -
http://docs.puppetlabs.com/references/latest/function.html#createresources
[4] - https://github.com/pdxcat/puppet-module-amanda/issues/12
[5] - https://gist.github.com/ghoneycutt/6627040
BR,
-g
--
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.