Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Ansible
*.retry
roles/
tests/roles/

# Swap files
*.swo
*.swp

# Python bytecode
*.pyc

# Pytest
.cache

# Tox
.tox

# Vagrant
.vagrant
*.log

# Molecule
.molecule
5 changes: 5 additions & 0 deletions .pyup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

# Pyup configuration

branch: 'develop'
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---

# Travis configuration

dist: 'xenial'
sudo: 'required'

services:
- 'docker'

language: 'python'
python: '2.7'

env:
matrix:
- TOXENV='py27-ansible24'
- TOXENV='py27-ansible25'
- TOXENV='py27-ansible26'
- TOXENV='py27-ansible27'

install:
- 'pip install tox-travis'

script:
- 'tox -e "${TOXENV}"'

notifications:
webhooks: 'https://galaxy.ansible.com/api/v1/notifications/'
11 changes: 11 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
truthy: disable
6 changes: 4 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2019 Temelio
The MIT License (MIT)

Copyright (c) 2015 Temelio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,3 +20,4 @@ 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.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ansible-role-exim4
# exim4

[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.com/Temelio/exim4.svg?branch=master)](https://travis-ci.org/Temelio/exim4)
[![Updates](https://pyup.io/repos/github/Temelio/exim4/shield.svg)](https://pyup.io/repos/github/Temelio/ansible-role-exim4/)
[![Build Status](https://travis-ci.com/Temelio/exim4.svg?branch=master)](https://travis-ci.com/Temelio/exim4)
[![Updates](https://pyup.io/repos/github/Temelio/ansible-role-exim4/shield.svg)](https://pyup.io/repos/github/Temelio/ansible-role-exim4/)
[![Python 3](https://pyup.io/repos/github/Temelio/ansible-role-exim4/python-3-shield.svg)](https://pyup.io/repos/github/Temelio/ansible-role-exim4/)
[![Ansible Role](https://img.shields.io/ansible/role/.svg)](https://galaxy.ansible.com/Temelio/exim4/)
[![Ansible Role](https://img.shields.io/ansible/role/43634.svg)](https://galaxy.ansible.com/Temelio/exim4/)
[![GitHub tag](https://img.shields.io/github/tag/Temelio/ansible-role-exim4.svg)](https://github.com/Temelio/ansible-role-exim4/tags)


Expand Down
36 changes: 36 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---

# Defaults vars file for exim4 role
exim_package: "{{ _exim_package }}"
exim_daemon: "{{ _exim_daemon }}"

exim_config:
- dest: '/etc/exim4/update-exim4.conf.conf'
owner: 'root'
group: 'root'
mode: '0644'

exim_dc_eximconfig_configtype: 'satellite'
exim_dc_other_hostnames: "{{ ansible_hostname }}"
exim_dc_local_interfaces: '127.0.0.1 ; ::1'
exim_dc_readhost: 'example.org'
exim_dc_relay_domains: ''
exim_dc_minimaldns: 'false'
exim_dc_relay_nets: ''
exim_dc_smarthost: 'smtp.example.org::465'
exim_CFILEMODE: '644'
exim_dc_user_split_config: false
exim_dc_hide_mailname: 'true'
exim_dc_mailname_in_oh: true
exim_dc_localdelivery: 'mail_spool'

exim_with_auth: 'true'
exim_with_auth_config:
- dest: '/etc/exim4/passwd.client'
owner: 'root'
group: 'Debian-exim'
mode: '0640'
options:
- smtp: 'smtp.example.com'
login: 'toto'
passwd: 'changeme'
Empty file added files/.keep
Empty file.
Empty file added filter_plugins/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

# Handlers main file for exim4 role
- name: 'Restart Exim4'
systemd:
name: "{{ exim_daemon }}"
state: 'restarted'
daemon-reload: true
enabled: true
18 changes: 18 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

galaxy_info:
author: 'Lise Machetel'
description: 'Ansible role to install and configure exim4'
company: 'Temelio (https://temelio.com)'
license: 'MIT'
min_ansible_version: '2.4'
github_branch: 'master'
role_name: 'exim4'
platforms:
- name: 'Ubuntu'
versions:
- 'xenial'
- 'bionic'
galaxy_tags:
- 'system'
dependencies: []
14 changes: 14 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
16 changes: 16 additions & 0 deletions molecule/default/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*******
Install
*******

Requirements
============

* Docker Engine
* docker-py

Install
=======

.. code-block:: bash

$ sudo pip install docker-py
39 changes: 39 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---

dependency:
name: 'galaxy'
driver:
name: 'docker'
lint:
name: 'yamllint'
platforms:
- name: "exim4-docker-xenial"
image: 'solita/ubuntu-systemd:16.04'
command: '/sbin/init'
cap_add:
- 'SYS_PTRACE'
privileged: true
- name: "exim4-docker-bionic"
image: 'solita/ubuntu-systemd:18.04'
command: '/sbin/init'
cap_add:
- 'SYS_PTRACE'
privileged: true
provisioner:
name: 'ansible'
lint:
name: 'ansible-lint'
inventory:
group_vars:
all: {}
host_vars: {}
scenario:
name: 'default'
verifier:
name: 'testinfra'
additional_files_or_dirs:
- '../../tests'
lint:
name: 'flake8'
options:
sudo: true
22 changes: 22 additions & 0 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---

# Role tests

- name: 'Converge | Prerequisites tasks'
hosts: 'all'
gather_facts: false
tasks:
- name: 'PREREQUISITES | APT | Do an apt-get update'
become: true
raw: 'apt-get update -qq'
changed_when: false
- name: 'PREREQUISITES | APT | Install python 2.7'
become: true
raw: 'apt-get install -qq python2.7'
changed_when: false


- name: 'Converge | Main tasks'
hosts: 'all'
roles:
- role: "ansible-role-exim4"
21 changes: 21 additions & 0 deletions molecule/default/tests/test_installation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Role tests
"""

import os
from testinfra.utils.ansible_runner import AnsibleRunner

testinfra_hosts = AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_hosts_file(host):
"""
Ensure /etc/hosts file exists
"""

f = host.file('/etc/hosts')

assert f.exists
assert f.user == 'root'
assert f.group == 'root'
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker==4.0.2
molecule==2.22
pytest==4.6.5
tox==3.14.0
21 changes: 21 additions & 0 deletions tasks/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: 'CONFIG | configure Exim4'
template:
src: "{{ role_path }}/templates/update-exim4.conf.conf.j2"
dest: "{{ item.dest }}"
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode }}"
with_items: "{{ exim_config }}"
notify: 'Restart Exim4'

- name: 'CONFIG | configure Exim4 with auth'
template:
src: "{{ role_path }}/templates/passwd.client.j2"
dest: "{{ item.dest }}"
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode }}"
with_items: "{{ exim_with_auth_config }}"
notify: 'Restart Exim4'
when: exim_with_auth
7 changes: 7 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: 'INSTALL | Ensure exim is installed'
apt:
name: "{{ exim_package }}"
state: 'present'
update_cache: true
cache_valid_time: 3600
21 changes: 21 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

# Main tasks file for exim4 role

- name: 'INIT | Manage variables to use for our target'
import_tasks: "{{ role_path }}/tasks/manage_variables.yml"
tags:
- 'role::exim4'
- 'role::exim4::init'

- name: 'INSTALL | Install Exim4'
import_tasks: "{{ role_path }}/tasks/install.yml"
tags:
- 'role::exim4'
- 'role::exim4::install'

- name: 'CONFIG | Configure Exim4'
import_tasks: "{{ role_path }}/tasks/config.yml"
tags:
- 'role::exim4'
- 'role::exim4::config'
41 changes: 41 additions & 0 deletions tasks/manage_variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---

# All tasks about variables management

- name: 'INIT | VARIABLES | Check if OS family vars file exists'
become: false
stat:
path: "{{ role_path }}/vars/os_family/{{ ansible_os_family | lower }}.yml"
register: 'exim4_check_os_family_vars'
delegate_to: '127.0.0.1'


- name: 'INIT | VARIABLES | Check if OS distribution vars file exists'
become: false
stat:
path: "{{ role_path }}/vars/os_distribution/{{ ansible_distribution | lower }}.yml"
register: 'exim4_check_os_distribution_vars'
delegate_to: '127.0.0.1'


- name: 'INIT | VARIABLES | Check if OS release vars file exists'
become: false
stat:
path: "{{ role_path }}/vars/os_distribution/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}.yml"
register: 'exim4_check_os_release_vars'
delegate_to: '127.0.0.1'


- name: 'INIT | VARIABLES | Load OS family vars file'
include_vars: "{{ role_path }}/vars/os_family/{{ ansible_os_family | lower }}.yml"
when: "exim4_check_os_family_vars.stat.exists"


- name: 'INIT | VARIABLES | Load OS distribution vars file'
include_vars: "{{ role_path }}/vars/os_distribution/{{ ansible_distribution | lower }}.yml"
when: "exim4_check_os_distribution_vars.stat.exists"


- name: 'INIT | VARIABLES | Load OS release vars file'
include_vars: "{{ role_path }}/vars/os_distribution/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}.yml"
when: "exim4_check_os_release_vars.stat.exists"
Empty file added templates/.keep
Empty file.
9 changes: 9 additions & 0 deletions templates/passwd.client.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ ansible_managed | comment }}
# password file used when the local exim is authenticating to a remote
# host as a client.
#
# see exim4_passwd_client(5) for more documentation
#
{% for item in item.options %}
{{ item.smtp }}:{{ item.login }}:{{ item.passwd }}
{% endfor %}
Loading
Loading