From 70dfaa68abb4fcc457527f4feaf795999c5ccce4 Mon Sep 17 00:00:00 2001 From: Paul Walko Date: Mon, 2 Dec 2019 22:06:59 -0500 Subject: [PATCH] add zfs-zed notifications --- ansible/files/bigdummy-main.cf | 55 ++++++++++++++++ ansible/files/zed.rc | 113 +++++++++++++++++++++++++++++++++ ansible/handlers.yml | 10 +++ ansible/main.yml | 37 +++++++++-- 4 files changed, 208 insertions(+), 7 deletions(-) create mode 100644 ansible/files/bigdummy-main.cf create mode 100644 ansible/files/zed.rc diff --git a/ansible/files/bigdummy-main.cf b/ansible/files/bigdummy-main.cf new file mode 100644 index 0000000..802e611 --- /dev/null +++ b/ansible/files/bigdummy-main.cf @@ -0,0 +1,55 @@ +# See /usr/share/postfix/main.cf.dist for a commented, more complete version + + +# Debian specific: Specifying a file name will cause the first +# line of that file to be used as the name. The Debian default +# is /etc/mailname. +#myorigin = /etc/mailname + +smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) +biff = no + +# appending .domain is the MUA's job. +append_dot_mydomain = no + +# Uncomment the next line to generate "delayed mail" warnings +#delay_warning_time = 4h + +readme_directory = no + +# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on +# fresh installs. +compatibility_level = 2 + + + +# TLS parameters +smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem +smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key +smtpd_use_tls=yes +smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache +smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache + +# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for +# information on enabling SSL in the smtp client. + +smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination +myhostname = bigdummy.seaturtle.pw +alias_maps = hash:/etc/aliases +alias_database = hash:/etc/aliases +myorigin = /etc/mailname +mydestination = $myhostname, bigdummy.seaturtle.pw, localhost.seaturtle.pw, , localhost +relayhost = [smtp.gmail.com]:587 +mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 +mailbox_size_limit = 0 +recipient_delimiter = + +inet_interfaces = all +inet_protocols = all + +# added configs +# http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html +smtp_use_tls = yes +smtp_sasl_auth_enable = yes +smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd +smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt +smtp_sasl_security_options = diff --git a/ansible/files/zed.rc b/ansible/files/zed.rc new file mode 100644 index 0000000..69e6a90 --- /dev/null +++ b/ansible/files/zed.rc @@ -0,0 +1,113 @@ +## +# zed.rc +# +# This file should be owned by root and permissioned 0600. +## + +## +# Absolute path to the debug output file. +# +#ZED_DEBUG_LOG="/tmp/zed.debug.log" + +## +# Email address of the zpool administrator for receipt of notifications; +# multiple addresses can be specified if they are delimited by whitespace. +# Email will only be sent if ZED_EMAIL_ADDR is defined. +# Disabled by default; uncomment to enable. +# +ZED_EMAIL_ADDR="alerts@seaturtle.pw" + +## +# Name or path of executable responsible for sending notifications via email; +# the mail program must be capable of reading a message body from stdin. +# Email will only be sent if ZED_EMAIL_ADDR is defined. +# +#ZED_EMAIL_PROG="mail" + +## +# Command-line options for ZED_EMAIL_PROG. +# The string @ADDRESS@ will be replaced with the recipient email address(es). +# The string @SUBJECT@ will be replaced with the notification subject; +# this should be protected with quotes to prevent word-splitting. +# Email will only be sent if ZED_EMAIL_ADDR is defined. +# +#ZED_EMAIL_OPTS="-s '@SUBJECT@' @ADDRESS@" + +## +# Default directory for zed lock files. +# +#ZED_LOCKDIR="/var/lock" + +## +# Minimum number of seconds between notifications for a similar event. +# +ZED_NOTIFY_INTERVAL_SECS=3600 + +## +# Notification verbosity. +# If set to 0, suppress notification if the pool is healthy. +# If set to 1, send notification regardless of pool health. +# +ZED_NOTIFY_VERBOSE=1 + +## +# Send notifications for 'ereport.fs.zfs.data' events. +# Disabled by default +# +#ZED_NOTIFY_DATA=1 + +## +# Pushbullet access token. +# This grants full access to your account -- protect it accordingly! +# +# +# Disabled by default; uncomment to enable. +# +#ZED_PUSHBULLET_ACCESS_TOKEN="" + +## +# Pushbullet channel tag for push notification feeds that can be subscribed to. +# +# If not defined, push notifications will instead be sent to all devices +# associated with the account specified by the access token. +# Disabled by default; uncomment to enable. +# +#ZED_PUSHBULLET_CHANNEL_TAG="" + +## +# Default directory for zed state files. +# +#ZED_RUNDIR="/var/run" + +## +# Turn on/off enclosure LEDs when drives get DEGRADED/FAULTED. This works for +# device mapper and multipath devices as well. Your enclosure must be +# supported by the Linux SES driver for this to work. +# +ZED_USE_ENCLOSURE_LEDS=1 + +## +# Run a scrub after every resilver +#ZED_SCRUB_AFTER_RESILVER=1 + +## +# The syslog priority (e.g., specified as a "facility.level" pair). +# +#ZED_SYSLOG_PRIORITY="daemon.notice" + +## +# The syslog tag for marking zed events. +# +#ZED_SYSLOG_TAG="zed" + +## +# Which set of event subclasses to log +# By default, events from all subclasses are logged. +# If ZED_SYSLOG_SUBCLASS_INCLUDE is set, only subclasses +# matching the pattern are logged. Use the pipe symbol (|) +# or shell wildcards (*, ?) to match multiple subclasses. +# Otherwise, if ZED_SYSLOG_SUBCLASS_EXCLUDE is set, the +# matching subclasses are excluded from logging. +#ZED_SYSLOG_SUBCLASS_INCLUDE="checksum|scrub_*|vdev.*" +#ZED_SYSLOG_SUBCLASS_EXCLUDE="statechange|config_*|history_event" + diff --git a/ansible/handlers.yml b/ansible/handlers.yml index 98cb448..a31e15d 100644 --- a/ansible/handlers.yml +++ b/ansible/handlers.yml @@ -4,6 +4,11 @@ name: chrony state: restarted +- name: Restart postfix + service: + name: postfix + state: restarted + - name: Restart sshd service service: name: sshd @@ -14,6 +19,11 @@ name: systemd-logind state: restarted +- name: Restart zfs-zed + service: + name: zfs-zed + state: restarted + - name: Enable weechat service service: name: weechat diff --git a/ansible/main.yml b/ansible/main.yml index 976f20c..5c3642e 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -134,18 +134,41 @@ handlers: - import_tasks: handlers.yml tasks: + - name: Install zfs-zed, postfix, nfs-kernel-server + apt: + name: + - nfs-kernel-server + - postfix + - zfs-zed + force_apt_get: yes + update_cache: yes + + - name: Configure postfix + copy: + src: files/bigdummy-main.cf + dest: /etc/postfix/main.cf + owner: root + group: root + mode: '0644' + notify: Restart postfix + + # Manually set postfix password + + - name: Configure zfs-zed + copy: + src: files/zed.rc + dest: /etc/zfs/zed.d/zed.rc + owner: root + group: root + mode: '0644' + notify: Restart zfs-zed + - name: Install rclone apt: deb: https://github.com/rclone/rclone/releases/download/v1.49.2/rclone-v1.49.2-linux-amd64.deb force_apt_get: yes - # Manually configure rclone - - - name: Install NFS server package - apt: - name: nfs-kernel-server - force_apt_get: yes - update_cache: yes + # Manually configure rclone remote drive - name: Export /bigdata copy: