PQL questions

59 views
Skip to first unread message

R.I.Pienaar

unread,
Aug 10, 2017, 12:33:04 PM8/10/17
to puppet-users
I want to do dot based fact queries in PQL, basic example:

inventory[certname] {facts.os.distro.release.major = "7"}

Great, no problems so far that works, but I cannot figure out how to say
!= "7"

in the fact endpoint I can do:

facts {name = "%s" and !(value = "%s")}

However this does not support the dot notation so thats not useful here.

The AST docs[1] says there is and, or and not but I cant figure out how
to use it there, the error messages various attempts give me are:

inventory[certname] {facts.os.distro.release.major not "7"
Expected one of:

is not null
is null
in
=
>
<
<=
>=
~>
~

This rather makes me think a basic not isn't supported here? But the old
AST docs[1] suggests it should be, so I am guessing some support is
missing in PQL here?

I'd also like to be able to do > etc on string values, which I think the
AST based queries also support?


[1]
https://docs.puppet.com/puppetdb/5.0/api/query/v4/ast.html#dot-notation

--
R.I.Pienaar / www.devco.net / @ripienaar

R.I.Pienaar

unread,
Aug 10, 2017, 2:20:39 PM8/10/17
to puppet...@googlegroups.com


On Thu, Aug 10, 2017, at 18:32, R.I.Pienaar wrote:
> I want to do dot based fact queries in PQL, basic example:
>
> inventory[certname] {facts.os.distro.release.major = "7"}
>
> Great, no problems so far that works, but I cannot figure out how to say
> != "7"
>
> in the fact endpoint I can do:
>
> facts {name = "%s" and !(value = "%s")}
>
> However this does not support the dot notation so thats not useful here.
>
> The AST docs[1] says there is and, or and not but I cant figure out how
> to use it there, the error messages various attempts give me are:
>
> inventory[certname] {facts.os.distro.release.major not "7"
> Expected one of:
>
> is not null
> is null
> in
> =
> >
> <
> <=
> >=
> ~>
> ~
>
> This rather makes me think a basic not isn't supported here? But the old
> AST docs[1] suggests it should be, so I am guessing some support is
> missing in PQL here?
>

flaf on IRC said to try this:

inventory[certname] {!(facts.os.distro.release.major = "7")}

This works, still to figure out string compares :)

> I'd also like to be able to do > etc on string values, which I think the
> AST based queries also support?
>
>
> [1]
> https://docs.puppet.com/puppetdb/5.0/api/query/v4/ast.html#dot-notation
>
> --
> R.I.Pienaar / www.devco.net / @ripienaar
>
> --
> 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/1502382772.1240443.1069431136.3BC482C6%40webmail.messagingengine.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages