Changeset - 13982172ed2e
[Not reviewed]
roles/mail_forwarder/defaults/main.yml
Show inline comments
 
---
 

	
 
local_mail_aliases: {}
 
smtp_from_relay_allowed: True
 
smtp_from_relay_allowed: true
 
smtp_relay_host: ""
 
smtp_relay_truststore: "{{ lookup('file', tls_certificate_dir + '/truststore.pem') }}"
 
smtp_relay_host_port: null
roles/mail_forwarder/molecule/default/create.yml
Show inline comments
 
@@ -2,7 +2,7 @@
 
- name: Create
 
  hosts: localhost
 
  connection: local
 
  gather_facts: False
 
  gather_facts: false
 
  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
 
  vars:
 
    molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
roles/mail_forwarder/molecule/default/destroy.yml
Show inline comments
 
@@ -3,7 +3,7 @@
 
- name: Destroy
 
  hosts: localhost
 
  connection: local
 
  gather_facts: False
 
  gather_facts: false
 
  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
 
  vars:
 
    molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
roles/mail_forwarder/molecule/default/group_vars/parameters-mandatory.yml
Show inline comments
 
new file 100644
 
---
 

	
 
# Global common parameters.
 
tls_certificate_dir: tests/data/x509/
roles/mail_forwarder/molecule/default/group_vars/parameters-no-incoming.yml
Show inline comments
 
new file 100644
 
---
 

	
 
smtp_relay_host: mail-server
 
smtp_from_relay_allowed: false
 
smtp_relay_truststore: "{{ lookup('file', 'tests/data/x509/ca.cert.pem') }}"
 

	
 
# common
 
ca_certificates:
 
  testca: "{{ lookup('file', 'tests/data/x509/ca.cert.pem') }}"
roles/mail_forwarder/molecule/default/group_vars/parameters-optional.yml
Show inline comments
 
new file 100644
 
---
 

	
 
local_mail_aliases:
 
  root: "root testuser"
 
smtp_from_relay_allowed: true
 
smtp_relay_host: mail-server
 
smtp_relay_host_port: 27
 
smtp_relay_truststore: "{{ lookup('file', 'tests/data/x509/ca.cert.pem') }}"
 

	
 
# common
 
ca_certificates:
 
  testca: "{{ lookup('file', 'tests/data/x509/ca.cert.pem') }}"
roles/mail_forwarder/molecule/default/molecule.yml
Show inline comments
 
@@ -9,6 +9,8 @@ driver:
 

	
 
lint:
 
  name: yamllint
 
  options:
 
    config-file: ../../.yamllint.yml
 

	
 
platforms:
 

	
roles/mail_forwarder/molecule/default/playbook.yml
Show inline comments
 
---
 

	
 
- hosts: parameters-mandatory
 
  become: yes
 
- hosts: parameters-mandatory,parameters-optional,parameters-no-incoming
 
  become: true
 
  roles:
 
    - role: mail_forwarder
 

	
 
      # Global common parameters.
 
      tls_certificate_dir: tests/data/x509/
 

	
 
- hosts: parameters-optional
 
  become: yes
 
  roles:
 
    - role: mail_forwarder
 
      local_mail_aliases:
 
        root: "root testuser"
 
      smtp_from_relay_allowed: True
 
      smtp_relay_host: mail-server
 
      smtp_relay_host_port: 27
 
      smtp_relay_truststore: "{{ lookup('file', 'tests/data/x509/ca.cert.pem') }}"
 

	
 
      # common
 
      ca_certificates:
 
        testca: "{{ lookup('file', 'tests/data/x509/ca.cert.pem') }}"
 

	
 
- hosts: parameters-no-incoming
 
  become: yes
 
  roles:
 
    - role: mail_forwarder
 
      smtp_relay_host: mail-server
 
      smtp_from_relay_allowed: False
 
      smtp_relay_truststore: "{{ lookup('file', 'tests/data/x509/ca.cert.pem') }}"
 

	
 
      # common
 
      ca_certificates:
 
        testca: "{{ lookup('file', 'tests/data/x509/ca.cert.pem') }}"
 
    - mail_forwarder
roles/mail_forwarder/molecule/default/prepare.yml
Show inline comments
 
@@ -2,24 +2,24 @@
 

	
 
- name: Prepare
 
  hosts: all
 
  gather_facts: False
 
  gather_facts: false
 
  tasks:
 
    - name: Install python for Ansible
 
      raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
 
      become: True
 
      changed_when: False
 
      become: true
 
      changed_when: false
 

	
 
- hosts: all
 
  become: yes
 
  become: true
 
  tasks:
 

	
 
    - name: Update all caches to avoid errors due to missing remote archives
 
      apt:
 
        update_cache: yes
 
      changed_when: False
 
        update_cache: true
 
      changed_when: false
 

	
 
- hosts: all
 
  become: yes
 
  become: true
 
  tasks:
 

	
 
    - name: Set-up the hosts file
 
@@ -42,18 +42,18 @@
 
        10.31.127.32: "parameters-no-incoming-stretch64"
 

	
 
- hosts: clients
 
  become: yes
 
  become: true
 
  tasks:
 

	
 
    - name: Install SWAKS for testing SMTP capability
 
      apt:
 
        name: swaks
 
        state: installed
 
        state: present
 

	
 
    - name: Install tool for testing TCP connectivity
 
      apt:
 
        name: hping3
 
        state: installed
 
        state: present
 

	
 
    - name: Deploy CA certificate
 
      copy:
 
@@ -71,7 +71,7 @@
 
      command: /usr/sbin/update-ca-certificates --fresh
 

	
 
- hosts: mail-servers
 
  become: yes
 
  become: true
 
  tasks:
 

	
 
    - name: Deploy CA certificate
 
@@ -96,10 +96,15 @@
 
        - mail-server_smtp.key.pem
 

	
 
    - name: Install Postfix
 
      apt: name="postfix" state=installed
 
      apt:
 
        name: "postfix"
 
        state: present
 

	
 
    - name: Purge Exim configuration
 
      apt: name="exim4*" state=absent purge=yes
 
      apt:
 
        name: "exim4*"
 
        state: absent
 
        purge: true
 

	
 
    - name: Deploy Postfix configuration
 
      copy:
 
@@ -114,16 +119,16 @@
 
    - name: Install tool for testing TCP connectivity
 
      apt:
 
        name: hping3
 
        state: installed
 
        state: present
 

	
 
    - name: Install SWAKS for testing SMTP capability
 
      apt:
 
        name: swaks
 
        state: installed
 
        state: present
 

	
 
    - name: Set-up port forwarding
 
      command: "iptables -t nat -A PREROUTING -p tcp -m tcp --dport 27 -j REDIRECT --to-ports 25"
 
      changed_when: False
 
      changed_when: false
 

	
 
  handlers:
 

	
 
@@ -136,7 +141,7 @@
 
        state: restarted
 

	
 
- hosts: parameters-optional
 
  become: yes
 
  become: true
 
  tasks:
 

	
 
    - name: Create additional group for testing local aliases
roles/mail_forwarder/molecule/default/tests/test_connectivity_from_client.py
Show inline comments
 
import os
 

	
 
import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts('client1')
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['client1'])
 

	
 

	
 
def test_connectivity_from_client(host):
roles/mail_forwarder/molecule/default/tests/test_connectivity_from_relay.py
Show inline comments
 
import os
 

	
 
import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts('mail-server')
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['mail-server'])
 

	
 

	
 
def test_connectivity_from_relay(host):
roles/mail_forwarder/molecule/default/tests/test_default.py
Show inline comments
 
import os
 

	
 
import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts(['parameters-mandatory', 'parameters-optional', 'parameters-no-incoming'])
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory', 'parameters-optional', 'parameters-no-incoming'])
 

	
 

	
 
def test_installed_packages(host):
roles/mail_forwarder/molecule/default/tests/test_mandatory.py
Show inline comments
 
import os
 
import re
 
import time
 

	
 

	
 
import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts('parameters-mandatory')
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory'])
 

	
 

	
 
def test_smtp_relay_truststore_file(host):
roles/mail_forwarder/molecule/default/tests/test_optional.py
Show inline comments
 
import os
 
import re
 
import time
 

	
 

	
 
import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts('parameters-optional')
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-optional'])
 

	
 

	
 
def test_smtp_relay_truststore_file(host):
roles/mail_forwarder/molecule/default/tests/test_smtp_relay_host_port.py
Show inline comments
 
import os
 
import re
 
import time
 

	
 
@@ -6,7 +7,7 @@ import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts('parameters-no-incoming')
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-no-incoming'])
 

	
 

	
 
def test_postfix_main_cf_file_content(host):
roles/mail_forwarder/tasks/main.yml
Show inline comments
 
@@ -3,18 +3,18 @@
 
- name: Install Postfix
 
  apt:
 
    name: postfix
 
    state: installed
 
    state: present
 

	
 
- name: Install procmail
 
  apt:
 
    name: procmail
 
    state: installed
 
    state: present
 

	
 
- name: Purge Exim configuration
 
  apt:
 
    name: "exim4*"
 
    state: absent
 
    purge: yes
 
    purge: true
 

	
 
- name: Deploy the SMTP relay TLS truststore
 
  copy:
 
@@ -77,7 +77,7 @@
 
- name: Install SWAKS
 
  apt:
 
    name: swaks
 
    state: installed
 
    state: present
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
0 comments (0 inline, 0 general)