init.sls 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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:
  14. - salt://network/ifupdown2.conf.{{ grains['oscodename'] }}
  15. - salt://network/ifupdown2.conf
  16. - require:
  17. - pkg: ifupdown2
  18. - pkg: python-ipcalc
  19. # Write network configuration
  20. /etc/network/interfaces:
  21. file.managed:
  22. - template: jinja
  23. - source: salt://network/interfaces/interfaces.tmpl
  24. - require:
  25. - pkg: ifupdown2
  26. # Reload interface configuration if neccessary
  27. ifreload:
  28. cmd.wait:
  29. - name: /sbin/ifreload -a
  30. - watch:
  31. - file: /etc/network/interfaces
  32. - require:
  33. - file: /etc/network/ifupdown2/ifupdown2.conf
  34. # If there is an interface in vrf_external, install a workaround script
  35. # for a bug in ifupdown2 which will sometimes drop an IPv4 default route
  36. # present in the kernel and not reinstall it.
  37. #
  38. # The fix script will be called every minute by cron and after ifreload
  39. # was called to try to minimize any downtime.
  40. {% set vrf = [False] %}
  41. {% for iface, iface_config in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':ifaces', {}).items() %}
  42. {% if iface_config.get ('vrf', '') == 'vrf_external' %}
  43. {% do vrf.append(True) %}
  44. {% break %}
  45. {% endif %}
  46. {% endfor %}
  47. /usr/local/sbin/ff_fix_default_route:
  48. {% if True in vrf %}
  49. file.managed:
  50. - source: salt://network/interfaces/ff_fix_default_route
  51. - mode: 755
  52. cmd.wait:
  53. - require:
  54. - cmd: ifreload
  55. - file: /usr/local/sbin/ff_fix_default_route
  56. - watch:
  57. - file: /etc/network/interfaces
  58. {% else %}
  59. file.absent
  60. {% endif %}
  61. /etc/cron.d/ff_fix_default_route:
  62. {% if True in vrf %}
  63. file.managed:
  64. - source: salt://network/interfaces/ff_fix_default_route.cron
  65. - template: jinja
  66. {% else %}
  67. file.absent
  68. {% endif %}