ansible6(邮件服务器)
v5-1_srvgroup.yml:
---
- name: Runing Mail Server
hosts: serverb
vars:
v_mail_servers:
- postfix
- dovecot
tasks:
- name: Install Postfix
yum:
name: "{{ item }}"
state: latest
loop:
"{{ v_mail_servers }}"
- name: myorigin
lineinfile:
path: /etc/postfix/main.cf
regexp: '^#myorigin = $mydomain'
line: myorigin = $mydomain
- name: inet_interfaces
lineinfile:
path: /etc/postfix/main.cf
regexp: '^inet_interfaces = localhost'
line: inet_interfaces = all
- name: mydestination
lineinfile:
path: /etc/postfix/main.cf
regexp: '^mydestination ='
line: mydestination = $myhostname, localhost.$mydomain, localhost, lab.example.com
- name: mynetwork
lineinfile:
path: /etc/postfix/main.cf
line: mynetworks = 172.25.250.0/24, 127.0.0.0/8
- name: login_trusted_networks
lineinfile:
path: /etc/dovecot/dovecot.conf
regexp: '^#login_trusted_networks ='
line: login_trusted_networks = 172.25.250.0/24
- name: Mbox
file:
path: /home/student/mail/.imap/INBOX
state: directory
recurse: yes
owner: student
group: student
setype: user_home_t
- name: 10conf
lineinfile:
path: /etc/dovecot/conf.d/10-mail.conf
line: mail_location = mbox:~/mail:INBOX=/var/mail/%u
- name: Running Servers
service:
name: "{{ item }}"
state: restarted
enabled: yes
loop:
- postfix
- dovecot
- name: firewalld
firewalld:
service: smtp
state: enabled
permanent: yes
immediate: yes
- name: firewalld-dovecot
firewalld:
service: pop3
state: enabled
permanent: yes
immediate: yes
Dec 12 21:05:20 serverb postfix/qmgr: 9D67920CE759: from=<student@lab.example.com>, size=334519, nrcpt=1 (queue active)
Dec 12 21:05:20 serverb postfix/smtpd: disconnect from classroom.lab.example.com ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Dec 12 21:05:24 serverb postfix/smtp: 9D67920CE759: to=<18950350376@189.cn>, relay=mta-189.21cn.com:25, delay=3.8, delays=0.2/0.04/2.1/1.4, dsn=5.0.0, status=bounced (host mta-189.21cn.com said: 543 suspected spams or account(IP) exception (in reply to end of DATA command))
Dec 12 21:05:24 serverb postfix/cleanup: 6B25820CE804: message-id=<20201212130524.6B25820CE804@serverb.lab.example.com>
Dec 12 21:05:24 serverb postfix/bounce: 9D67920CE759: sender non-delivery notification: 6B25820CE804
Dec 12 21:05:24 serverb postfix/qmgr: 6B25820CE804: from=<>, size=2762, nrcpt=1 (queue active)
Dec 12 21:05:24 serverb postfix/qmgr: 9D67920CE759: removed
页:
[1]