Skip to content

Conversation

@salanisor
Copy link
Contributor

This PR adds the email feature on the bastion host so that users can test Prometheus rules and Alertmanager notifications out of the box.

Given that the ocp4-helpernode project already provides DNS MX Record it was a no-brainer to include this as part of this helpful project.

Please note that the code utilized was mostly obtained from the upstream postfix ansible-galaxy role [1]. However, found it too convoluted to use alone in addition to the ocp4-helpernode project. It is my opinion that this addition to the ocp4-helpernode will greatly help me and others to facilitate the setup to a more realistic test environment.

The details are as follow:

  • The postfix configuration is setup to allow email from 127.0.0.1 & the openshift4 subnet 192.168.7.0/24
  • It adds two local accounts openshift & incoming which Alertmanager uses to connect and receive the email notifications - (required).
  • By default, the accounts are setup with the /usr/sbin/nologin shell and locked password.
  • You can extend the configuration for postfix_files or postfix_conf per the upstream project [1] if you desire.
  • Last but not least, it provides it own documentation docs/email-notifications.md for how to get this up and working with minimal effort. So you can focus on testing and not having to figure out how to implement email on the bastion host.

Tested on RHEL-8.10 and Centos Stream 8

[1] - https://github.com/linux-system-roles/postfix

include: set_facts_.yaml
# ERROR! [DEPRECATED]: ansible.builtin.include has been removed. Use include_tasks or import_tasks instead. This feature was removed from ansible-core in a release after 2023-05-16. Please update your playbooks.
# CentOS Stream 8
import_tasks: set_facts_.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets stick with include_tasks, as you have used it below as well (or whichever is more convenient, but lets keep everything in sync)

msg:
- "Please run /usr/local/bin/helpernodecheck for information"

- "Please run /usr/local/bin/helpernodecheck for information"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- "Please run /usr/local/bin/helpernodecheck for information"
- "Please run /usr/local/bin/helpernodecheck for information"


- name: Check postfix
command: postfix check
when: postfix_check
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
when: postfix_check
when: postfix_check


- set_fact:
postfix_smtp_services:
- smtp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- smtp
- smtp

sender: "openshift@{{ helper.name }}.{{ dns.clusterid }}.{{ dns.domain | lower }}"
to: "incoming@{{ helper.name }}.{{ dns.clusterid }}.{{ dns.domain | lower }}"
subject: Email By Ansible
body: Test successful No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body: Test successful
body: Test successful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants