mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #7541/b8ecb167 backport][stable-7] CI: devel supports Fedora 39, and no longer Fedora 38 (#7547)
CI: devel supports Fedora 39, and no longer Fedora 38 (#7541) * devel supports Fedora 39, and no longer Fedora 38. * Disable 'mail' tests for Python 3.12+. Ref: https://github.com/ansible-collections/community.general/issues/4656 * Fix setupSSLServer to work with Python 3.12. (cherry picked from commitb8ecb1671b
) Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit3ce83dcf6a
)
This commit is contained in:
parent
ec5e4919eb
commit
820d067c29
2 changed files with 98 additions and 86 deletions
|
@ -18,7 +18,14 @@ except ModuleNotFoundError:
|
||||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||||
|
|
||||||
httpd = HTTPServer(('localhost', port), SimpleHTTPRequestHandler)
|
httpd = HTTPServer(('localhost', port), SimpleHTTPRequestHandler)
|
||||||
httpd.socket = ssl.wrap_socket(httpd.socket, server_side=True,
|
try:
|
||||||
certfile=os.path.join(root_dir, 'cert.pem'),
|
httpd.socket = ssl.wrap_socket(httpd.socket, server_side=True,
|
||||||
keyfile=os.path.join(root_dir, 'key.pem'))
|
certfile=os.path.join(root_dir, 'cert.pem'),
|
||||||
|
keyfile=os.path.join(root_dir, 'key.pem'))
|
||||||
|
except AttributeError:
|
||||||
|
# Python 3.12 or newer:
|
||||||
|
context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
|
||||||
|
context.load_cert_chain(certfile=os.path.join(root_dir, 'cert.pem'),
|
||||||
|
keyfile=os.path.join(root_dir, 'key.pem'))
|
||||||
|
httpd.socket = context.wrap_socket(httpd.socket)
|
||||||
httpd.handle_request()
|
httpd.handle_request()
|
||||||
|
|
|
@ -10,96 +10,101 @@
|
||||||
|
|
||||||
# TODO: Our current implementation does not handle SMTP authentication
|
# 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
|
- when:
|
||||||
- name: Attempt to install smtpd-tls
|
# TODO: https://github.com/ansible-collections/community.general/issues/4656
|
||||||
pip:
|
- ansible_python.version.major != 3 or ansible_python.version.minor < 12
|
||||||
name: smtpd-tls
|
block:
|
||||||
state: present
|
|
||||||
ignore_errors: true
|
|
||||||
register: smtpd_tls
|
|
||||||
|
|
||||||
- name: Install test smtpserver
|
# NOTE: If the system does not support smtpd-tls (python 2.6 and older) we do basic tests
|
||||||
copy:
|
- name: Attempt to install smtpd-tls
|
||||||
src: '{{ item }}'
|
pip:
|
||||||
dest: '{{ remote_tmp_dir }}/{{ item }}'
|
name: smtpd-tls
|
||||||
loop:
|
state: present
|
||||||
- smtpserver.py
|
ignore_errors: true
|
||||||
- smtpserver.crt
|
register: smtpd_tls
|
||||||
- smtpserver.key
|
|
||||||
|
|
||||||
# FIXME: Verify the mail after it was send would be nice
|
- name: Install test smtpserver
|
||||||
# This would require either dumping the content, or registering async task output
|
copy:
|
||||||
- name: Start test smtpserver
|
src: '{{ item }}'
|
||||||
shell: '{{ ansible_python.executable }} {{ remote_tmp_dir }}/smtpserver.py 10025:10465'
|
dest: '{{ remote_tmp_dir }}/{{ item }}'
|
||||||
async: 45
|
loop:
|
||||||
poll: 0
|
- smtpserver.py
|
||||||
register: smtpserver
|
- smtpserver.crt
|
||||||
|
- smtpserver.key
|
||||||
|
|
||||||
- name: Send a basic test-mail
|
# FIXME: Verify the mail after it was send would be nice
|
||||||
mail:
|
# This would require either dumping the content, or registering async task output
|
||||||
port: 10025
|
- name: Start test smtpserver
|
||||||
subject: Test mail 1 (smtp)
|
shell: '{{ ansible_python.executable }} {{ remote_tmp_dir }}/smtpserver.py 10025:10465'
|
||||||
secure: never
|
async: 45
|
||||||
|
poll: 0
|
||||||
|
register: smtpserver
|
||||||
|
|
||||||
- name: Send a test-mail with body and specific recipient
|
- name: Send a basic test-mail
|
||||||
mail:
|
mail:
|
||||||
port: 10025
|
port: 10025
|
||||||
from: ansible@localhost
|
subject: Test mail 1 (smtp)
|
||||||
to: root@localhost
|
secure: never
|
||||||
subject: Test mail 2 (smtp + body)
|
|
||||||
body: Test body 2
|
|
||||||
secure: never
|
|
||||||
|
|
||||||
- name: Send a test-mail with attachment
|
- name: Send a test-mail with body and specific recipient
|
||||||
mail:
|
mail:
|
||||||
port: 10025
|
port: 10025
|
||||||
from: ansible@localhost
|
from: ansible@localhost
|
||||||
to: root@localhost
|
to: root@localhost
|
||||||
subject: Test mail 3 (smtp + body + attachment)
|
subject: Test mail 2 (smtp + body)
|
||||||
body: Test body 3
|
body: Test body 2
|
||||||
attach: /etc/group
|
secure: never
|
||||||
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 with attachment
|
||||||
- name: Send a test-mail using starttls
|
mail:
|
||||||
mail:
|
port: 10025
|
||||||
port: 10025
|
from: ansible@localhost
|
||||||
from: ansible@localhost
|
to: root@localhost
|
||||||
to: root@localhost
|
subject: Test mail 3 (smtp + body + attachment)
|
||||||
subject: Test mail 4 (smtp + starttls + body + attachment)
|
body: Test body 3
|
||||||
body: Test body 4
|
attach: /etc/group
|
||||||
attach: /etc/group
|
secure: never
|
||||||
secure: starttls
|
|
||||||
ignore_errors: true
|
|
||||||
register: starttls_support
|
|
||||||
|
|
||||||
# NOTE: This might fail if smtpd-tls is missing or python 2.7.8 or older is used
|
# 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
|
- name: Send a test-mail using starttls
|
||||||
mail:
|
mail:
|
||||||
port: 10465
|
port: 10025
|
||||||
from: ansible@localhost
|
from: ansible@localhost
|
||||||
to: root@localhost
|
to: root@localhost
|
||||||
subject: Test mail 5 (smtp + tls + body + attachment)
|
subject: Test mail 4 (smtp + starttls + body + attachment)
|
||||||
body: Test body 5
|
body: Test body 4
|
||||||
attach: /etc/group
|
attach: /etc/group
|
||||||
secure: always
|
secure: starttls
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: tls_support
|
register: starttls_support
|
||||||
|
|
||||||
- fail:
|
# NOTE: This might fail if smtpd-tls is missing or python 2.7.8 or older is used
|
||||||
msg: Sending mail using starttls failed.
|
- name: Send a test-mail using TLS
|
||||||
when: smtpd_tls is succeeded and starttls_support is failed and tls_support is succeeded
|
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: true
|
||||||
|
register: tls_support
|
||||||
|
|
||||||
- fail:
|
- fail:
|
||||||
msg: Send mail using TLS failed.
|
msg: Sending mail using starttls failed.
|
||||||
when: smtpd_tls is succeeded and tls_support is failed and starttls_support is succeeded
|
when: smtpd_tls is succeeded and starttls_support is failed and tls_support is succeeded
|
||||||
|
|
||||||
- name: Send a test-mail with body, specific recipient and specific ehlohost
|
- fail:
|
||||||
mail:
|
msg: Send mail using TLS failed.
|
||||||
port: 10025
|
when: smtpd_tls is succeeded and tls_support is failed and starttls_support is succeeded
|
||||||
ehlohost: some.domain.tld
|
|
||||||
from: ansible@localhost
|
- name: Send a test-mail with body, specific recipient and specific ehlohost
|
||||||
to: root@localhost
|
mail:
|
||||||
subject: Test mail 6 (smtp + body + ehlohost)
|
port: 10025
|
||||||
body: Test body 6
|
ehlohost: some.domain.tld
|
||||||
secure: never
|
from: ansible@localhost
|
||||||
|
to: root@localhost
|
||||||
|
subject: Test mail 6 (smtp + body + ehlohost)
|
||||||
|
body: Test body 6
|
||||||
|
secure: never
|
||||||
|
|
Loading…
Reference in a new issue