Use http.query instead of nbroles module
All checks were successful
ci/lysergic/push/pipeline Pipeline was successful

This is an attempt to remove the need for the custom nbroles module. If
it works out, the localhost reference should be replaced with a global
roles API endpoint.

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

View File

@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# This rewrites top-files to fetch roles from grains instead of our custom roles API. Useful for testing outside of the LibertaCasa infrastructure, but not recommended for production. # This rewrites top-files to fetch roles from grains instead of our custom roles API. Useful for testing outside of the LibertaCasa infrastructure, but not recommended for production.
sed -i "s/salt\['nbroles.get'\](id)/grains\['roles'\]/" */top.sls sed -i "s/salt\['http.query'\].*/grains\['roles'\] -%}/" */top.sls

View File

@ -1,5 +1,5 @@
{%- set id = salt['grains.get']('id') -%} {%- set id = salt['grains.get']('id') -%}
{%- set roles = salt['nbroles.get'](id) -%} {%- set roles = salt['http.query']('http://127.0.0.1:5000/roles', decode=True, decode_type='json', params={"machine": id})['dict']['roles'] -%}
{{ saltenv }}: {{ saltenv }}:
'*': '*':
@ -7,6 +7,6 @@
'{{ id }}': '{{ id }}':
- ignore_missing: True - ignore_missing: True
- id.{{ id.replace('.', '_') }} - id.{{ id.replace('.', '_') }}
{% for role in roles %} {%- for role in roles %}
- role.{{ role }} - role.{{ role }}
{%- endfor %} {%- endfor %}

View File

@ -1,5 +1,5 @@
{%- set id = salt['grains.get']('id') -%} {%- set id = salt['grains.get']('id') -%}
{%- set roles = salt['nbroles.get'](id) -%} {%- set roles = salt['http.query']('http://127.0.0.1:5000/roles', decode=True, decode_type='json', params={"machine": id})['dict']['roles'] -%}
{{ saltenv }}: {{ saltenv }}:
'*': '*':