]> git.somenet.org - root/pub/somesible.git/blob - roles/base/munin-node/tasks/main.yml
[roles/base/munin-node] munin node + async proxy setup
[root/pub/somesible.git] / roles / base / munin-node / tasks / main.yml
1 #####################################
2 ### someone"s ansible provisioner ###
3 #####################################
4 # Part of: https://git.somenet.org/root/pub/somesible.git
5 # 2017-2025 by someone <someone@somenet.org>
6 #
7 # Install munin-node and munin-async.
8 #
9 ---
10 - name: install munin
11   apt:
12     pkg:
13     - munin-async
14     - munin-node
15     - munin-plugins-extra
16     state: present
17     policy_rc_d: 101
18   when: munin_node_setup | bool
19   tags: "online"
20
21
22 - name: create munin-plugins dir
23   file:
24     path: "/opt/somesible/munin-plugins"
25     state: directory
26     mode: 0755
27     owner: "root"
28     group: "root"
29   when: munin_node_setup | bool
30
31
32 - name: copy custom plugins
33   copy:
34     src:  "{{item.src}}"
35     dest: "/opt/somesible/munin-plugins/{{item.path}}"
36     mode: 0755
37     owner: "root"
38     group: "root"
39   with_filetree:
40     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/plugins.somesible/"
41     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/plugins.somesible/"
42     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/plugins.somesible/"
43     - "default/plugins.somesible/"
44   when: munin_node_setup | bool and item.state == "file"
45   notify: restart munin-node.service and munin-async.service
46
47
48 - name: list files in /etc/munin/plugins
49   shell: "ls -1 /etc/munin/plugins"
50   register: contents
51   when: munin_node_setup | bool
52   changed_when: False
53
54
55 - name: remove unmanaged files in /etc/munin/plugins
56   file:
57     path: "/etc/munin/plugins/{{item}}"
58     state: absent
59   with_items: "{{contents.stdout_lines}}"
60   when: munin_node_setup | bool and item not in munin_node_plugins.keys() | list and item not in munin_node_plugins_extra.keys() | list
61   notify: restart munin-node.service and munin-async.service
62
63
64 - name: symlink new files into /etc/munin/plugins
65   file:
66     dest: "/etc/munin/plugins/{{item.key}}"
67     src: "{{item.value}}"
68     force: yes
69     owner: "root"
70     group: "root"
71     state: link
72   loop: "{{ lookup('dict', munin_node_plugins|combine(munin_node_plugins_extra)) }}"
73   when: munin_node_setup | bool
74   notify: restart munin-node.service and munin-async.service
75
76
77 - name: copy plugin-conf.d/munin-node
78   copy:
79     src:  "{{item}}"
80     dest: "/etc/munin/plugin-conf.d/munin-node"
81     mode: 0644
82     owner: "root"
83     group: "root"
84   with_first_found:
85     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/plugin-confd.munin-node.conf"
86     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/plugin-confd.munin-node.conf"
87     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/plugin-confd.munin-node.conf"
88     - "default/plugin-confd.munin-node.conf"
89   when: munin_node_setup | bool
90   notify: restart munin-node.service and munin-async.service
91
92
93 - name: copy munin-node.service to /etc/systemd/system/
94   copy:
95     src: "{{item}}"
96     dest: "/etc/systemd/system/munin-node.service"
97     mode: 0644
98     owner: "root"
99     group: "root"
100   with_first_found:
101     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/munin-node.service"
102     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/munin-node.service"
103     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/munin-node.service"
104     - "default/munin-node.service"
105   when: munin_node_setup | bool
106   notify: restart munin-node.service and munin-async.service
107
108
109 - name: create munin-async home and fix ownership
110   file:
111     path: "/var/lib/munin-async/"
112     state: directory
113     recurse: yes
114     owner: "munin-async"
115     group: "munin-async"
116   when: munin_node_setup | bool
117
118
119 - name: create .ssh-dir
120   file:
121     path: "/var/lib/munin-async/.ssh"
122     state: directory
123     mode: 0700
124     owner: "munin-async"
125     group: "munin-async"
126   when: munin_node_setup | bool
127
128
129 - name: copy authorized_keys to /var/lib/munin-async/.ssh/authorized_keys
130   copy:
131     src: "{{item}}"
132     dest: "/var/lib/munin-async/.ssh/authorized_keys"
133     mode: 0600
134     owner: "munin-async"
135     group: "munin-async"
136   with_first_found:
137     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/authorized_keys"
138     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/authorized_keys"
139     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/authorized_keys"
140     - "default/authorized_keys"
141   when: munin_node_setup | bool
142
143
144 - name: copy munin-async.service to /etc/systemd/system/
145   copy:
146     src: "{{item}}"
147     dest: "/etc/systemd/system/munin-async.service"
148     mode: 0644
149     owner: "root"
150     group: "root"
151   with_first_found:
152     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/munin-async.service"
153     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/munin-async.service"
154     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/munin-async.service"
155     - "default/munin-async.service"
156   when: munin_node_setup | bool
157   notify: restart munin-node.service and munin-async.service
158
159
160 - name: enable and start munin-node.service
161   include_role: name="base/systemd/enable-and-start"
162   vars:
163     service_name: munin-node.service
164   when: munin_node_setup | bool
165
166
167 - name: enable and start munin-async.service
168   include_role: name="base/systemd/enable-and-start"
169   vars:
170     service_name: munin-async.service
171   when: munin_node_setup | bool