summaryrefslogtreecommitdiffstats
path: root/roles/base/tasks/postfix.yml
blob: 851bb8ab1bc19afb0805488fc8f1c94f3f36bc39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
- name: /etc/postfix/main.cf
  copy: src={{ item }} dest=/etc/postfix/main.cf
  with_first_found:
    - "{{ postfix_maincf }}"
    - "postfix/main.cf/main.cf.{{ inventory_hostname }}"
    - "postfix/main.cf/main.cf.{{ host_group }}"
    - "postfix/main.cf/main.cf.{{ postfix_group }}"
    - "postfix/main.cf/main.cf.{{ datacenter }}"
    - "postfix/main.cf/main.cf"
  notify:
  - restart postfix
  tags:
  - postfix
  - config
  - base

- name: install /etc/postfix/master.cf file
  copy: src={{ item }} dest=/etc/postfix/master.cf mode=0644
  with_first_found:
    - "{{ postfix_mastercf }}"
    - "postfix/master.cf/master.cf.{{ inventory_hostname }}"
    - "postfix/master.cf/master.cf.{{ host_group }}"
    - "postfix/master.cf/master.cf.{{ postfix_group }}"
    - "postfix/master.cf/master.cf"
  when: inventory_hostname.startswith(('smtp-mm', 'mailman', 'noc02'))
  notify:
  - restart postfix
  tags:
  - postfix
  - config
  - base

- name: enable postfix to start
  service: name=postfix state=started enabled=true
  tags:
  - service
  - base

- name: install /etc/postfix/transport file
  copy: src="postfix/{{ postfix_transport_filename }}" dest=/etc/postfix/transport
  when: inventory_hostname.startswith(('smtp-mm','bastion','noc02'))
  notify:
  - rebuild postfix transport
  - restart postfix
  tags:
  - postfix
  - base
  - config

- name: create /etc/postfix/tls_policy
  copy: src="postfix/tls_policy" dest=/etc/postfix/tls_policy
  when: inventory_hostname.startswith(('bastion','smtp-mm'))
  notify:
  - rebuild postfix tls_policy
  - restart postfix
  tags:
  - postfix
  
- name: install /etc/pki/tls/certs/gateway.crt
  copy: 
    src="{{private}}/files/smtpd/gateway.complete.crt"
    dest=/etc/pki/tls/certs/gateway.crt
    owner=root
    group=root
    mode=0644
  when: inventory_hostname.startswith(('bastion','smtp-mm'))
  notify:
  - restart postfix
  tags:
  - postfix

- name: Copy gateway.key
  copy: 
    src="{{private}}/files/smtpd/gateway.key"
    dest=/etc/pki/tls/private/
    owner=root
    group=postfix
    mode=0640
  when: inventory_hostname.startswith(('bastion','smtp-mm'))
  notify:
  - restart postfix
  tags:
  - postfix