diff --git a/defaults/main.yml b/defaults/main.yml index 043441f..f6d7236 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -42,6 +42,8 @@ spamassassin_db_allowed_hosts: - '{{ ansible_fqdn }}' spamassassin_enable_pyzor: True +# in seconds +spamassassin_pyzor_timeout: '60' spamassassin_use_bayes: False spamassassin_bayes_sql_db: '{{ spamassassin_db_user_config }}' spamassassin_use_bayes_autolearn: '0' diff --git a/tasks/spamassassin.yml b/tasks/spamassassin.yml index 1e7abf0..8238743 100644 --- a/tasks/spamassassin.yml +++ b/tasks/spamassassin.yml @@ -23,12 +23,15 @@ - name: Install pyzor from pip block: - name: Install the pyzor pip packages - pip: name={{ spamassassin_pyzor_pip_packages }} state=latest + pip: name={{ spamassassin_pyzor_pip_packages }} state=present - name: Create the pyzor home file: dest={{ spamassassin_conf_dir }}/pyzor state=directory owner={{ spamassassin_user }} mode=0750 - when: spamassassin_enable_pyzor | bool + - name: Install the pyzor configuration + template: src=pyzor-config.j2 dest={{ spamassassin_conf_dir }}/pyzor/config owner=root group={{ spamassassin_user }} mode=0440 + + when: spamassassin_enable_pyzor tags: [ 'spamassassin', 'pyzor', 'spamassassin_conf' ] - name: Manage the letsencrypt configuration diff --git a/templates/pyzor-config.j2 b/templates/pyzor-config.j2 new file mode 100644 index 0000000..f94ee48 --- /dev/null +++ b/templates/pyzor-config.j2 @@ -0,0 +1,97 @@ +## Note that the options that require a file name, must not contain absolute +## paths. They are relative to the specified --homedir, which is {{ spamassassin_conf_dir }}/pyzor + +## All of these options are overridable from the respective command-line +## arguments. + +## The client section only affects the pyzor client. + +[client] +## The `ServersFile` must contain a newline-separated list of server +## addresses to report/whitelist/check with. +ServersFile = servers + +## The `AccountsFile` file containing information about accounts on servers. +# AccountsFile = accounts + +## This option specifies the name of the log file. +# LogFile = + +## The `LocaWhitelist` file containing skipped digests. +# LocalWhitelist = whitelist + +## This options specifies the number of seconds that the pyzor client should +## wait for a response from the server before timing out. +Timeout = {{ spamassassin_pyzor_timeout }} + +## This options specifies the input style of the pyzor client. Current options +## are: +## - msg (individual RFC5321 message) +## - mbox (mbox file of messages) +## - digests (Pyzor digests, one per line) +Style = msg + +## Thes options specify the threshold for number of reports/whitelists. +## According to these thresholds the pyzor client exit code will differ. +# ReportThreshold = 0 +# WhitelistThreshold = 0 + +## The server section only affects the pyzord server. + +[server] +## Specifes the port and interface to listen on. +# Port = 24441 +# ListenAddress = 0.0.0.0 + +## This option specifies the name of the log file. +# LogFile = +## This option specifies the name of the usage log file. +# UsageLogFile = + +## This file will contain the PID of the pyzord daemon, when the it's +## started with the --detach options. The file is removed when the daemon is +## closed +# PidFile = pyzord.pid + +## This file must contain the username and their keys +# PasswdFile = pyzord.passwd + +## This file defines the ACL for the users +# AccessFile = pyzord.access + +## If set to True then use the gevent library. +# Gevent = False + +## These settings define the storage engine that the pyzord server should use. + +## Example for gdbm (default): +# Engine = gdbm +# DigestDB = pyzord.db + +## Example for mysql: +# Engine = mysql +# DigestDB = localhost,user,passwd,pyzor_db,pyzor_table + +## Example for redis: +# Engine = redis +# DigestDB = localhost,6379,,0 +## Or if a password is required +# DigestDB = localhost,6379,passwd,0 + +## The maximum age of an record, after which it will be removed. +## To disable this set this to 0. +# CleanupAge = 10368000 # aprox 4 months + + +## These setting define how and if the pyzord server should use concurrency +## For pre-forking +# PreFork = 0 # disabled + +## For multi-threading: +# Threads = False +# MaxThreads = 0 # unlimited +# DBConnections = 0 # new connection for each request + +## For multi-processing: +# Processes = False +# MaxProcesses = 40 diff --git a/templates/spamassassin-local.cf.j2 b/templates/spamassassin-local.cf.j2 index da34d63..d40b0a2 100644 --- a/templates/spamassassin-local.cf.j2 +++ b/templates/spamassassin-local.cf.j2 @@ -24,5 +24,9 @@ skip_rbl_checks 1 dns_query_restriction deny {{ rbl }} {% endfor %} {% if spamassassin_enable_pyzor %} +use_pyzor 1 +pyzor_timeout {{ spamassassin_pyzor_timeout }}s pyzor_options --homedir {{ spamassassin_conf_dir }}/pyzor +{% else %} +use_pyzor 0 {% endif %}