dynamic annotations

This commit is contained in:
m0duspwnens
2024-10-29 10:20:31 -04:00
parent 0c4426a55e
commit c64a05f2ff
5 changed files with 47 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
hostname:
network_mode:
ip4:
gw4:
dns4:
sarch4:
cpu:
memory:
disk:
copper:
sfp:

View File

@@ -1,9 +1,14 @@
hypervisor: hypervisor:
hosts: hosts:
defaultHost: defaultHost:
add_guest: add_searchnode:
description: Add a new guest to the hypervisor. description: Add a new searchnode to the hypervisor.
forcedType: "[]string" file: True
global: True
multiline: True
add_sensor:
description: Add a new sensor to the hypervisor.
file: True
global: True global: True
multiline: True multiline: True
guests: guests:

View File

@@ -1,5 +1,28 @@
{% from 'soc/dynamic_annotations/hypervisor/map.jinja' import HYPERVISORS %}
hypervisor_annotation: hypervisor_annotation:
file.managed: file.managed:
- name: /opt/so/saltstack/default/salt/hypervisor/soc_hypervisor.yaml - name: /opt/so/saltstack/default/salt/hypervisor/soc_hypervisor.yaml
- source: salt://soc/dynamic_annotations/hypervisor/soc_hypervisor.yaml.jinja - source: salt://soc/dynamic_annotations/hypervisor/soc_hypervisor.yaml.jinja
- template: jinja - template: jinja
- defaults:
HYPERVISORS: {{ HYPERVISORS }}
{% for role in HYPERVISORS %}
{% for hypervisor in HYPERVISORS[role].keys() %}
hypervisor_host_directory_{{hypervisor}}:
file.directory:
- name: /opt/so/saltstack/local/salt/hypervisor/hosts/{{hypervisor}}
- makedirs: True
add_searchnode_file_{{hypervisor}}:
file.managed:
- name: /opt/so/saltstack/local/salt/hypervisor/hosts/{{hypervisor}}/add_searchnode
- source: salt://soc/dynamic_annotations/hypervisor/add_node
add_sensor_file_{{hypervisor}}:
file.managed:
- name: /opt/so/saltstack/local/salt/hypervisor/hosts/{{hypervisor}}/add_sensor
- source: salt://soc/dynamic_annotations/hypervisor/add_node
{% endfor %}
{% endfor %}

View File

@@ -0,0 +1 @@
{% set HYPERVISORS = salt['pillar.get']('hypervisor:nodes', {}) %}

View File

@@ -1,12 +1,13 @@
{% import_yaml 'soc/dynamic_annotations/hypervisor/hypervisor.yaml' as ANNOTATION %} {% import_yaml 'soc/dynamic_annotations/hypervisor/hypervisor.yaml' as ANNOTATION %}
{% set HYPERVISORS = salt['pillar.get']('hypervisor:nodes', {}) %}
{% set TEMPLATE = ANNOTATION.hypervisor.hosts.pop('defaultHost') %} {% set TEMPLATE = ANNOTATION.hypervisor.hosts.pop('defaultHost') %}
{# remove defaultGuest so that it is not shown in Grid Configuration UI #} {# remove defaultGuest so that it is not shown in Grid Configuration UI #}
{% do TEMPLATE['guests'].pop('defaultGuest') %} {% do TEMPLATE['guests'].pop('defaultGuest') %}
{% for hypervisor in HYPERVISORS.hypervisor %} {% for role in HYPERVISORS %}
{% do ANNOTATION.hypervisor.hosts.update({hypervisor: TEMPLATE}) %} {% for hypervisor in HYPERVISORS[role].keys() %}
{% do ANNOTATION.hypervisor.hosts.update({hypervisor: TEMPLATE}) %}
{% endfor %}
{% endfor %} {% endfor %}
{{ ANNOTATION | yaml(False) }} {{ ANNOTATION | yaml(False) }}