]> git.somenet.org - root/pub/somesible.git/blob - roles/base/munin-node/tasks/main.yml
roles/base/munin-node/files
[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-2026 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.conf
94   copy:
95     src:  "{{item}}"
96     dest: "/etc/munin/munin-node.conf"
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.conf"
102     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/munin-node.conf"
103     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}munin-node.conf"
104     - "default/munin-node.conf"
105   when: munin_node_setup | bool
106   notify: restart munin-node.service and munin-async.service
107
108
109 - name: copy munin-node.service to /etc/systemd/system/
110   copy:
111     src: "{{item}}"
112     dest: "/etc/systemd/system/munin-node.service"
113     mode: 0644
114     owner: "root"
115     group: "root"
116   with_first_found:
117     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/munin-node.service"
118     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/munin-node.service"
119     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/munin-node.service"
120     - "default/munin-node.service"
121   when: munin_node_setup | bool
122   notify: restart munin-node.service and munin-async.service
123
124
125 - name: create munin-async home and fix ownership
126   file:
127     path: "/var/lib/munin-async/"
128     state: directory
129     recurse: yes
130     owner: "munin-async"
131     group: "munin-async"
132   when: munin_node_setup | bool
133
134
135 - name: create .ssh-dir
136   file:
137     path: "/var/lib/munin-async/.ssh"
138     state: directory
139     mode: 0700
140     owner: "munin-async"
141     group: "munin-async"
142   when: munin_node_setup | bool
143
144
145 - name: copy authorized_keys to /var/lib/munin-async/.ssh/authorized_keys
146   copy:
147     src: "{{item}}"
148     dest: "/var/lib/munin-async/.ssh/authorized_keys"
149     mode: 0600
150     owner: "munin-async"
151     group: "munin-async"
152   with_first_found:
153     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/authorized_keys"
154     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/authorized_keys"
155     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/authorized_keys"
156     - "default/authorized_keys"
157   when: munin_node_setup | bool
158
159
160 - name: copy munin-async.service to /etc/systemd/system/
161   copy:
162     src: "{{item}}"
163     dest: "/etc/systemd/system/munin-async.service"
164     mode: 0644
165     owner: "root"
166     group: "root"
167   with_first_found:
168     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/munin-async.service"
169     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/munin-async.service"
170     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/munin-async.service"
171     - "default/munin-async.service"
172   when: munin_node_setup | bool
173   notify: restart munin-node.service and munin-async.service
174
175
176 - name: enable and start munin-node.service
177   include_role: name="base/systemd/enable-and-start"
178   vars:
179     service_name: munin-node.service
180   when: munin_node_setup | bool
181
182
183 - name: enable and start munin-async.service
184   include_role: name="base/systemd/enable-and-start"
185   vars:
186     service_name: munin-async.service
187   when: munin_node_setup | bool