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