Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It appears "*" GJSON wildcard is not working as expected #1506

Open
mdechiaro opened this issue Nov 5, 2021 · 1 comment
Open

It appears "*" GJSON wildcard is not working as expected #1506

mdechiaro opened this issue Nov 5, 2021 · 1 comment

Comments

@mdechiaro
Copy link

It appears "*" GJSON wildcard is not working as expected. It doesn't to traverse past the first key
the networking.interfaces Puppet fact.

Example from the documentation on compound filters

choria discover -S 'include(fact("networking.interfaces.*.bindings.#.network"), "10.0.2.0")'

Consider the following Puppet fact (hash was shortened for brevity):

{
  "networking": {
    "domain": "domain.com",
    "fqdn": "hostname.domain.com",
    "hostname": "hostname",
    "interfaces": {
      "ens224": {
        "bindings": [
          {
            "address": "10.50.36.210",
            "netmask": "255.255.255.0",
            "network": "10.50.36.0"
          }
        ],
        "ip": "10.50.36.210",
        "netmask": "255.255.255.0",
        "network": "10.50.36.0",
      },
      "ens256": {
        "bindings": [
          {
            "address": "10.50.0.73",
            "netmask": "255.255.254.0",
            "network": "10.50.0.0"
          }
        ],
        "dhcp": "10.50.0.1",
        "ip": "10.50.0.73",
        "netmask": "255.255.254.0",
        "network": "10.50.0.0",
      },
    },
    "ip": "10.50.36.210",
    "netmask": "255.255.255.0",
    "network": "10.50.36.0",
  }
}

If I try this example on one of my puppet nodes, "*" does not work as expected. It can find the address in the first interface, but not the second:

choria discover -S 'include(fact("networking.interfaces.*.bindings.#.address"), "10.50.36.210")' | wc -l
1

choria discover -S 'include(fact("networking.interfaces.*.bindings.#.address"), "10.50.0.73")' | wc -l
0

Currently using version 0.23.0

@ripienaar
Copy link
Member

Yeah that does unfortunately seem to be the case, I tried a few things and cannot come up with an example that can actually work.

I might need to add a function something like:

extract_key("networking.interfaces", "bindings")

That then turns the bindings into a more simple array and it can be used that way, but not sure tbh, nightmare structure. I had some functions to dig into this specific structure before but a bit hessitant to put them into choria core and so have a facter structure dependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants