puppetlabs/bolt

Provide get_groups function in apply block

Closed this issue · 3 comments

gucki commented

It seems there's no way to find out the parent groups of the current target (as defined in the inventory.yaml). That'd be really helpful information, for example how to lookup data in Hiera:

version: 5

hierarchy:
  - name: "Per-node data"
    path: "nodes/%{trusted.certname}.yaml"

  - name: "Per-groups data"
    mapped_paths: [groups, tmp, "groups/%{tmp}.yaml"]

  - name: "Per-OS defaults"
    path: "os/%{facts.os.family}.yaml"

  - name: "Common data"
    globs: ["common/**", "common.yaml"]

My current approach is to define them manually in my deploy plan, see #1765 (comment)

Having a $target.get_groups() function available in the apply block would solve this issue.

This issue has not had activity for 60 days and will be marked as stale.
If this issue continues to have no activity for 7 days, it will be closed.

This issue is stale and has been closed. If you believe this is in error,
or would like the Bolt team to reconsider it, please reopen the issue.

It would be even better to have all of a target's groups as a top level variable so it can be used in Hiera hierarchy as well.