Переглянути джерело

Use IPs from pillar instead of grains.

  Using IPs from grains breaks this state on first run as the IPs which just
  have been configured via the network state aren't reflected within grains
  in the same Salt run. Doh.

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
Maximilian Wilhelm 7 роки тому
батько
коміт
31a4095f34
1 змінених файлів з 8 додано та 8 видалено
  1. 8 8
      snmpd/snmpd.conf

+ 8 - 8
snmpd/snmpd.conf

@@ -1,5 +1,6 @@
 {%- import "globals.sls" as globals with context %}
 {%- set ro_community = salt['pillar.get'] ('ffho:snmp:ro_community', "Configure ffho:snmp:ro_community in pillar...") %}
+{%- set sys_location = salt['pillar.get'] ('nodes:' ~ grains['id'] ~ ':sysLocation', "Please fix sysLocation...") %}
 #
 # /etc/snmp/snmpd.conf (Salt managed)
 #
@@ -9,14 +10,12 @@ agentAddress  udp:127.0.0.1:161
 agentAddress  udp6:[::1]:161
 
 # Listen for connections on Loopback-IPs
-{%- for ipv4 in grains['ipv4'] %}
-  {%- if ipv4.startswith ('10.132.255.') %}
-agentAddress  udp:{{ ipv4 }}:161
+{%- for ip in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':ifaces:lo:prefixes', []) %}
+  {%- if ip.startswith ('10.132.255.') %}
+agentAddress  udp:{{ ip.split ('/')[0] }}:161
   {%- endif %}
-{%- endfor %}
-{%- for ipv6 in grains['ipv6'] %}
-  {%- if ipv6.startswith ('2a03:2260:2342:ffff:') or ipv6.startswith ('fdca:ffee:ff12:ffff:') %}
-agentAddress  udp6:[{{ ipv6 }}]:161
+  {%- if ip.startswith ('2a03:2260:2342:ffff::') %}
+agentAddress  udp6:[{{ ip.split ('/')[0] }}]:161
   {%- endif %}
 {%- endfor %}
 
@@ -25,8 +24,9 @@ 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    {{ globals.SYS_LOCATION }}
+sysLocation    {{ sys_location }}
 sysContact     ops@ffho.net
 sysServices    72