init.sls 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #
  2. # Postfix
  3. #
  4. # Make sure 'mail' is present
  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.H_{{ grains['id'] }}
  22. - salt://postfix/master.cf.{{ grains.os }}.{{ grains.oscodename }}
  23. - salt://postfix/master.cf
  24. - watch_in:
  25. - service: postfix
  26. /etc/postfix/main.cf:
  27. file.managed:
  28. - source:
  29. - salt://postfix/main.cf.H_{{ grains['id'] }}
  30. - salt://postfix/main.cf.{{ grains.os }}.{{ grains.oscodename }}
  31. - salt://postfix/main.cf
  32. - template: jinja
  33. - watch_in:
  34. - service: postfix
  35. #
  36. # Send root mail to pillar <globals:ops_mail>
  37. /etc/aliases:
  38. file.managed:
  39. - source:
  40. - salt://postfix/aliases.H_{{ grains['id'] }}
  41. - salt://postfix/aliases
  42. - template: jinja
  43. - context:
  44. root_mail_address: {{ salt['pillar.get']('globals:ops_mail') }}
  45. newaliases:
  46. cmd.wait:
  47. - name: /usr/bin/newaliases
  48. - watch:
  49. - file: /etc/aliases
  50. # Set mailname to node_id if not specified otherwise in node pillar.
  51. {% set mailname = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':mailname', grains['id']) %}
  52. /etc/mailname:
  53. file.managed:
  54. - contents: "{{ mailname }}"
  55. #
  56. # Manage virtual domains and aliases on MX nodes
  57. #
  58. {% if 'mx' in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  59. /etc/postfix/virtual-domains:
  60. file.managed:
  61. - source: salt://postfix/virtual-domains
  62. postmap_domains:
  63. cmd.wait:
  64. - name: /usr/sbin/postmap /etc/postfix/virtual-domains
  65. - watch:
  66. - file: /etc/postfix/virtual-domains
  67. /etc/postfix/virtual-aliases:
  68. file.managed:
  69. - source: salt://postfix/virtual-aliases
  70. postmap_aliases:
  71. cmd.wait:
  72. - name: /usr/sbin/postmap /etc/postfix/virtual-aliases
  73. - watch:
  74. - file: /etc/postfix/virtual-aliases
  75. /etc/postfix/mynetworks:
  76. file.managed:
  77. - source: salt://postfix/mynetworks
  78. {% endif %}