init.sls 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #
  2. # Postfix
  3. #
  4. # Force installation of bsd-mailx as it's not installed anymore in Debian Jessie..
  5. bsd-mailx:
  6. pkg.installed:
  7. - name: bsd-mailx
  8. postfix:
  9. pkg.installed:
  10. - name: postfix
  11. - require:
  12. - file: /etc/mailname
  13. service.running:
  14. - enable: true
  15. - reload: true
  16. #
  17. # Don't listen on port 25, by default, a unix socket is enough.
  18. /etc/postfix/master.cf:
  19. file.managed:
  20. - source:
  21. - salt://postfix/master.cf.{{ grains['id'] }}
  22. - salt://postfix/master.cf.{{ grains.oscodename }}
  23. - watch_in:
  24. - service: postfix
  25. /etc/postfix/main.cf:
  26. file.managed:
  27. - source:
  28. - salt://postfix/main.cf.{{ grains['id'] }}
  29. - salt://postfix/main.cf
  30. - template: jinja
  31. - watch_in:
  32. - service: postfix
  33. #
  34. # Send root mail to ops@ffho.net
  35. /etc/aliases:
  36. file.managed:
  37. - source:
  38. - salt://postfix/aliases.{{ grains['id'] }}
  39. - salt://postfix/aliases
  40. newaliases:
  41. cmd.wait:
  42. - name: /usr/bin/newaliases
  43. - watch:
  44. - file: /etc/aliases
  45. # Set mailname to node_id if not specified otherwise in node pillar.
  46. {% set mailname = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':mailname', grains['id']) %}
  47. /etc/mailname:
  48. file.managed:
  49. - contents: "{{ mailname }}"
  50. #
  51. # Manage virtual domains and aliases on MX nodes
  52. #
  53. {% if 'mx' in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  54. /etc/postfix/virtual-domains:
  55. file.managed:
  56. - source: salt://postfix/virtual-domains
  57. postmap_domains:
  58. cmd.wait:
  59. - name: /usr/sbin/postmap /etc/postfix/virtual-domains
  60. - watch:
  61. - file: /etc/postfix/virtual-domains
  62. /etc/postfix/virtual-aliases:
  63. file.managed:
  64. - source: salt://postfix/virtual-aliases
  65. postmap_aliases:
  66. cmd.wait:
  67. - name: /usr/sbin/postmap /etc/postfix/virtual-aliases
  68. - watch:
  69. - file: /etc/postfix/virtual-aliases
  70. /etc/postfix/mynetworks:
  71. file.managed:
  72. - source: salt://postfix/mynetworks
  73. {% endif %}