Hi
I need to be able to filter consul-template query to filter out nodes by their OS. ie. “os=windows”
Is this technically possible with consul-template?
I can add a node-meta tag of os=windows to the consul node but cannot find a filter for node-meta.
consul agent -config-dir /etc/consul.d/ -node-meta "os:windows"
Thanks
Chris
eikenb
2
Hey Chris,
I think you can do what you want with the .Meta information included with the nodes.
Assuming your agents are started with -node-meta "os:windows"
, then this template shows one way you filter them like you want.
{{ range nodes }}
{{ if eq .Meta.os "windows" }}I'm a windows box!{{ end }}
{{ end }}
There are other ways to do this, but the key here is the -node-meta
data is added the the .Meta
map in the returned data.
Hope this helps.