Skip to content

Instantly share code, notes, and snippets.

@slumos
Created February 2, 2021 19:12
Show Gist options
  • Save slumos/d4ab6749af10ebaf8e15994073ca92d0 to your computer and use it in GitHub Desktop.
Save slumos/d4ab6749af10ebaf8e15994073ca92d0 to your computer and use it in GitHub Desktop.
puppet query groups.conf
[Main]
default: match
confdir: $CFGDIR/groups.d
autodir:
[env]
map: puppet query 'nodes[certname] { catalog_environment = "$GROUP" }' | jq -r '.[].certname'
list: puppet query 'environments {}' | jq -r .[].name
[cluster]
map: puppet query 'inventory[certname] { facts.cluster_name ~ "$GROUP" }' | jq -r .[].certname
list: puppet query 'facts[value] { name = "cluster_name" group by value }' | jq -r '.[].value'
[group]
map: cat $CFGDIR/group-$GROUP
list: ls -1 $CFGDIR/group-* | sed 's/.*group-//'
all: cat $CFGDIR/group-*
[match]
map: puppet query 'inventory[certname] { certname ~ "$GROUP"}' | jq -r '.[].certname'
list: echo certname-regex
[profile]
map: puppet query 'resources[certname] { type = "Class" and title ~ "(?i)^profile::$GROUP" }' | jq -r .[].certname
list: puppet query 'resources[title] { type = "Class" and title ~ "^Profile::" group by title }' | jq -r .[].title | sed 's/^Profile:://'
[role]
map: puppet query 'resources[certname] { type = "Class" and title ~ "(?i)^Role::$GROUP" }' | jq -r .[].certname
list: puppet query 'resources[title] { type = "Class" and title ~ "^Role::" group by title }' | jq -r .[].title | sed 's/^Role:://'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment