diff --git a/group_vars/all/all.yml b/group_vars/all/all.yml index 9882a5b..605a0ad 100644 --- a/group_vars/all/all.yml +++ b/group_vars/all/all.yml @@ -23,5 +23,8 @@ main_domain: wirebrass.fr # Certbot admin Email address certbot_admin_email: contact@wirebrass.fr +# Admin email (for system notification) +system_admin_email: nemo@wirebrass.fr + # Munin server SSH pubkey public_key_munin_user_host: "{{ vault_public_key_munin_user_host }}" diff --git a/playbook_general_deploy.yml b/playbook_general_deploy.yml index b059353..1c6c3f7 100644 --- a/playbook_general_deploy.yml +++ b/playbook_general_deploy.yml @@ -3,7 +3,7 @@ roles: # - auto_reboot # - auto_upgrade - - sysctl_customizations +# - sysctl_customizations # - client_ntp # - client_resolvers # - client_tools @@ -11,3 +11,4 @@ # - client_iptables # - munin-node # - munin-async + - postfix diff --git a/roles/munin-node/README.md b/roles/munin-node/README.md index 4637c35..6fc5c9b 100644 --- a/roles/munin-node/README.md +++ b/roles/munin-node/README.md @@ -73,7 +73,7 @@ None. - hosts: servers roles: - - { role: geerlingguy.munin-node } + - { role: munin-node } ## License diff --git a/roles/postfix/.gitignore b/roles/postfix/.gitignore new file mode 100644 index 0000000..c9b2377 --- /dev/null +++ b/roles/postfix/.gitignore @@ -0,0 +1,2 @@ +*.retry +tests/test.sh diff --git a/roles/postfix/.travis.yml b/roles/postfix/.travis.yml new file mode 100644 index 0000000..e4a7f31 --- /dev/null +++ b/roles/postfix/.travis.yml @@ -0,0 +1,18 @@ +--- +services: docker + +env: + - distro: centos7 + - distro: ubuntu1604 + - distro: debian9 + +script: + # Download test shim. + - wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/ + - chmod +x ${PWD}/tests/test.sh + + # Run tests. + - ${PWD}/tests/test.sh + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/postfix/LICENSE b/roles/postfix/LICENSE new file mode 100644 index 0000000..4275cf3 --- /dev/null +++ b/roles/postfix/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2017 Jeff Geerling + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/roles/postfix/README.md b/roles/postfix/README.md new file mode 100644 index 0000000..8944629 --- /dev/null +++ b/roles/postfix/README.md @@ -0,0 +1,50 @@ +# Ansible Role: Postfix + +[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-postfix.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-postfix) + +Installs postfix on RedHat/CentOS, Gentoo or Debian/Ubuntu. + +## Requirements + +If you're using this as an SMTP relay server, you will need to do that on your own, and open TCP port 25 in your server firewall. + +## Role Variables + +Available variables are listed below, along with default values (see `defaults/main.yml`): + + postfix_config_file: /etc/postfix/main.cf + aliases_config_file: /etc/aliases + +The path to the Postfix `main.cf` and aliases configuration file. + + postfix_service_state: started + postfix_service_enabled: yes + +The state in which the Postfix service should be after this role runs, and whether to enable the service on startup. + + postfix_inet_interfaces: localhost + postfix_inet_protocols: all + +Options for values `inet_interfaces` and `inet_protocols` in the `main.cf` file. + + alias_email: "{{ system_admin_email }}" + +The email address of admin user (to receive system notification). + +## Dependencies + +None. + +## Example Playbook + + - hosts: all + roles: + - postfix + +## License + +MIT / BSD + +## Author Information + +This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/roles/postfix/defaults/main.yml b/roles/postfix/defaults/main.yml new file mode 100644 index 0000000..4270ffc --- /dev/null +++ b/roles/postfix/defaults/main.yml @@ -0,0 +1,11 @@ +--- +postfix_config_file: /etc/postfix/main.cf +aliases_config_file: /etc/aliases + +postfix_service_state: started +postfix_service_enabled: yes + +postfix_inet_interfaces: localhost +postfix_inet_protocols: all + +alias_email: "{{ system_admin_email }}" diff --git a/roles/postfix/handlers/main.yml b/roles/postfix/handlers/main.yml new file mode 100644 index 0000000..80d18eb --- /dev/null +++ b/roles/postfix/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: restart postfix + service: name=postfix state=restarted + +- name: update aliases + command: postalias {{ aliases_config_file }} diff --git a/roles/postfix/meta/.galaxy_install_info b/roles/postfix/meta/.galaxy_install_info new file mode 100644 index 0000000..cbb7927 --- /dev/null +++ b/roles/postfix/meta/.galaxy_install_info @@ -0,0 +1 @@ +{install_date: 'Sun Jul 12 12:53:58 2020', version: 2.0.0} diff --git a/roles/postfix/meta/main.yml b/roles/postfix/meta/main.yml new file mode 100644 index 0000000..1f034f1 --- /dev/null +++ b/roles/postfix/meta/main.yml @@ -0,0 +1,23 @@ +--- +dependencies: [] + +galaxy_info: + author: geerlingguy + description: Postfix for RedHat/CentOS or Debian/Ubuntu. + company: "Midwestern Mac, LLC" + license: "license (BSD, MIT)" + min_ansible_version: 1.8 + platforms: + - name: EL + versions: + - all + - name: Debian + versions: + - all + - name: Ubuntu + versions: + - all + galaxy_tags: + - networking + - system + - mail diff --git a/roles/postfix/tasks/main.yml b/roles/postfix/tasks/main.yml new file mode 100644 index 0000000..2ccab0a --- /dev/null +++ b/roles/postfix/tasks/main.yml @@ -0,0 +1,33 @@ +--- +- name: Include OS-specific variables. + include_vars: "{{ ansible_os_family }}.yml" + +- name: Ensure postfix is installed. + package: + name: postfix + state: present + +- name: Update mail aliases. + lineinfile: + dest: "{{ aliases_config_file }}" + line: "root: {{ alias_email }}" + regexp: "^root:" + notify: update aliases + +- name: Update Postfix configuration. + lineinfile: + dest: "{{ postfix_config_file }}" + line: "{{ item.name }} = {{ item.value }}" + regexp: "^{{ item.name }} =" + with_items: + - name: inet_interfaces + value: "{{ postfix_inet_interfaces }}" + - name: inet_protocols + value: "{{ postfix_inet_protocols }}" + notify: restart postfix + +- name: Ensure postfix is started and enabled at boot. + service: + name: postfix + enabled: "{{ postfix_service_enabled }}" + notify: restart postfix diff --git a/roles/postfix/tests/README.md b/roles/postfix/tests/README.md new file mode 100644 index 0000000..6fb2117 --- /dev/null +++ b/roles/postfix/tests/README.md @@ -0,0 +1,11 @@ +# Ansible Role tests + +To run the test playbook(s) in this directory: + + 1. Install and start Docker. + 1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`: + - `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/` + 1. Make the test shim executable: `chmod +x tests/test.sh`. + 1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh` + +If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)` diff --git a/roles/postfix/tests/test.yml b/roles/postfix/tests/test.yml new file mode 100644 index 0000000..2505c1d --- /dev/null +++ b/roles/postfix/tests/test.yml @@ -0,0 +1,15 @@ +--- +- hosts: all + + pre_tasks: + - name: Update apt cache. + apt: update_cache=yes cache_valid_time=600 + when: ansible_os_family == 'Debian' + + - name: Override postfix_inet_protocols (RHEL). + set_fact: + postfix_inet_protocols: ipv4 + when: ansible_os_family == 'RedHat' + + roles: + - role_under_test diff --git a/roles/postfix/vars/Debian.yml b/roles/postfix/vars/Debian.yml new file mode 100644 index 0000000..23c593e --- /dev/null +++ b/roles/postfix/vars/Debian.yml @@ -0,0 +1,2 @@ +--- +aliases_config_file: /etc/aliases diff --git a/roles/postfix/vars/Gentoo.yml b/roles/postfix/vars/Gentoo.yml new file mode 100644 index 0000000..e9edc07 --- /dev/null +++ b/roles/postfix/vars/Gentoo.yml @@ -0,0 +1,2 @@ +--- +aliases_config_file: /etc/mail/aliases diff --git a/roles/postfix/vars/RedHat.yml b/roles/postfix/vars/RedHat.yml new file mode 100644 index 0000000..23c593e --- /dev/null +++ b/roles/postfix/vars/RedHat.yml @@ -0,0 +1,2 @@ +--- +aliases_config_file: /etc/aliases