init.sls 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. - file: /usr/local/sbin/ff_fix_default_route
  54. - watch:
  55. - file: /etc/network/interfaces
  56. {% else %}
  57. file.absent
  58. {% endif %}
  59. /etc/cron.d/ff_fix_default_route:
  60. {% if True in vrf %}
  61. file.managed:
  62. - source: salt://network/interfaces/ff_fix_default_route.cron
  63. {% else %}
  64. file.absent
  65. {% endif %}