You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
5.7 KiB

9 years ago
9 years ago
9 years ago
  1. - name: Check vars
  2. fail: msg="Missing domain name for first Vdomain creation"
  3. when: domain is not defined
  4. - name: Install pwgen
  5. apt: pkg={{item}} state=installed update_cache=yes
  6. with_items: "{{ firstpkg }}"
  7. ignore_errors: no
  8. - name: Randomly generate a postfix database password
  9. shell: pwgen -y -B -s 80 1
  10. register: dbpassword
  11. - name: Install necessary packages for postfix standalone
  12. apt: pkg={{item}} state=installed update_cache=yes
  13. with_items: "{{ packages }}"
  14. ignore_errors: no
  15. - name: Downloading postfixadmin
  16. get_url: url=https://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-3.0.2/postfixadmin-3.0.2.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fpostfixadmin%2Ffiles%2F&ts=1489870165&use_mirror=netcologne validate_certs=no dest=/tmp/postfixadmin.tar.gz
  17. - name: Creation of the right folder
  18. file: path=/etc/postfixadmin/ state=directory mode=0755 recurse=yes
  19. - name: Untar the pfxadmin
  20. unarchive: src=/tmp/postfixadmin.tar.gz dest=/etc/postfixadmin/ copy=no
  21. - name: enable SASLAuthd on boot
  22. copy: src=etc-default-saslauthd dest=/etc/default/saslauthd
  23. notify: restart saslauthd
  24. - name: Adding facteur group and user
  25. shell: groupadd -g 3000 facteur
  26. ignore_errors: yes
  27. - name: Adding facteur group and user
  28. shell: useradd -d /home/facteur -m -u 3000 -g 3000 facteur
  29. ignore_errors: yes
  30. - name: Copy dynmap file
  31. copy: src=etc-postfix-dynmap.cf dest=/etc/postfix/dynmap.cf
  32. - name: creation of /sasl in postfixdir
  33. file: path=/etc/postfix/sasl state=directory
  34. - name: Copying file to directory previously created
  35. copy: src=etc-postfix-sasl-smtpd.conf dest=/etc/postfix/sasl/smtpd.conf
  36. notify: restart postfix
  37. - name: adduser postfix sasl
  38. shell: adduser postfix sasl
  39. notify: restart dovecot
  40. - name: Copy dovecot config files - dovecot.conf
  41. template: src=dovecot.conf dest=/etc/dovecot/ owner=root mode=655
  42. - name: Copy dovecot config files - dovecot-mysql.conf
  43. template: src=dovecot-mysql.conf dest=/etc/dovecot/ owner=root mode=655
  44. - name: Copy postfixadmin config files - dbconfig.inc.php pfxadmin
  45. template: src=dbconfig.inc.php dest=/etc/postfixadmin/ owner=root mode=655
  46. - name: Copy postfix config files - dynmaps
  47. template: src=dynamicmaps.cf dest=/etc/postfix/ owner=root mode=655
  48. - name: Copy postfix config files - main.cf
  49. template: src=main.cf dest=/etc/postfix/ owner=root mode=655
  50. - name: Copy postfix config files - master.cf
  51. template: src=master.cf dest=/etc/postfix/ owner=root mode=655
  52. - name: Copy postfix config files - relay_domains.cf
  53. template: src=mysql_relay_domains.cf dest=/etc/postfix/ owner=root mode=655
  54. - name: Copy postfix config files - valias_maps.cf
  55. template: src=mysql_virtual_alias_maps.cf dest=/etc/postfix/ owner=root mode=655
  56. - name: Copy postfix config files - vbox_domains.cf
  57. template: src=mysql_virtual_mailbox_domains.cf dest=/etc/postfix/ owner=root mode=655
  58. - name: Copy postfix config files vbox_maps.cf
  59. template: src=mysql_virtual_mailbox_maps.cf dest=/etc/postfix/ owner=root mode=655
  60. - name: Copy postfix config files - postfix-files
  61. template: src=postfix-files dest=/etc/postfix/ owner=root mode=655
  62. - name: Copy postfix config files - postfix-scripts
  63. template: src=postfix-script dest=/etc/postfix/ owner=root mode=655
  64. - name: Copy postfix config files - post-install
  65. template: src=post-install dest=/etc/postfix/ owner=root mode=655
  66. - name: Copy postfix config files - database script
  67. template: src=root-postfix.sql dest=/etc/postfix/ owner=root mode=655
  68. - name: Copy postfix config files - smtpd.conf
  69. template: src=smtpd.conf dest=/etc/postfix/sasl/smtpd.conf owner=root mode=655
  70. notify: restart postfix
  71. - name: Autosigned cert - openssl query
  72. command: openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=FR/ST=RA/L=Somewhere/O=Overtherainbow/CN={{ domain }}" -keyout /etc/ssl/mail.key -out /etc/ssl/mail.crt
  73. - name: Create database for postfix
  74. shell: mysql < /etc/postfix/root-postfix.sql
  75. - name: Config amavis - content_filter_mode
  76. copy: src=etc-amavis-conf.d-15-content_filter_mode dest=/etc/amavis/conf.d/15-content_filter_mode
  77. - name: Config amavis - userfile
  78. copy: src=etc-amavis-conf.d-50-user dest=/etc/amavis/conf.d/50-user
  79. - name: adding amavis to clamav group
  80. shell: usermod amavis -a -G clamav
  81. - name: Vice versa
  82. shell: usermod clamav -a -G amavis
  83. - name: setting right perms to amavis homedir
  84. shell: chmod g+rx /var/lib/amavis
  85. - name: Virus repository
  86. file: path=/var/spool/virusmails state=directory owner=amavis group=amavis
  87. - name: update Spam-Assassin - will fail if playbook is played twice
  88. shell: sa-update -D
  89. notify: restart amavis
  90. ignore_errors: yes
  91. - name: Config Spam-Assassin
  92. copy: src=etc-default-spamassassin dest=/etc/default/spamassassin
  93. notify: restart spamassassin
  94. - name: Config Postgrey
  95. template: src=etc-default-postgrey dest=/etc/default/postgrey
  96. notify: restart postgrey
  97. - name: Install postfixadmin from debian repos
  98. apt: pkg={{item}} state=installed update_cache=no install_recommends=yes
  99. with_items: "{{ postfixadmin }}"
  100. ignore_errors: no
  101. - name: Update old postfixadmin with new one
  102. shell: rsync -aP /etc/postfixadmin/postfixadmin-3.0.2/* /usr/share/postfixadmin/
  103. - name: Chowning to the rightful user
  104. shell: chown -R www-data. /usr/share/postfixadmin/
  105. notify: restart apache
  106. - name: Copy postfixadmin config files
  107. template: src=config.inc.php dest=/etc/postfixadmin/ owner=root mode=655
  108. - name: Also to usr share
  109. template: src=config.inc.php dest=/usr/share/postfixadmin/ owner=www-data mode=655
  110. - name: TODO
  111. debug: msg="Now go to http://{{ domain }}/postfixadmin and follow the instructions documentation is here http://sourceforge.net/p/postfixadmin/wiki/Home/"
  112. # vim: set textwidth=0 ft=yaml ts=2 sw=2 expandtab: