added msmtp as sendmail

This commit is contained in:
Jens Heinrich 2019-05-24 09:06:52 +02:00
parent e650f91311
commit e776a3dc0d
4 changed files with 159 additions and 0 deletions

View file

@ -35,3 +35,8 @@
loop:
- sdpd
- hpsecd
- name: new aliases
become: true
command: newaliases

View file

@ -0,0 +1,115 @@
---
- include_vars: msmtp-as-sendmail.yml
- name: install msmtp
package:
name: "{{ msmtp_package }}"
state: present
become: true
tags:
- installation
- name: create systemwide msmtp config
template:
dest: "{{ msmtprc }}"
src: "../mutt/templates/msmtprc.j2"
become: true
tags:
- configuration
- name: "set msmtp as mta"
lineinfile:
path: "{{ mailrc | default(/etc/mail.rc) }}"
regexp: "^{{ item.name }}"
line: "{{ item.name }}={{ item.val }}"
become: true
loop: "{{ sysctl_setting }}"
tags:
- configuration
vars:
sysctl_setting:
- name: "set mta"
val: "{{ msmtp_path }}"
- name: "set an adress for root"
lineinfile:
path: "{{ aliases | default(/etc/aliases) }}"
regexp: "^{{ item.name }}"
line: "{{ item.name }}: {{ item.val }}"
become: true
loop: "{{ sysctl_setting }}"
tags:
- configuration
vars:
sysctl_setting:
- name: "root"
val: "{{ root_mail }}"
- name: "default"
val: "root"
when: root_mail is defined
notify: new aliases
- name: "enable local_unbound"
lineinfile:
path: "/etc/rc.conf"
regexp: "^{{ item.name }}"
line: "{{ item.name }}={{ item.val }}"
become: true
loop: "{{ sysctl_setting }}"
tags:
- configuration
vars:
sysctl_setting:
- name: "local_unbound_enable"
val: "YES"
- name: "get opennic hints"
shell: "{{ hints_opennic_cmd }}"
become: true
tags:
- installation
- configuration
- name: "get named hints"
get_url:
url: "{{ hints_named_url }}"
dest: "{{ hints_named }}"
become: true
tags:
- installation
- configuration
- name: manage resolv.conf
template:
dest: /etc/resolv.conf
src: templates/resolv.conf.j2
become: true
tags:
- configuration
- name: "generate configs"
template:
src: "{{ config.src }}"
dest: "{{ config.dest }}"
become: true
loop: "{{ local_unbound_files }}"
loop_control:
loop_var: config
tags:
- configuration
notify: "restart local_unbound"
- name: "start local_unbound"
service:
name: "local_unbound"
state: started
become: true
tags:
- service
- configuration

View file

@ -0,0 +1,26 @@
{{ ansible_managed | comment }}
# https://dev.gentoo.org/~tomka/mail.html
# Set default values for all following accounts.
defaults
tls on
tls_certcheck off
#tls_trust_file /usr/home/jens/.dotfiles/mutt/importedcerts
logfile ~/.msmtp.log
syslog on
# uberspace_host
#
account uberspace_thinkpad
host mail.alioth.uberspace.de
from admin-host-{{ ansible_fqdn }}@927589452.de
user high5-thinkpad
port 587
tls_starttls on
auth on
password iohieFood2quah8e
account default : uberspace_host

View file

@ -0,0 +1,13 @@
---
mail_accounts:
- name: "uberspace_thinkpad"
password: "iohieFood2quah8e"
username: "high5-thinkpad"
imap: mail.alioth.uberspace.de
smtp: mail.alioth.uberspace.de
from: admin@927589452.de
default: yes
msmtprc: "{{ config_path }}/msmtprc"
root_mail: "ansible-host-{{ ansible_fqdn }}@927589452.de"