init.sls 2.1 KB

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