-----Original message-----
From: Isaiah Frantz <isaiah.fra...@gmail.com>
Sent: Wednesday 21st September 2016 21:35
To: Puppet Users <puppet-users@googlegroups.com>
Subject: [Puppet Users] resource collector with multiple 'tag !=' test

Hello,
I am trying to realize users and am not getting what I expect with multiple != 
test.
Here is a simplified version that I have tested with puppet gem 4.2.2 and 4.6.2 
(results were the same for all tests):
cat t.ppt.pp (common to all tests): 
@notify {'This is a test 1':
        tag => 'one'
}
@notify {'This is a test 2':
        tag => 'two'
}
@notify {'This is a test 3':
        tag => ['one', 'two']
}
@notify {'This is a test 4':
        tag => 'three'
}
Notify <| test_goes_here |>

First 3 expected:
tail -1 t.pp 
Notify <| tag == 'one' or tag == 'two' |>

puppet apply t.pp 
Notice: Compiled catalog for defiant.cequintecid.com in environment production 
in 0.70 seconds
Notice: This is a test 1
Notice: /Stage[main]/Main/Notify[This is a test 1]/message: defined 'message' 
as 'This is a test 1'
Notice: This is a test 2
Notice: /Stage[main]/Main/Notify[This is a test 2]/message: defined 'message' 
as 'This is a test 2'
Notice: This is a test 3
Notice: /Stage[main]/Main/Notify[This is a test 3]/message: defined 'message' 
as 'This is a test 3'
Notice: Applied catalog in 0.02 seconds


Test 3 only, as expected:
tail -1 t.pp 
Notify <| tag == 'one' and tag == 'two' |>

puppet apply t.pp 
Notice: Compiled catalog for defiant.cequintecid.com in environment production 
in 0.47 seconds
Notice: This is a test 3
Notice: /Stage[main]/Main/Notify[This is a test 3]/message: defined 'message' 
as 'This is a test 3'
Notice: Applied catalog in 0.02 seconds

Now we get to the '!=' tests.
with a single tag it works as expected so I wont take space here to show that.
With multiple tags, it does not work as expected

Since tags is a hash that contains lots of things, including all explicit tag's 
set on a resource. The == and != operators are supposed to act like contains 
and !contains functions (or so I thought)
Here I expect to only get test 4. 1 and 2 are filtered because one of the 
and'ed tests is false.
3 should fail too because both test are false: tags contains both 'one' and 
'two'. 
tail -1 t.pp 
Notify <| tag != 'one' and tag != 'two' |>

puppet apply t.pp 
Notice: Compiled catalog for defiant.cequintecid.com in environment production 
in 0.48 seconds
Notice: This is a test 3
Notice: /Stage[main]/Main/Notify[This is a test 3]/message: defined 'message' 
as 'This is a test 3'
Notice: This is a test 4
Notice: /Stage[main]/Main/Notify[This is a test 4]/message: defined 'message' 
as 'This is a test 4'
Notice: Applied catalog in 0.01 seconds


Frankly, I also expect that 3 should be filtered from the or version too 
because neither of the tests should be true if this is a contains function and 
not one that tests against each hash value.
tail -1 t.pp                                                                    
                                             
Notify <| tag != 'one' or tag != 'two' |>

puppet apply t.pp 
Notice: Compiled catalog for defiant.cequintecid.com in environment production 
in 0.58 seconds
Notice: This is a test 1
Notice: /Stage[main]/Main/Notify[This is a test 1]/message: defined 'message' 
as 'This is a test 1'
Notice: This is a test 2
Notice: /Stage[main]/Main/Notify[This is a test 2]/message: defined 'message' 
as 'This is a test 2'
Notice: This is a test 3
Notice: /Stage[main]/Main/Notify[This is a test 3]/message: defined 'message' 
as 'This is a test 3'
Notice: This is a test 4
Notice: /Stage[main]/Main/Notify[This is a test 4]/message: defined 'message' 
as 'This is a test 4'
Notice: Applied catalog in 0.02 seconds



Two boolean falses dont make a true do they?
Im confused  :(
The query could be explained as follows :



If iether there is a tag that is not 'one', or there is a tag that is not two, 
then it will be collected.

test1 : tag => one is != two, so that gives us true, and this collected

test2: tag => two is != one, so here also gives us true and thus collected

test3: tag => [ one , two].  as soon as there is one tag in the array that 
return true, than the resource is collected.  In your case one != two and aslo  
two!=one, which makes the rersource collected. 

test4: tag => three differs from both one and two



It is clear one needs to be carefull when defining the query in a collector.  
Don't assume it works as we are used to work in conditionals as we are used in 
normal programming.  



I hope i didn't confuse too much.



Hth



johan










-- 
 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 puppet-users+unsubscr...@googlegroups.com 
<mailto:puppet-users+unsubscr...@googlegroups.com> .
 To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/e31573bc-b306-482b-bf64-762a0ba9dfca%40googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

Next Trainings:

Zabbix Training | https://www.open-future.be/calendar
Bacula Training | https://www.open-future.be/calendar
Puppet Training | https://www.open-future.be/calendar
Linux  Training | https://www.open-future.be/calendar

Subscribe to our newsletter   | http://eepurl.com/BUG8H


-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/zarafa.57e37a8f.731d.4b7d002e7da74b84%40zarafa7.open-future.be.
For more options, visit https://groups.google.com/d/optout.

Reply via email to