FAQ
Hello.
I'm kind of new with puppet and i'mhaving a problem using hashes with
classes or defines.
Here is an example of what im trying to do:

$myhash = { key => "some value",
other_key => "some other value",
other_ki => "other other",
}

class test{
file {"/var/tmp/$myhash[key]":
ensure => "present",
}
}

class {'test':
}

Result:
Error: Invalid tag "/var/tmp/other_keysome other valuekeysome
valueother_kipepe" at /etc/puppet/manifests/site.pp:10 on nod

--
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.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jcbollinger at Jan 28, 2013 at 3:53 pm

    On Friday, January 25, 2013 5:26:13 AM UTC-6, emzvargas wrote:
    Hello.
    I'm kind of new with puppet and i'mhaving a problem using hashes with
    classes or defines.
    Here is an example of what im trying to do:

    $myhash = { key => "some value",
    other_key => "some other value",
    other_ki => "other other",
    }

    class test{
    file {"/var/tmp/$myhash[key]":
    ensure => "present",
    }
    }

    class {'test':
    }

    Result:
    Error: Invalid tag "/var/tmp/other_keysome other valuekeysome
    valueother_kipepe" at /etc/puppet/manifests/site.pp:10 on nod

    Puppet string interpolation does not recognize references to components of
    compound values. Instead, you are getting interpolation of the whole hash
    (coerced to a string). Do this instead:

    class test{
    $value = $myhash['key']

    file {"/var/tmp/$value":
    ensure => "present",
    }
    }



    John

    --
    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.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJan 25, '13 at 2:52p
activeJan 28, '13 at 3:53p
posts2
users2
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase