init.sls 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 pillar <globals:ops_mail>
  35. /etc/aliases:
  36. file.managed:
  37. - source:
  38. - salt://postfix/aliases.{{ grains['id'] }}
  39. - salt://postfix/aliases
  40. - template: jinja
  41. - context:
  42. root_mail_address: {{ salt['pillar.get']('globals:ops_mail') }}
  43. newaliases:
  44. cmd.wait:
  45. - name: /usr/bin/newaliases
  46. - watch:
  47. - file: /etc/aliases
  48. # Set mailname to node_id if not specified otherwise in node pillar.
  49. {% set mailname = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':mailname', grains['id']) %}
  50. /etc/mailname:
  51. file.managed:
  52. - contents: "{{ mailname }}"
  53. #
  54. # Manage virtual domains and aliases on MX nodes
  55. #
  56. {% if 'mx' in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  57. /etc/postfix/virtual-domains:
  58. file.managed:
  59. - source: salt://postfix/virtual-domains
  60. postmap_domains:
  61. cmd.wait:
  62. - name: /usr/sbin/postmap /etc/postfix/virtual-domains
  63. - watch:
  64. - file: /etc/postfix/virtual-domains
  65. /etc/postfix/virtual-aliases:
  66. file.managed:
  67. - source: salt://postfix/virtual-aliases
  68. postmap_aliases:
  69. cmd.wait:
  70. - name: /usr/sbin/postmap /etc/postfix/virtual-aliases
  71. - watch:
  72. - file: /etc/postfix/virtual-aliases
  73. /etc/postfix/mynetworks:
  74. file.managed:
  75. - source: salt://postfix/mynetworks
  76. {% endif %}