reload.sls 1.3 KB

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