---

# ansible_slackware_bootstrap
#
# File: slackware-mailinstall.yaml
# Version 1.0
# Copyright Joey Kelly (joeykelly.net)
# March 9, 2016
# License: GPL version 2
#
# https://github.com/mmlj4/ansible_slackware_bootstrap


# we need to build packages for our mail stack

- hosts: '{{ hosts }}'
  remote_user: root
  tasks:

    # first we have to set up our users and groups
    - group:  name=postfix    gid=200 state=present
    - group:  name=postdrop   gid=201 state=present
    - group:  name=clamav     gid=210 state=present
    - group:  name=amavis     gid=225 state=present
    - group:  name=dovecot    gid=202 state=present
    - group:  name=dovenull   gid=248 state=present
    - user:   name=postfix    uid=200 group=postfix   home=/dev/null        shell=/bin/false
    - user:   name=clamav     uid=210 group=clamav    home=/dev/null        shell=/bin/false
    - user:   name=amavis     uid=225 group=amavis    home=/var/lib/amavis  shell=/bin/bash
    - user:   name=dovecot    uid=202 group=postfix   home=/dev/null        shell=/bin/false
    - user:   name=dovenull   uid=248 group=postfix   home=/dev/null        shell=/bin/false


    # now we can run our sbotools commands

    # postfix would be clobbered upon sendmail update
    # NOTE: the slackpkg module is an ansible 2.0 addition; we're stuck with 1.7.x
    #- slackpkg: name=sendmail,sendmail-cf state=absent
    - shell: echo Y | slackpkg -dialog=off -default_answer=y -spinning=off -postinst=off remove sendmail
    - shell: echo Y | slackpkg -dialog=off -default_answer=y -spinning=off -postinst=off remove sendmail-cf
    # we need to blacklist these
    - shell: perl -e '$blacklistentry = "sendmail";     print "$blacklistentry\n" unless `grep "^$blacklistentry\$" /etc/slackpkg/blacklist`' >> /etc/slackpkg/blacklist
    - shell: perl -e '$blacklistentry = "sendmail-cf";  print "$blacklistentry\n" unless `grep "^$blacklistentry\$" /etc/slackpkg/blacklist`' >> /etc/slackpkg/blacklist

    # these few CPAN modules aren't specified, but amavisd and others will fail to run without them
    - command: sboinstall -r perl-MIME-tools
    - command: sboinstall -r perl-Unix-Syslog
    - command: sboinstall -r perl-Archive-Zip
    - command: sboinstall -r perl-Crypt-OpenSSL-Random
    - command: sboinstall -r perl-Crypt-OpenSSL-RSA
    - command: sboinstall -r perl-TimeDate
    - command: sboinstall -r perl-MailTools
    - command: sboinstall -r perl-Mail-DKIM
    - command: sboinstall -r perl-Net-LibIDN
    - command: sboinstall -r perl-IO-stringy
    - command: sboinstall -r perl-Convert-BinHex
    - command: sboinstall -r perl-file-mimeinfo
    - command: sboinstall -r perl-MIME-Lite
    - command: sboinstall -r perl-extutils-makemaker
    - command: sboinstall -r perl-IPC-Run3
    - command: sboinstall -r perl-Probe-Perl
    - command: sboinstall -r perl-Test-Script
    - command: sboinstall -r perl-File-Which
    - command: sboinstall -r perl-CPAN-Meta-YAML
    - command: sboinstall -r perl-Parse-CPAN-Meta
    - command: sboinstall -r perl-CPAN-Meta
    - command: sboinstall -r perl-PAR-Dist
    - command: sboinstall -r perl-Module-Build
    - command: sboinstall -r perl-IPC-System-Simple
    - command: sboinstall -r perl-file-basedir
    - command: sboinstall -r perl-file-desktopentry
    - command: sboinstall -r perl-file-mimeinfo
    - command: sboinstall -r perl-Capture-Tiny
    - command: sboinstall -r perl-Email-Date-Format
    - command: sboinstall -r perl-MIME-Lite

    # spamassassin
    - command: sboinstall -r GeoIP
    - command: sboinstall -r perl-Geo-IP
    - command: sboinstall -r perl-Net-CIDR-Lite
    - command: sboinstall -r perl-Socket6
    - command: sboinstall -r perl-Net-Patricia
    - command: sboinstall -r razor-agents
    - command: sboinstall -r perl-IO-Socket-IP
    - command: sboinstall -r perl-http-date
    - command: sboinstall -r perl-file-listing
    - command: sboinstall -r perl-encode-locale
    - command: sboinstall -r perl-html-tagset
    - command: sboinstall -r perl-html-parser
    - command: sboinstall -r perl-lwp-mediatypes
    - command: sboinstall -r perl-IO-HTML
    - command: sboinstall -r perl-http-message
    - command: sboinstall -r perl-http-cookies
    - command: sboinstall -r perl-http-daemon
    - command: sboinstall -r perl-http-negotiate
    - command: sboinstall -r perl-net-http
    - command: sboinstall -r perl-www-robotrules
    - command: sboinstall -r libwww-perl
    - command: sboinstall -r perl-Crypt-OpenSSL-Bignum
    - command: sboinstall -r perl-Encode-Detect
    - command: sboinstall -r perl-IO-Socket-INET6
    - command: sboinstall -r Net-SSLeay
    - command: sboinstall -r perl-IO-Socket-SSL
    - command: sboinstall -r perl-Geography-Countries
    - command: sboinstall -r perl-IP-Country
    - command: sboinstall -r perl-Image-Info
    - command: sboinstall -r perl-Net-DNS-Resolver-Programmable
    - command: sboinstall -r perl-NetAddr-IP
    - command: sboinstall -r perl-Mail-SPF
    - command: sboinstall -r perl-Net-Ident
    - command: sboinstall -r pyzor
    - command: sboinstall -r re2c
    - command: echo "the administrator of that system" | sboinstall -r spamassassin

    # our email stack and found prerequisites
    - command: sboinstall -r perl-Net-Server
    - command: sboinstall -r perl-IO-Multiplex
    - command: sboinstall -r perl-BerkeleyDB
    - command: sboinstall -r perl-digest-sha1
    - command: sboinstall -r perl-digest-hmac
    - command: sboinstall -r perl-net-ip
    - command: sboinstall -r perl-net-dns
    - command: sboinstall -r clamav
    - command: sboinstall -r amavisd-new
    - command: sboinstall -r dovecot
    - command: sboinstall -r postgrey
    - command: sboinstall -r postfix

