summaryrefslogtreecommitdiffstats
path: root/roles/munin-master/tasks/main.yml
blob: 6dad93b759e97fabbbae9746aaea1abc1d8e1509 (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
- name: Install munin
  apt: pkg={{ packages }}
  vars:
    packages:
    - munin
    - rrdcached
    - libcgi-fast-perl

- name: Configure rrdcached
  lineinfile: "dest=/etc/default/rrdcached
               regexp='^#?{{ item.name }}='
               line='{{ item.name }}=\"{{ item.value }}\"'"
  with_items:
    - { name: 'BASE_OPTIONS',  value: '-B -F'               }
    - { name: 'BASE_PATH',     value: '/var/lib/munin'      }
    - { name: 'SOCKFILE',      value: '/run/rrdcached.sock' }
    - { name: 'SOCKGROUP',     value: 'munin'               }
    - { name: 'SOCKMODE',      value: '0660'                }
    - { name: 'WRITE_TIMEOUT', value: '1800'                }
  register: r
  notify:
    - Restart rrdcached

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

- meta: flush_handlers

- name: Create directory /var/lib/munin/cgi-tmp/munin-cgi-graph
  file: path=/var/lib/munin/cgi-tmp/munin-cgi-graph
        state=directory
        owner=www-data group=www-data
        mode=0755

- 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=etc/systemd/system/{{ item }}
        dest=/etc/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=etc/systemd/system/{{ item }}
        dest=/etc/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: 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