init.sls 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #
  2. # /etc/network/interfaces
  3. #
  4. include:
  5. - network.interfaces.base
  6. # Reload interface configuration if neccessary
  7. ifreload:
  8. cmd.wait:
  9. - name: /sbin/ifreload -a
  10. - watch:
  11. - file: /etc/network/interfaces
  12. - require:
  13. - file: /etc/network/ifupdown2/ifupdown2.conf
  14. # If there is an interface in vrf_external, install a workaround script
  15. # for a bug in ifupdown2 which will sometimes drop an IPv4 default route
  16. # present in the kernel and not reinstall it.
  17. #
  18. # The fix script will be called every minute by cron and after ifreload
  19. # was called to try to minimize any downtime.
  20. {% set vrf = [False] %}
  21. {% for iface, iface_config in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':ifaces', {}).items() %}
  22. {% if iface_config.get ('vrf', '') == 'vrf_external' %}
  23. {% do vrf.append(True) %}
  24. {% break %}
  25. {% endif %}
  26. {% endfor %}
  27. /usr/local/sbin/ff_fix_default_route:
  28. {% if True in vrf %}
  29. file.managed:
  30. - source: salt://network/interfaces/ff_fix_default_route
  31. - mode: 755
  32. cmd.wait:
  33. - require:
  34. - cmd: ifreload
  35. - file: /usr/local/sbin/ff_fix_default_route
  36. - watch:
  37. - file: /etc/network/interfaces
  38. {% else %}
  39. file.absent
  40. {% endif %}
  41. /etc/cron.d/ff_fix_default_route:
  42. {% if True in vrf %}
  43. file.managed:
  44. - source: salt://network/interfaces/ff_fix_default_route.cron
  45. - template: jinja
  46. {% else %}
  47. file.absent
  48. {% endif %}