init.sls 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 node_config = salt['pillar.get']('nodes:' ~ grains['id'], {}) %}
  39. {% set sites_config = salt['pillar.get']('sites', {}) %}
  40. {% set ifaces = salt['ffho_net.get_interface_config'](node_config, sites_config) %}
  41. {% if 'vrf_external' in ifaces %}
  42. /usr/local/sbin/ff_fix_default_route:
  43. file.managed:
  44. - source: salt://network/interfaces/ff_fix_default_route
  45. - mode: 755
  46. cmd.wait:
  47. - require:
  48. - cmd: ifreload
  49. - watch:
  50. - file: /etc/network/interfaces
  51. /etc/cron.d/ff_fix_default_route:
  52. file.managed:
  53. - source: salt://network/interfaces/ff_fix_default_route.cron
  54. {% else %}
  55. /usr/local/sbin/ff_fix_default_route:
  56. file.absent
  57. /etc/cron.d/ff_fix_default_route:
  58. file.absent
  59. {% endif %}