# “Make Everything as simple as possible, but not simpler.” { Albert Einstein }
---
- name: Send an email to LinuxCore
hosts: localhost
gather_facts: false
tasks:
- name: Check SMTP service
shell: netstat -tlnp | grep :25
register: smtp_check
failed_when: false
- name: Fail if SMTP not running
fail:
msg: "SMTP service not running. Start with: sudo systemctl start postfix"
when: smtp_check.rc != 0
- name: Send notification email
mail:
host: "localhost"
port: 25
to: "info@linuxcore.nl"
subject: "Hello Linux Core team"
body: |
Discover how LinuxCore can streamline your infrastructure.
Our experts in Linux, DevOps, and cybersecurity are ready to assist.
register: email_result
retries: 2
delay: 3
- name: Report failure
debug:
msg: "Email failed: {{ email_result.msg }}"
when: email_result is failed