1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/mail/tasks/main.yml
Hartwig Hauschild ae6cbc2d82
mail: adding capability to specify ehlo hostname ()
* Adding capability to specify ehlo hostname

* Fixing default for ehlohost

the CI did not like "None" as default in the documentation,
judging from the rest of the definitions omitting that seems to be right

* Update plugins/modules/notification/mail.py

Proper spelling in documentation

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>

* Adding Changelog Fragment

* Update changelogs/fragments/3425-mail_add_configurable_ehlo_hostname.yml

Proper phrasing in changelog

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>

* integration-test for ehlohost parameter

* proper description, increased async-time

changed body of ehlohost-mail to reflect ehlohost
increased async from 30 to 45 as CI failed because
smtp was already down.

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
2021-09-24 05:30:14 +00:00

100 lines
2.8 KiB
YAML

####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# TODO: Our current implementation does not handle SMTP authentication
# NOTE: If the system does not support smtpd-tls (python 2.6 and older) we do basic tests
- name: Attempt to install smtpd-tls
pip:
name: smtpd-tls
state: present
ignore_errors: yes
register: smtpd_tls
- name: Install test smtpserver
copy:
src: '{{ item }}'
dest: '{{ remote_tmp_dir }}/{{ item }}'
loop:
- smtpserver.py
- smtpserver.crt
- smtpserver.key
# FIXME: Verify the mail after it was send would be nice
# This would require either dumping the content, or registering async task output
- name: Start test smtpserver
shell: '{{ ansible_python.executable }} {{ remote_tmp_dir }}/smtpserver.py 10025:10465'
async: 45
poll: 0
register: smtpserver
- name: Send a basic test-mail
mail:
port: 10025
subject: Test mail 1 (smtp)
secure: never
- name: Send a test-mail with body and specific recipient
mail:
port: 10025
from: ansible@localhost
to: root@localhost
subject: Test mail 2 (smtp + body)
body: Test body 2
secure: never
- name: Send a test-mail with attachment
mail:
port: 10025
from: ansible@localhost
to: root@localhost
subject: Test mail 3 (smtp + body + attachment)
body: Test body 3
attach: /etc/group
secure: never
# NOTE: This might fail if smtpd-tls is missing or python 2.7.8 or older is used
- name: Send a test-mail using starttls
mail:
port: 10025
from: ansible@localhost
to: root@localhost
subject: Test mail 4 (smtp + starttls + body + attachment)
body: Test body 4
attach: /etc/group
secure: starttls
ignore_errors: yes
register: starttls_support
# NOTE: This might fail if smtpd-tls is missing or python 2.7.8 or older is used
- name: Send a test-mail using TLS
mail:
port: 10465
from: ansible@localhost
to: root@localhost
subject: Test mail 5 (smtp + tls + body + attachment)
body: Test body 5
attach: /etc/group
secure: always
ignore_errors: yes
register: tls_support
- fail:
msg: Sending mail using starttls failed.
when: smtpd_tls is succeeded and starttls_support is failed and tls_support is succeeded
- fail:
msg: Send mail using TLS failed.
when: smtpd_tls is succeeded and tls_support is failed and starttls_support is succeeded
- name: Send a test-mail with body, specific recipient and specific ehlohost
mail:
port: 10025
ehlohost: some.domain.tld
from: ansible@localhost
to: root@localhost
subject: Test mail 6 (smtp + body + ehlohost)
body: Test body 6
secure: never