Use nbroles instead of grains

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2023-01-21 01:00:22 +01:00
parent 2181a4999f
commit bf0dfeb941
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57
3 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,5 @@
{% set roles = salt['grains.get']('roles', []) %} {%- set id = salt['grains.get']('id') -%}
{% set id = salt['grains.get']('id') %} {%- set roles = salt['nbroles.get'](id) -%}
{{ saltenv }}: {{ saltenv }}:
'*': '*':

12
salt/_modules/nbroles.py Normal file
View File

@ -0,0 +1,12 @@
#to-do: tidy this up, make host configurable
import requests
host = 'http://127.0.0.1:5000/roles?machine='
def get(name):
req = requests.get(host + name)
if req.status_code == 404:
return([])
if req.status_code == 200:
return(req.json()['roles'])

View File

@ -1,5 +1,5 @@
{% set client_id = salt['grains.get']('id') %} {%- set id = salt['grains.get']('id') -%}
{% set roles = salt['grains.get']('roles', []) %} {%- set roles = salt['nbroles.get'](id) -%}
{{ saltenv }}: {{ saltenv }}:
'*': '*':