OK, I did some more testing and while the error message is different with
the selector using if/then doesn't really fix the issue.  The underlying
problem is that testing a hash with an undefined LHS doesn't work the way
I'd expect it to.  It should return false, but as long as the hash itself
exists the test will return true.  Like so:

$testhash = { testkey1 => "testval1" }
if $testhash[testkey1] { notify{ "Testhash with testkey1 is true": } }
if $testhash[testkey2] { notify{ "Testhash with testkey2 is true": } }


The results:
notice: Testhash with testkey1 is true
notice: Testhash with testkey2 is true

On Wed, Jun 1, 2011 at 8:48 AM, Aaron Grewell <aaron.grew...@gmail.com>wrote:

> Good point, sorry I left out the error message:
>
> err: Could not retrieve catalog from remote server: Error 400 on SERVER: No
> matching value for selector param '' at
> /usr/share/puppet/environments/testing/modules/users/manifests/init.pp:142
> on node
>
> The value isn't an array, it's a hash.  I noticed there was a similar bug
> opened on hash handling in selectors, but that was supposed to be fixed in
> 2.6.7.  I'm running 2.6.7 so I'm not sure why I'd be seeing this behavior.
>
>
> On Wed, Jun 1, 2011 at 6:13 AM, Brice Figureau <
> brice-pup...@daysofwonder.com> wrote:
>
>> On Tue, 2011-05-31 at 17:29 -0700, Aaron Grewell wrote:
>> > Should the C-style selector and if/then statements have equivalent
>> > true/false handling?  Maybe I'm setting this up wrong, but I expected
>> > these two to be the same:
>> >
>> > if $name[symlink]    { $symlink    = $name[symlink]    } else
>> > { $symlink    = undef                }
>> > $symlink    = $name[symlink]    ? { true => $name[symlink],    false
>> > => undef              }
>> >
>> > Yet they don't return the same result.  The if/then statement sets the
>> > value to false as expected, whereas the selector never matches at all
>> > and throws an error.
>>
>> There shouldn't be any difference, except there is a known issue with
>> selectors and arrays:
>> http://projects.puppetlabs.com/issues/5860
>>
>> Since you're mentioning an error (which you should have included for
>> further analysis), I'd tend to think you're hitting this issue.
>>
>> HTH,
>> --
>> Brice Figureau
>> Follow the latest Puppet Community evolutions on www.planetpuppet.org!
>>
>> --
>> 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