Browse Source

snmpd: Read nms_list from pillar instead of using static IPs.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Maximilian Wilhelm 5 years ago
parent
commit
78bf9dadd3
1 changed files with 16 additions and 10 deletions
  1. 16 10
      snmpd/snmpd.conf

+ 16 - 10
snmpd/snmpd.conf

@@ -2,10 +2,16 @@
 {%- set ro_community = salt['pillar.get'] ('globals:snmp:ro_community', "Configure globals:snmp:ro_community in pillar...") %}
 {%- set sys_contact = salt['pillar.get'] ('globals:ops_mail', "Configure globals:ops_mail in pillar...") %}
 {%- set sys_location = node_config.get ('sysLocation', "Please fix sysLocation...") %}
+{%- set nms_list = salt['pillar.get'] ('globals:snmp:nms_list', []) %}
+
 #
 # /etc/snmp/snmpd.conf (Salt managed)
 #
 
+sysLocation	{{ sys_location }}
+sysContact	{{ sys_contact }}
+sysServices	72
+
 # Listen for connections from the local system
 agentAddress  udp:127.0.0.1:161
 agentAddress  udp6:[::1]:161
@@ -14,16 +20,16 @@ agentAddress  udp6:[::1]:161
 agentAddress  udp:{{ salt['ffho_net.get_loopback_ip'] (node_config, grains['id'], 'v4') }}:161
 agentAddress  udp6:[{{ salt['ffho_net.get_loopback_ip'] (node_config, grains['id'], 'v6') }}]:161
 
-
-rocommunity   {{ ro_community }}	127.0.0.1
-rocommunity   {{ ro_community }}	10.132.251.161
-rocommunity6 {{ ro_community }}	::1
-rocommunity6 {{ ro_community }}	fdca:ffee:ff12:a251::161
-rocommunity6 {{ ro_community }}	2a03:2260:2342:a251::161
-
-sysLocation    {{ sys_location }}
-sysContact     {{ sys_contact }}
-sysServices    72
+# We accept requests from those fine boxes
+rocommunity	{{ ro_community }}	127.0.0.1
+rocommunity6	{{ ro_community }}	::1
+{%- for entry in nms_list %}
+  {%- if ':' in entry %}
+rocommunity6	{{ ro_community }}	{{ entry }}
+  {%- else %}
+rocommunity	{{ ro_community }}	{{ entry }}
+  {%- endif %}
+{%- endfor %}
 
 #
 # Network interfaces