From d1460ae01fd5eed2c2418f47c89298faba5c65fa Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 24 Jan 2023 17:05:40 -0500 Subject: [PATCH] add node_data.ips pillar. grab influx host ip for soc extra_hosts --- pillar/node_data/ips.sls | 10 ++++------ pillar/top.sls | 1 + salt/soc/init.sls | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pillar/node_data/ips.sls b/pillar/node_data/ips.sls index 233038e66..59c598879 100644 --- a/pillar/node_data/ips.sls +++ b/pillar/node_data/ips.sls @@ -1,7 +1,5 @@ {% set node_types = {} %} {% set manage_alived = salt.saltutil.runner('manage.alived', show_ip=True) %} -{% set manager = grains.master %} -{% set manager_type = manager.split('_')|last %} {% for minionid, ip in salt.saltutil.runner('mine.get', tgt='*', fun='network.ip_addrs', tgt_type='glob') | dictsort() %} {% set hostname = minionid.split('_')[0] %} {% set node_type = minionid.split('_')[1] %} @@ -24,10 +22,10 @@ node_data: {% for node_type, host_values in node_types.items() %} - {{node_type}}: {% for hostname, details in host_values.items() %} - {{hostname}}: - ip: {{details.ip}} - alive: {{ details.alive }} + {{hostname}}: + ip: {{details.ip}} + alive: {{ details.alive }} + role: {{node_type}} {% endfor %} {% endfor %} diff --git a/pillar/top.sls b/pillar/top.sls index 074a0a9d4..d24b6980f 100644 --- a/pillar/top.sls +++ b/pillar/top.sls @@ -10,6 +10,7 @@ base: - sensoroni.adv_sensoroni - telegraf.soc_telegraf - telegraf.adv_telegraf + - node_data.ips '* and not *_eval and not *_import': - logstash.nodes diff --git a/salt/soc/init.sls b/salt/soc/init.sls index 40cb4487d..65cae16e6 100644 --- a/salt/soc/init.sls +++ b/salt/soc/init.sls @@ -110,8 +110,9 @@ so-soc: - /opt/so/conf/soc/soc_users_roles:/opt/sensoroni/rbac/users_roles:rw - /opt/so/conf/soc/salt:/opt/sensoroni/salt:rw - /opt/so/saltstack:/opt/so/saltstack:rw - {%- if salt['pillar.get']('nodestab', {}) %} - extra_hosts: + - {{GLOBALS.influxdb_host}}:{{pillar.node_data[GLOBALS.influxdb_host].ip}} + {%- if salt['pillar.get']('nodestab', {}) %} {%- for SN, SNDATA in salt['pillar.get']('nodestab', {}).items() %} - {{ SN.split('_')|first }}:{{ SNDATA.ip }} {%- endfor %}