From 538128db0a80a7dd496b7a1ae7f99916e742daf7 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Mon, 19 Aug 2019 16:06:16 +0200 Subject: [PATCH] simple automatic tests added --- ansible/ispmail.yml | 1 + ansible/roles/ispmail-tests/tasks/main.yml | 39 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 ansible/roles/ispmail-tests/tasks/main.yml diff --git a/ansible/ispmail.yml b/ansible/ispmail.yml index 7b8073a..0743d5f 100644 --- a/ansible/ispmail.yml +++ b/ansible/ispmail.yml @@ -20,3 +20,4 @@ # - ispmail-dovecot # - ispmail-webmail # - ispmail-webmail-apache + - ispmail-tests diff --git a/ansible/roles/ispmail-tests/tasks/main.yml b/ansible/roles/ispmail-tests/tasks/main.yml new file mode 100644 index 0000000..f5a1c55 --- /dev/null +++ b/ansible/roles/ispmail-tests/tasks/main.yml @@ -0,0 +1,39 @@ +--- +- name: Remove all mails from john@example.org mailbox + file: + path: /var/vmail/example.org/john + state: absent + +- name: Check that all required TCP ports are responding + wait_for: + host: localhost + port: "{{ item }}" + state: started # Port should be open + delay: 0 # No wait before first check (sec) + timeout: 3 # Stop checking after timeout (sec) + ignore_errors: yes + with_items: + - 443 + - 80 + - 143 + - 110 + - 25 + - 587 + +- name: Try sending an email to Postfix over SMTP + mail: + host: localhost + port: 25 + to: John Smith + subject: Ansible Test SMTP + body: System {{ ansible_hostname }} has been successfully provisioned. + +- name: Try sending an email to Postfix over Submission port + mail: + host: localhost + username: john@example.org + password: summersun + port: 587 + to: John Smith + subject: Ansible Test Submission + body: System {{ ansible_hostname }} has been successfully provisioned.