Skip to content

Commit 3b2d61c

Browse files
committed
Set mailserver option if alerts are enabled
1 parent 515e80d commit 3b2d61c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tasks/monit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111
- "allow localhost"
1212

1313

14+
- when: when enable_mail_alerts == True and smtp_use_tls == True
15+
name: set tls_option
16+
set_fact: smtp_tls_option="using tlsv1"
17+
18+
- when: when enable_mail_alerts == True and smtp_use_tls != True
19+
name: set tls_option
20+
set_fact: smtp_tls_option=""
21+
22+
23+
- when: when enable_mail_alerts == True
24+
name: set mail server for notifications in monit
25+
lineinfile: dest=/etc/monit/monitrc line="{{ item }}"
26+
with_items:
27+
- "set mailserver {{ smtp_host }} port {{ smtp_port }} username {{ smtp_user }} password {{ smtp_password }} {{ smtp_tls_option }} with timeout 30 seconds"
28+
29+
1430
- name: start monit & mark to be started on system reboots
1531
service: name=monit state=started enabled=yes
1632

0 commit comments

Comments
 (0)