init.sls 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #
  2. # /etc/network/interfaces
  3. #
  4. ifupdown2:
  5. pkg.installed
  6. # Require for some functions of ffho_net module, so make sure they are present.
  7. # Used by functions for bird and dhcp-server for example.
  8. python-ipcalc:
  9. pkg.installed
  10. # ifupdown2 configuration
  11. /etc/network/ifupdown2/ifupdown2.conf:
  12. file.managed:
  13. - source: salt://network/ifupdown2.conf
  14. - require:
  15. - pkg: ifupdown2
  16. - pkg: python-ipcalc
  17. # Write network configuration
  18. /etc/network/interfaces:
  19. file.managed:
  20. - template: jinja
  21. - source: salt://network/interfaces/interfaces.tmpl
  22. - require:
  23. - pkg: ifupdown2
  24. # Reload interface configuration if neccessary
  25. ifreload:
  26. cmd.wait:
  27. - name: /sbin/ifreload -a
  28. - watch:
  29. - file: /etc/network/interfaces
  30. - require:
  31. - file: /etc/network/ifupdown2/ifupdown2.conf
  32. # If there is an interface in vrf_external, install a workaround script
  33. # for a bug in ifupdown2 which will sometimes drop an IPv4 default route
  34. # present in the kernel and not reinstall it.
  35. #
  36. # The fix script will be called every minute by cron and after ifreload
  37. # was called to try to minimize any downtime.
  38. {% set vrf = [False] %}
  39. {% for iface, iface_config in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':ifaces', {}).items() %}
  40. {% if iface_config.get ('vrf', '') == 'vrf_external' %}
  41. {% do vrf.append(True) %}
  42. {% break %}
  43. {% endif %}
  44. {% endfor %}
  45. /usr/local/sbin/ff_fix_default_route:
  46. {% if True in vrf %}
  47. file.managed:
  48. - source: salt://network/interfaces/ff_fix_default_route
  49. - mode: 755
  50. cmd.wait:
  51. - require:
  52. - cmd: ifreload
  53. - watch:
  54. - file: /etc/network/interfaces
  55. {% else %}
  56. file.absent
  57. {% endif %}
  58. /etc/cron.d/ff_fix_default_route:
  59. {% if True in vrf %}
  60. file.managed:
  61. - source: salt://network/interfaces/ff_fix_default_route.cron
  62. {% else %}
  63. file.absent
  64. {% endif %}