/
mailsync.yml
56 lines (50 loc) · 1.44 KB
/
mailsync.yml
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
---
- name: Push mail sync script
template: src=mailsync.sh.j2 dest=/usr/local/bin/mailsync mode=755
tags:
- mailsync
- name: Push mailsync service file
template: src=mailsync.service.j2 dest=/etc/systemd/user/mailsync.service
tags:
- mailsync
notify:
- reload systemd config
- name: Push mailsync timer file
template: src=mailsync.timer.j2 dest=/etc/systemd/user/mailsync.timer
tags:
- mailsync
notify:
- reload systemd config
- restart mailsync
- name: Enable and start mailsync timer
systemd: name=mailsync.timer user=yes enabled=yes state=started
become: yes
become_user: "{{ user.name }}"
environment:
XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
when: mail.sync_on == "all"
tags:
- mailsync
- name: Remove mailsync from trusted unit list
lineinfile: dest=/etc/nmtrust/trusted_units
state=absent
line="mailsync.timer,user:{{ user.name }}"
when: mail.sync_on == "all"
tags:
- mailsync
- name: Disable mailsync timer
systemd: name=mailsync.timer user=yes enabled=no
become: yes
become_user: "{{ user.name }}"
environment:
XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}"
when: mail.sync_on == "trusted"
tags:
- mailsync
- name: Add mailsync to trusted unit list
lineinfile: dest=/etc/nmtrust/trusted_units
state=present
line="mailsync.timer,user:{{ user.name }}"
when: mail.sync_on == "trusted"
tags:
- mailsync