I found an answer to this particular issue.  Thanks for the reminder so I can 
share the answer:

I found the hiera/yaml way to indicate an empty array !
So, to use my earlier example:

users:
  beast:
      username : beast
      uid      : 6666
      ingroups :
          - ''
      info     : Let's see if this works

Then, with a hiera call, I get :

{"beast"=>{"ingroups"=>[""], "uid"=>6666, "username"=>"beast", "info"=>"Let's 
see if this works"}

I was able to more forward past this problem after figuring that out.

“Sometimes I think the surest sign that intelligent life exists elsewhere in 
the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)

----- Luke Bigum <luke.bi...@lmax.com> wrote:
> On 22/05/12 00:22, Jeff McCune wrote:
> > On Mon, May 21, 2012 at 1:24 AM, Luke Bigum <luke.bi...@lmax.com 
> > <mailto:luke.bi...@lmax.com>> wrote:
> >
> >     I agree with Gary, Dan, it's probably the lack of data in the
> >     'v_ingroups' key in your YAML that create_resources() is
> >     complaining about. If it truly can't pass an empty key/val pair
> >     you could do something hacky like use the string "undef" then
> >     explicitly check for it in the define.
> >
> >
> >     define add_virtual_user ( $v_username, $v_uid, $v_ingroups,
> >     $v_info ) {
> >        if ($v_ingroups == "undef") {
> >
> >
> > Do you really mean to be comparing to the string "undef" rather than 
> > the keyword undef (no quotes)?
> >
> 
> Yes, unfortunately I did. It's because when using Hiera 0.3 it's a bit 
> difficult to figure out what a Ruby nil gets passed into Puppet as. 
> Consider the following manifest using Dan's example YAML (v_ingroups is 
> a nil value):
> 
> ----------------
> #---
> #users:
> #   beast:
> #       v_username : beast
> #       v_uid      : 6666
> #       v_ingroups :
> #       v_info     : Let's see if this works
> 
> define add_virtual_user ( $v_username, $v_uid, $v_ingroups, $v_info ) {
>     notify { $name:
>         message => "username = ${v_username}, uid = ${v_uid}, ingroups = 
> ${v_ingroups}, info = ${v_info}",
>     }
> }
> 
> $the_users = hiera_hash('users')
> 
> notice($the_users["beast"])
> notice("prints as ${the_users[beast][v_ingroups]}")
> 
> if ($the_users["beast"]["v_ingroups"] == undef) {
>    notice("is == undef")
> }
> 
> if (defined($the_users["beast"]["v_ingroups"])) {
>    notice("is not defined")
> }
> 
> if ($the_users["beast"]["v_ingroups"] == "") {
>    notice("is empty string")
> }
> 
> if (! $the_users["beast"]["v_ingroups"]) {
>    notice("is false")
> }
> 
> if ($the_users["beast"]["v_ingroups"]) {
>    notice("is true")
> }
> 
> if ($the_users["beast"]["v_ingroups"] == nil) {
>    notice("is nil?")
> }
> 
> create_resources('add_virtual_user', $the_users)
> ---------------
> 
> It's not an empty string, it's not undef (but when you print it it comes 
> out as undef), it's not nil (which doesn't exist in Puppet), it's not 
> false but it *is* true? I've came across this once before and can't 
> remember what "nil" actually gets interpreted as.
> 
> So if you feed that Puppet hash directly into the create_resources() 
> function, it complains about a missing parameter:
> 
> ---------------------
> biguml@biguml-laptop:~$ puppet apply test.pp
> notice: Scope(Class[main]): 
> v_usernamebeastv_uid6666v_ingroupsundefv_infoLet's see if this works
> notice: Scope(Class[main]): undef
> notice: Scope(Class[main]): is true
> Must pass a parameter or all necessary values at /home/biguml/test.pp:40 
> on node biguml-laptop
> ---------------------
> 
> So my suggestion was to explicitly set "undef" as a string in the yaml, 
> then match on that in the Puppet manifests. It's horrible but would work.
> 
> -Luke
> 
> > There's a big difference...
> >
> > If you want to test if a variable is undefined the best way is to do this:
> >
> > if ($foo == undef) { notice "\$foo is undef" }
> > else { notice "\$foo is defined as ${foo}" }
> >
> > -Jeff
> > -- 
> > 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+unsubscr...@googlegroups.com.
> > For more options, visit this group at 
> > http://groups.google.com/group/puppet-users?hl=en.
> 
> 
> -- 
> Luke Bigum
> 
> Information Systems
> Ph: +44 (0) 20 3192 2520
> luke.bi...@lmax.com | http://www.lmax.com
> LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN
> 
> 
> 
> FX and CFDs are leveraged products that can result in losses exceeding
> your deposit.  They are not suitable for everyone so please ensure you
> fully understand the risks involved.  The information in this email is not
> directed at residents of the United States of America or any other
> jurisdiction where trading in CFDs and/or FX is restricted or prohibited
> by local laws or regulations.
> 
> The information in this email and any attachment is confidential and is
> intended only for the named recipient(s). The email may not be disclosed
> or used by any person other than the addressee, nor may it be copied in
> any way. If you are not the intended recipient please notify the sender
> immediately and delete any copies of this message. Any unauthorised
> copying, disclosure or distribution of the material in this e-mail is
> strictly forbidden.
> 
> LMAX operates a multilateral trading facility.  Authorised and regulated 
> by the Financial Services Authority (firm registration number 509778) and
> is registered in England and Wales (number 06505809). 
> Our registered address is Yellow Building, 1A Nicholas Road, London, W11
> 4AN.
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
> 

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

Reply via email to