How to get a list of all salt minions in a template?

前端 未结 3 1208
小蘑菇
小蘑菇 2020-12-13 20:55

Basically I am creating a Salt state describing Munin server configuration and I need to get a list of all minions known to the master, something like this:

         


        
3条回答
  •  失恋的感觉
    2020-12-13 21:34

    Why not use minion.list module?

    In our pillar environment we have pillar that are private to each minion (/srv/pillar/hosts/[server_A, server_B, server_C...]/some_pillar.sls).

    To make things easier (since some people keep forgetting to add new pillars to the top file) our pillar top file looks like this:

    {{ saltenv }}:
      {% for minion in salt['minion.list']()['minions'] -%}
      {{ minion + '*' }}:
        - hosts.{{ minion.split('.')[0] }}
      {% endfor -%}
    

    This way I can get a list of all minions known to the master every time the pillar enviorment is updated.

提交回复
热议问题