Array of tags not applying to resource

43 views
Skip to first unread message

Robert Davidson

unread,
Aug 6, 2015, 6:39:40 PM8/6/15
to puppet...@googlegroups.com
First of all: I'm running puppet 3.6.2, as we are not in a position to move to Puppet 4 yet/

When I try to apply an array of tags to an exported resource, as I should be able to according to docs (https://docs.puppetlabs.com/puppet/3.6/reference/lang_tags.html#the-tag-metaparameter), the tags simply do not apply, and thus collectors fail to function correctly. If I apply only a single tag, it works fine.

This works:
@@module::hostentry{ $::fqdn:
tag => 'host.example.com',
}
Module::Hostentry <<| tag != 'host.example.com' |>>

This does not - fails with duplicate resource errors, because we already have a host entry for the machine defined elsewhere:
@@module::hostentry{ $::fqdn:
tag => ['host.example.com'],
}
Module::Hostentry <<| tag != 'host.example.com' |>>


My actual code is trying to use more than one tag, and looks more like this, which again, works if I cut it down to a single tag on the resource:

@@module::hostentry{ $::fqdn:
tag => [$::fqdn, $::site],
}
Module::Hostentry <<| tag ==$::site and tag != $::fqdn|>>


I must be doing *something* wrong here, since I haven't been able to turn up anyone else complaining about this, and something that is so contrary to what the documentation says would surely have hit someone else before now!


--
Robert Davidson


jcbollinger

unread,
Aug 7, 2015, 8:58:35 AM8/7/15
to Puppet Users
Per the docs, there is a bit of asymmetry between the '==' and '!=' operators in search expressions:
  • For ==, "this operator will match if the value of the attribute (or one of the value’s members, if the value is an array) is identical to the search key."
  • For !=, "This operator will always match if the attribute’s value is an array."
Both behaviors make sense (in particular, a scalar value certainly isn't equal to any array), but they are not proper opposites of each other with respect to arrays, as one might reasonably expect them to be.


John

Robert Davidson

unread,
Aug 7, 2015, 6:04:42 PM8/7/15
to puppet...@googlegroups.com
So there's no way to apply more than one tag to something at a time and have it actually act as if they are single tags?

Therefore, this exported resource:
@@module::hostentry{ $::fqdn:
tag => [$::fqdn, $::site],
}

Has these tags:
module
hostentry
module::hostentry
[$::fqdn, $::site]

Rather than what you might expect:
module
hostentry
module::hostentry
$::fqdn
$::site

That's . . . uh . . . special. I suppose I could get around this by only having one tag added using the metaparameter, and include the other in the surrounding class using the tag function, which would add them independently, but that's ludicrous. (Is there any way to make puppet spit out the list of tags on a resource in something like a notify{}? )

Given that I'm using an old version of puppet, would I be able to get anywhere by filing a bug report on this behavior, or would it just get bitbucketed? I don't see anything in the Puppet 4 docs that would indicate it's behavior has changed, though.


--
Robert Davidson


> -----Original Message-----
> From: puppet...@googlegroups.com [mailto:puppet-
> us...@googlegroups.com] On Behalf Of jcbollinger
> Sent: Friday, August 07, 2015 5:59 AM
> To: Puppet Users
> Subject: [Puppet Users] Re: Array of tags not applying to resource
>
>
>
> On Thursday, August 6, 2015 at 5:39:40 PM UTC-5, robert.davidson wrote:
>
> First of all: I'm running puppet 3.6.2, as we are not in a position to
> move to Puppet 4 yet/
>
> When I try to apply an array of tags to an exported resource, as I
> should be able to according to docs
> (https://docs.puppetlabs.com/puppet/3.6/reference/lang_tags.html#the-
> tag-metaparameter
> <https://docs.puppetlabs.com/puppet/3.6/reference/lang_tags.html#the-
> tag-metaparameter> ), the tags simply do not apply, and thus collectors fail
> to function correctly. If I apply only a single tag, it works fine.
>
> This works:
> @@module::hostentry{ $::fqdn:
> tag => 'host.example.com',
> }
> Module::Hostentry <<| tag != 'host.example.com' |>>
>
> This does not - fails with duplicate resource errors, because we
> already have a host entry for the machine defined elsewhere:
> @@module::hostentry{ $::fqdn:
> tag => ['host.example.com'],
> }
> Module::Hostentry <<| tag != 'host.example.com' |>>
>
>
> My actual code is trying to use more than one tag, and looks more
> like this, which again, works if I cut it down to a single tag on the resource:
>
> @@module::hostentry{ $::fqdn:
> tag => [$::fqdn, $::site],
> }
> Module::Hostentry <<| tag ==$::site and tag != $::fqdn|>>
>
>
> I must be doing *something* wrong here, since I haven't been able
> to turn up anyone else complaining about this, and something that is so
> contrary to what the documentation says would surely have hit someone
> else before now!
>
>
>
>
>
> Per the docs
> <https://docs.puppetlabs.com/puppet/3.6/reference/lang_collectors.html#
> search-expressions> , there is a bit of asymmetry between the '==' and '!='
> operators in search expressions:
>
>
> * For ==, "this operator will match if the value of the attribute (or one
> of the value’s members, if the value is an array) is identical to the search
> key."
> * For !=, "This operator will always match if the attribute’s value is an
> array."
>
> Both behaviors make sense (in particular, a scalar value certainly isn't equal
> to any array), but they are not proper opposites of each other with respect
> to arrays, as one might reasonably expect them to be.
>
>
> John
>
>
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/878a121c-05ab-4a78-
> b2ab-f63bc4633341%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/878a121c-05ab-4a78-
> b2ab-
> f63bc4633341%40googlegroups.com?utm_medium=email&utm_source=foot
> er> .
> For more options, visit https://groups.google.com/d/optout.

jcbollinger

unread,
Aug 10, 2015, 11:21:21 AM8/10/15
to Puppet Users


On Friday, August 7, 2015 at 5:04:42 PM UTC-5, robert.davidson wrote:
So there's no way to apply more than one tag to something at a time and have it actually act as if they are single tags?

Therefore, this exported resource:
@@module::hostentry{ $::fqdn:
   tag => [$::fqdn, $::site],
}

Has these tags:
module
hostentry
module::hostentry
[$::fqdn, $::site]

Rather than what you might expect:
module
hostentry
module::hostentry
$::fqdn
$::site

That's . . . uh . . . special.


I think it's probably more complicated than that, with ties to implementation details and [inconsistencies in] data model representation, but I cannot answer the question authoritatively.  Upon further consideration, I agree that the observed behavior is inconsistent; I just don't know which should be considered correct.

 
I suppose I could get around this by only having one tag added using the metaparameter, and include the other in the surrounding class using the tag function, which would add them independently, but that's ludicrous. (Is there any way to make puppet spit out the list of tags on a resource in something like a notify{}? )

Given that I'm using an old version of puppet, would I be able to get anywhere by filing a bug report on this behavior, or would it just get bitbucketed? I don't see anything in the Puppet 4 docs that would indicate it's behavior has changed, though.


I suggest you do check bug tracker, and report the issue if it's not already documented.  I cannot speak to how a report against Puppet 3.6 would be received, but it might at least get someone to check against other Puppet versions, especially if you can present simple, standalone, easily tested code that reproduces it for you.  Even if not, there's some value just in having it documented.


John

Reply all
Reply to author
Forward
0 new messages