summaryrefslogtreecommitdiffstats
path: root/roles/munin-master/tasks/main.yml
blob: 5dd11517e2418ff1525f7cde3eb6e93338c8fbd8 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
- name: Install munin
  apt: pkg={{ item }}
  with_items:
    - munin
    - rrdcached
    - libcgi-fast-perl

- name: Configure rrdcached
  lineinfile: "dest=/etc/default/rrdcached
               regexp='^#?OPTS='
               line='OPTS=\"-s munin -m 660 -l unix:/var/run/rrdcached.sock -w 1800 -z 1800 -f 3600 -j /var/lib/rrdcached/journal -F -b /var/lib/munin -B\"'"
  register: r
  notify:
    - Restart rrdcached

- name: Start rrdcached
  service: name=rrdcached state=started
  when: not r.changed

- meta: flush_handlers


- name: Configure munin
  template: src=etc/munin/munin.conf.j2
            dest=/etc/munin/munin.conf
            owner=root group=root
            mode=0644
  notify:
    - Restart munin-cgi-graph
    - Restart munin-cgi-html

- name: chown www-data:adm /var/log/munin/munin-cgi-{graph,html}.log
  file: path=/var/log/munin/{{ item }}
        owner=www-data group=adm
        mode=0640
  with_items:
    - munin-cgi-graph.log
    - munin-cgi-html.log

- name: Copy munin-cgi-graph.{service,socket}
  copy: src=lib/systemd/system/{{ item }}
        dest=/lib/systemd/system/{{ item }}
        owner=root group=root
        mode=0644
  notify:
    - systemctl daemon-reload
    - Restart munin-cgi-graph
  with_items:
    - munin-cgi-graph.service
    - munin-cgi-graph.socket

- name: Copy munin-cgi-html.{service,socket}
  copy: src=lib/systemd/system/{{ item }}
        dest=/lib/systemd/system/{{ item }}
        owner=root group=root
        mode=0644
  notify:
    - systemctl daemon-reload
    - Restart munin-cgi-html
  with_items:
    - munin-cgi-html.service
    - munin-cgi-html.socket

- meta: flush_handlers

- name: Start munin-cgi-{graph,html}
  service: name={{ item }} state=started enabled=yes
  with_items:
    - munin-cgi-graph
    - munin-cgi-html


- name: Copy /etc/nginx/sites-available/munin
  copy: src=etc/nginx/sites-available/munin
        dest=/etc/nginx/sites-available/munin
        owner=root group=root
        mode=0644
  register: r1
  notify:
    - Restart Nginx

- name: Create /etc/nginx/sites-enabled/munin
  file: src=../sites-available/munin
        dest=/etc/nginx/sites-enabled/munin
        owner=root group=root
        state=link force=yes
  register: r2
  notify:
    - Restart Nginx

- name: Start Nginx
  service: name=nginx state=started
  when: not (r1.changed or r2.changed)

- meta: flush_handlers


- name: Copy munin-node X.509 certificates
  copy: src=certs/munin/{{ item }}.pem
        dest=/etc/stunnel/certs/munin-{{ hostvars[item].inventory_hostname_short }}.pem
        owner=root group=root
        mode=0644
  with_items: groups.all | difference([inventory_hostname])
  register: r1
  notify:
    - Restart stunnel

- name: Configure stunnel
  template: src=etc/stunnel/munin-master.conf.j2
            dest=/etc/stunnel/munin-master.conf
            owner=root group=root
            mode=0644
  register: r2
  notify:
    - Restart stunnel

- name: Start stunnel
  service: name=stunnel4 pattern=/usr/bin/stunnel4 state=started
  when: not (r1.changed or r2.changed)

- meta: flush_handlers


- name: Install 'munin_stats' and 'munin_update' plugins
  file: src=/usr/share/munin/plugins/{{ item }}
        dest=/etc/munin/plugins/{{ item }}
        owner=root group=root
        state=link force=yes
  with_items:
    - munin_stats
    - munin_update
  tags:
    - munin-node
    - munin
  notify:
    - Restart munin-node