Add postfix ansible roll
This commit is contained in:
parent
00259b25a1
commit
5a1f098597
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- hosts: plumbi
|
||||
become: yes
|
||||
roles:
|
||||
- postfix
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
Role Name
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# defaults file for /etc/ansible/roles/postfix
|
||||
#
|
||||
packages: [mailutils, postfix]
|
||||
relay_host: "[sub.domain.com]:777"
|
||||
email: "email@domain.com"
|
||||
sasl_passwd: "xxxxxxxxxxxxx"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
sudo postmap /etc/postfix/sasl/sasl_passwd;
|
||||
sudo chown root:root /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db;
|
||||
sudo chmod 600 /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db;
|
|
@ -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 (Ubuntu)
|
||||
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 = {{ ansible_hostname }}
|
||||
alias_maps = hash:/etc/aliases
|
||||
alias_database = hash:/etc/aliases
|
||||
mydestination = $myhostname, {{ ansible_hostname }}, localhost.localdomain, localhost
|
||||
relayhost = {{ relay_host }}
|
||||
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
|
||||
|
||||
# Enable SASL authentication
|
||||
smtp_sasl_auth_enable = yes
|
||||
# Disallow methods that allow anonymous authentication
|
||||
smtp_sasl_security_options = noanonymous
|
||||
# Location of sasl_passwd
|
||||
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
|
||||
# Enable STARTTLS encryption
|
||||
smtp_tls_security_level = encrypt
|
||||
# Location of CA certificates
|
||||
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
|
|
@ -0,0 +1 @@
|
|||
{{ relay_host }} {{ email }}:{{ sasl_passwd }}
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# handlers file for /etc/ansible/roles/postfix
|
||||
#
|
||||
|
||||
- name: restart postfix
|
||||
service: name=postfix state=restarted
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
galaxy_info:
|
||||
author: Shaun Reed
|
||||
description: A template for basic postfix configuration
|
||||
company: (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.4
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
# platforms:
|
||||
# - name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 25
|
||||
# - name: SomePlatform
|
||||
# versions:
|
||||
# - all
|
||||
# - 1.0
|
||||
# - 7
|
||||
# - 99.99
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
- name: Copy postfix configuration template
|
||||
template: src=files/postfix/main.cf dest=/etc/postfix/main.cf
|
||||
|
||||
- name: Copy postfix sasl_passwd
|
||||
template: src=files/postfix/sasl_passwd dest=/etc/postfix/sasl/sasl_passwd
|
||||
|
||||
- name: Copy init-mail.sh script to remote hosts
|
||||
copy: src=files/postfix/init-mail.sh dest=/etc/postfix/init-mail.sh
|
||||
|
||||
- name: Touch a file, using symbolic modes to set the permissions (equivalent to 0644)
|
||||
file:
|
||||
path: /etc/postfix/init-mail.sh
|
||||
state: touch
|
||||
mode: u=rwx,g=rwx,o=rwx
|
||||
|
||||
- name: Run script to initialize postfix
|
||||
script: files/postfix/init-mail.sh
|
||||
notify:
|
||||
- restart postfix
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- name: Install packages
|
||||
apt: name="{{ item }}" state=latest
|
||||
with_items: "{{ packages }}"
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# tasks file for /etc/ansible/roles/nginx
|
||||
|
||||
- import_tasks: install.yml
|
||||
- import_tasks: configure.yml
|
||||
- import_tasks: service.yml
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- name: Start and enable postfix service
|
||||
service: name=postfix state=restarted enabled=yes
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# vars file for /etc/ansible/roles/postfix
|
Loading…
Reference in New Issue