Debian version
will remove other MTAs, added Vagrantfile
This commit is contained in:
parent
0a8f71fbbd
commit
7153155289
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# OS generated files #
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
Icon?
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Vagrant files #
|
||||||
|
.virtualbox/
|
||||||
|
.vagrant/
|
||||||
|
vagrant_ansible_inventory_*
|
||||||
|
ansible.cfg
|
||||||
|
|
||||||
|
# Other files #
|
||||||
|
!empty
|
|
@ -1,7 +1,7 @@
|
||||||
[![Build Status](https://travis-ci.org/ahelal/ansible-msmtp.svg?branch=master)](https://travis-ci.org/ahelal/ansible-msmtp)
|
[![Build Status](https://travis-ci.org/ahelal/ansible-msmtp.svg?branch=master)](https://travis-ci.org/ahelal/ansible-msmtp)
|
||||||
#Readme
|
#Readme
|
||||||
|
|
||||||
This ansible role deploys msmtp for Ubuntu 12.04 (tested on vagrant)
|
This ansible role deploys msmtp for Debian 9 stretch (tested on vagrant)
|
||||||
|
|
||||||
##Prerequisite
|
##Prerequisite
|
||||||
* Having ansible installed on your workstation.
|
* Having ansible installed on your workstation.
|
||||||
|
|
71
Vagrantfile
vendored
Normal file
71
Vagrantfile
vendored
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# -*- mode: ruby -*-
|
||||||
|
# vi: set ft=ruby ts=2 sw=2 tw=0 et :
|
||||||
|
|
||||||
|
boxes = [
|
||||||
|
# {
|
||||||
|
# :name => "ubuntu-1204",
|
||||||
|
# :box => "bento/ubuntu-12.04",
|
||||||
|
# :ip => '10.0.0.11',
|
||||||
|
# :cpu => "50",
|
||||||
|
# :ram => "256"
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# :name => "ubuntu-1404",
|
||||||
|
# :box => "bento/ubuntu-14.04",
|
||||||
|
# :ip => '10.0.0.12',
|
||||||
|
# :cpu => "50",
|
||||||
|
# :ram => "256"
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# :name => "ubuntu-1604",
|
||||||
|
# :box => "bento/ubuntu-16.04",
|
||||||
|
# :ip => '10.0.0.13',
|
||||||
|
# :cpu => "50",
|
||||||
|
# :ram => "256"
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# :name => "debian-7",
|
||||||
|
# :box => "bento/debian-7",
|
||||||
|
# :ip => '10.0.0.14',
|
||||||
|
# :cpu => "50",
|
||||||
|
# :ram => "256"
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# :name => "debian-8",
|
||||||
|
# :box => "bento/debian-8",
|
||||||
|
# :ip => '10.0.0.15',
|
||||||
|
# :cpu => "50",
|
||||||
|
# :ram => "256"
|
||||||
|
# },
|
||||||
|
{
|
||||||
|
:name => "debian-9",
|
||||||
|
:box => "bento/debian-9",
|
||||||
|
:ip => '10.0.0.16',
|
||||||
|
:cpu => "50",
|
||||||
|
:ram => "512"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
role = File.basename(File.expand_path(File.dirname(__FILE__)))
|
||||||
|
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
boxes.each do |box|
|
||||||
|
config.vm.define box[:name] do |vms|
|
||||||
|
vms.vm.box = box[:box]
|
||||||
|
vms.vm.hostname = "#{role}-#{box[:name]}"
|
||||||
|
|
||||||
|
vms.vm.provider "virtualbox" do |v|
|
||||||
|
v.customize ["modifyvm", :id, "--cpuexecutioncap", box[:cpu]]
|
||||||
|
v.customize ["modifyvm", :id, "--memory", box[:ram]]
|
||||||
|
end
|
||||||
|
|
||||||
|
vms.vm.network :private_network, ip: box[:ip]
|
||||||
|
|
||||||
|
vms.vm.provision :ansible do |ansible|
|
||||||
|
ansible.playbook = "tests/vagrant.yml"
|
||||||
|
ansible.verbose = "vv"
|
||||||
|
ansible.compatibility_mode = "2.0"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,28 +1,30 @@
|
||||||
---
|
---
|
||||||
msmtp_accounts:
|
msmtp_accounts:
|
||||||
#Account 1
|
#Account 1
|
||||||
- account : "gmail"
|
- account : gmail
|
||||||
host : "smtp.gmail.com"
|
host : smtp.gmail.com
|
||||||
port : 587
|
port : 587
|
||||||
auth : "on"
|
auth : "on"
|
||||||
user : "example@gmail.example"
|
from : username@gmail.com
|
||||||
password : "some password"
|
user : username@gmail.com
|
||||||
|
password : plain-text-password1
|
||||||
#Account 2
|
#Account 2
|
||||||
- account : "mysmtp"
|
- account : mysmtp
|
||||||
host : "smtp.example"
|
host : smtp.example
|
||||||
port : 587
|
port : 587
|
||||||
auth : "on"
|
auth : "on"
|
||||||
user : "myuser"
|
from : admin@example.org
|
||||||
password : "123456"
|
user : myuser@example.org
|
||||||
|
password : plain-text-password2
|
||||||
|
|
||||||
msmtp_default_account: "gmail"
|
msmtp_default_account: mysmtp
|
||||||
msmtp_from : "My Org"
|
msmtp_domain : example.org
|
||||||
|
|
||||||
## Logging (Select A) "syslog" or B) "file" logging or C) "no" log
|
## Logging (Select A) "syslog" or B) "file" logging or C) "no" log
|
||||||
msmtp_log : "syslog"
|
#msmtp_log : "syslog"
|
||||||
#msmtp_logfile : /var/log/msmtp.log
|
msmtp_logfile : /var/log/msmtp.log
|
||||||
|
|
||||||
## Aliases mail account ( only msmtp_alias_default is required the rest is optional )
|
## Aliases mail account ( only msmtp_alias_default is required the rest is optional )
|
||||||
msmtp_alias_default : ops@example.
|
msmtp_alias_default : devops@example.org
|
||||||
msmtp_alias_root : root@example.com
|
msmtp_alias_root : root@example.org
|
||||||
msmtp_alias_cron : cron@example.com
|
msmtp_alias_cron : cron@example.org
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
# send test mail to admin
|
# send test mail to admin
|
||||||
- name: test mail
|
- name: test mail
|
||||||
shell: echo "Test mail from new/updated MSTMP at" `hostname` | mail root -s "Test SMTP `hostname`"
|
shell: echo "Test mail from new/updated MSTMP at" `hostname -f` | mail root -s "Test SMTP at `hostname -f`"
|
||||||
tags: mail
|
tags: mail
|
|
@ -1,11 +1,12 @@
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: Adham Helal
|
author: Adham Helal, modified by Christian Wagner
|
||||||
description: "Deploy msmtp mail for Ubuntu 12.04"
|
description: "Deploy msmtp mail for Debian"
|
||||||
min_ansible_version: 1.4
|
min_ansible_version: 2.4
|
||||||
platforms:
|
platforms:
|
||||||
- name: Ubuntu
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- precise
|
- jessie
|
||||||
|
- stretch
|
||||||
categories:
|
categories:
|
||||||
- system
|
- system
|
||||||
- networking
|
- networking
|
|
@ -1,3 +1,62 @@
|
||||||
---
|
---
|
||||||
|
# Deploy msmtp
|
||||||
|
- name: Update apt cache.
|
||||||
|
apt:
|
||||||
|
upgrade: yes
|
||||||
|
update_cache: yes
|
||||||
|
cache_valid_time: 14400 # 4 hours
|
||||||
|
tags: mail
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
- include: msmtp.yml
|
- name: Remove other MTAs.
|
||||||
|
apt:
|
||||||
|
pkg: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
autoremove: yes
|
||||||
|
purge: yes
|
||||||
|
with_items:
|
||||||
|
- exim4*
|
||||||
|
- postfix*
|
||||||
|
- sendmail*
|
||||||
|
tags:
|
||||||
|
- mail
|
||||||
|
|
||||||
|
- name: Install msmtp and mailx.
|
||||||
|
apt:
|
||||||
|
pkg: "{{item}}"
|
||||||
|
state: present
|
||||||
|
with_items:
|
||||||
|
- msmtp-mta
|
||||||
|
- bsd-mailx
|
||||||
|
tags: mail
|
||||||
|
notify: test mail
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
|
# not tested my modifications with Archlinux
|
||||||
|
- name: Install msmtp and mailx.
|
||||||
|
pacman: name={{item}} state=present
|
||||||
|
with_items:
|
||||||
|
- msmtp
|
||||||
|
- msmtp-mta
|
||||||
|
- mailutils
|
||||||
|
when: ansible_os_family == "Archlinux"
|
||||||
|
|
||||||
|
- name: Copy mstprc conf file.
|
||||||
|
template:
|
||||||
|
src: msmtprc.j2
|
||||||
|
dest: /etc/msmtprc
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
tags: mail
|
||||||
|
notify: test mail
|
||||||
|
|
||||||
|
- name: Copy aliases conf file.
|
||||||
|
template:
|
||||||
|
src: aliases.j2
|
||||||
|
dest: /etc/aliases
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
tags: mail
|
||||||
|
notify: test mail
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
# Author: Adham Helal
|
|
||||||
#
|
|
||||||
# Objective: Deploy msmtp
|
|
||||||
|
|
||||||
- name: Update apt cache
|
|
||||||
apt: update_cache=yes cache_valid_time=3600
|
|
||||||
tags: mail
|
|
||||||
when: ansible_os_family == "Debian"
|
|
||||||
|
|
||||||
- name: Install msmtp and mailx
|
|
||||||
apt: pkg={{item}} state=present
|
|
||||||
with_items:
|
|
||||||
- msmtp
|
|
||||||
- msmtp-mta
|
|
||||||
- bsd-mailx
|
|
||||||
tags: mail
|
|
||||||
notify: test mail
|
|
||||||
when: ansible_os_family == "Debian"
|
|
||||||
|
|
||||||
- name: Install msmtp and mailx
|
|
||||||
pacman: name={{item}} state=present
|
|
||||||
with_items:
|
|
||||||
- msmtp
|
|
||||||
- msmtp-mta
|
|
||||||
- mailutils
|
|
||||||
when: ansible_os_family == "Archlinux"
|
|
||||||
|
|
||||||
- name: Copy mstprc conf file
|
|
||||||
template:
|
|
||||||
src=msmtprc.j2
|
|
||||||
dest=/etc/msmtprc
|
|
||||||
owner=root
|
|
||||||
group=root
|
|
||||||
mode=0644
|
|
||||||
tags: mail
|
|
||||||
notify: test mail
|
|
||||||
|
|
||||||
- name: Copy aliases conf file
|
|
||||||
template: src=aliases.j2 dest=/etc/aliases
|
|
||||||
owner=root group=root mode=0644
|
|
||||||
tags: mail
|
|
||||||
notify: test mail
|
|
|
@ -1,8 +1,10 @@
|
||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
# Default settings that all others account inherit
|
|
||||||
|
# Default settings that all others accounts inherit
|
||||||
defaults
|
defaults
|
||||||
auth on
|
auth on
|
||||||
tls on
|
tls on
|
||||||
|
tls_starttls on
|
||||||
{% if msmtp_tls_trust_file is defined %}
|
{% if msmtp_tls_trust_file is defined %}
|
||||||
tls_trust_file {{msmtp_tls_trust_file}}
|
tls_trust_file {{msmtp_tls_trust_file}}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -18,9 +20,12 @@ logfile {{msmtp_logfile}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
# default is ‘localhost’. Use domain part of your email address or FQDN of host.
|
||||||
from {{msmtp_from}}
|
domain {{msmtp_domain}}
|
||||||
keepbcc on
|
# default is ‘off’. When on, an envelope-from address of the form user@domain will be generated.
|
||||||
|
auto_from off
|
||||||
|
# The default is to remove BCC headers.
|
||||||
|
# remove_bcc_headers on|off
|
||||||
|
|
||||||
{% if msmtp_accounts is defined %}
|
{% if msmtp_accounts is defined %}
|
||||||
{% for msmtp_account in msmtp_accounts %}
|
{% for msmtp_account in msmtp_accounts %}
|
||||||
|
@ -29,6 +34,7 @@ account {{msmtp_account.account}}
|
||||||
host {{msmtp_account.host}}
|
host {{msmtp_account.host}}
|
||||||
port {{msmtp_account.port}}
|
port {{msmtp_account.port}}
|
||||||
auth {{msmtp_account.auth}}
|
auth {{msmtp_account.auth}}
|
||||||
|
from {{msmtp_account.from}}
|
||||||
user {{msmtp_account.user}}
|
user {{msmtp_account.user}}
|
||||||
password {{msmtp_account.password}}
|
password {{msmtp_account.password}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
7
tests/vagrant.yml
Normal file
7
tests/vagrant.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# test file for fail2ban
|
||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
remote_user: vagrant
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- ../../
|
Loading…
Reference in a new issue