When standing up a new greenfield environment, one of the first services you typically end up needing is an internal mail relay. We use Office 365, so we wanted to our mail relay to send mail through it. To do that I used Puppet along with a Puppet module from jlambert121, which you can find here. Note, I also used the Firewalld puppet module from crayfishx to manage my firewall ports on RHEL 7, which you can find here.

Once I had the puppet module installed, I was able to use the following puppet manifest.

#filename        :postfix_relay.pp
#description     :This is the base puppet manifest for a postfix mail relay for EMS
#author          :Eric Sarakaitis
#date            :9/29/16

class profiles::postfix_relay {

#open the firewall ports
firewalld_service { 'Allow smtp from the external zone':
  ensure  => 'present',
  service => 'smtp',
  zone    => 'external'

firewalld_port {
  #open port 25 TCP for SMTP
  'Open port 25 TCP in the public zone':
  ensure   => present,
  zone     => 'public',
  port     => 25,
  protocol => 'tcp'

#install and configure postfix
class { 'postfix':
  smtp_relay      => true,
  relay_networks  => ',,',
  relay_host => '[smtp.office365.com]',
  relay_username => 'relay@domain.com',
  relay_password => 'Passw0rd',
  relay_port => '587',

#closing frenchie

The following two tabs change content below.

Eric Sarakaitis

Virtualization Engineer at CBTS
I'm Eric, I love to cook, sing, garden and enjoy cold beverages!
2018 vmware admins. All rights reserved.
Design by picomol. Powered by WordPress.