Hi,
On 31 Mar 2016, at 16:38, Jakov Sosic <[email protected]> wrote:
> Hi guys,
>
> I have a `test.pp` manifest that looks like:
>
>
> ```
> define basket($arg) {
> file { "/tmp/$name":
> ensure => present,
> content => $arg,
> }
> }
>
> foobar = {
> 'fruit' => { arg => 'apple' },
> 'berry' => { arg => 'watermelon' }
> }
>
> @basket[$foobar]
>
> realize( Basket[fruit] )
> realize( Basket[berry] )
> ```
>
>
> When I run `puppet apply test.pp`, this is what I get:
>
> Error: Could not parse for environment production: Virtual (@) can only be
> applied to a Resource Expression at /tmp/pero.pp:16:1 on node workstation
You are passing a Hash as an parameter to a define.
Inside the define you expect the parameter to be of type String - according to
what you do in the define.
You need to take care of splitting data accordingly in your define:
With Puppet 4 this is very easy to achieve:
define basket (
Hash $arg,
){
$arg.each |String $key, Hash $value| {
file { β/tmp/${key}β:
ensure => file,
content => $value[βargβ],
}
}
}
hth,
Martin
>
>
> Any ideas?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/56FD367F.90000%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/69D9ED57-136E-4394-9404-F85DC1E5B413%40gmail.com.
For more options, visit https://groups.google.com/d/optout.