Commit initial

This commit is contained in:
Navas 2022-06-12 23:07:03 +02:00
commit acee1d5044
6 changed files with 81 additions and 0 deletions

23
README.md Normal file
View file

@ -0,0 +1,23 @@
# Role : nodeexporter
## Services fournis
- main.yml : Installation de nodeexporter sur un serveur avec rôle common
## Variables
```yaml
nodeexporter_base_url: https://github.com/prometheus/node_exporter/releases/download/v1.3.1
nodeexporter_package: node_exporter-1.3.1.linux-amd64
```
| Option | Valeur par défaut | Description |
|-----------------------------|-------------------|-------------------------------------------------------------|
| nodeexporter_port | 9100 | Le numero de port local pour l'accès à nodeexporter |
| nodeexporter_base_url | | La base de l'url depuis laquelle télécharger le package |
| nodeexporter_package | | Le nom du package nodeexporter à installer, sans le suffixe |
| nodeexporter_package_suffix | .tar.gz | Le suffixe du package nodeexporter |

2
defaults/main.yml Normal file
View file

@ -0,0 +1,2 @@
nodeexporter_port: "9100"
nodeexporter_package_suffix: .tar.gz

6
handlers/main.yml Normal file
View file

@ -0,0 +1,6 @@
- name: nodeexporter-restart
systemd:
name: node_exporter
daemon_reload: yes
state: restarted
enabled: yes

39
tasks/main.yml Normal file
View file

@ -0,0 +1,39 @@
- name: Download nodeexporter
get_url:
url: "{{ nodeexporter_base_url }}/{{ nodeexporter_package }}{{ nodeexporter_package_suffix }}"
dest: /tmp/
mode: '0444'
delegate_to: localhost
- name: create user node_exporter
user:
name: node_exporter
system: yes
shell: /bin/false
create_home: no
- name: Extract nodeexporter
ansible.builtin.unarchive:
src: /tmp/{{ nodeexporter_package }}{{ nodeexporter_package_suffix }}
dest: /usr/local/sbin/
remote_src: no
mode: 0755
owner: root
extra_opts:
- "--strip-components"
- "1"
- "{{ nodeexporter_package }}/node_exporter"
notify: nodeexporter-restart
- name: prepare systemd
template:
src: node_exporter.service
dest: /etc/systemd/system/node_exporter.service
notify: nodeexporter-restart
- name: prepare config
template:
src: node_exporter.default
dest: /etc/default/node_exporter
notify: nodeexporter-restart

View file

@ -0,0 +1 @@
OPTIONS="--collector.textfile.directory /var/lib/node_exporter/textfile_collector"

View file

@ -0,0 +1,10 @@
[Unit]
Description=Node Exporter
[Service]
User=node_exporter
EnvironmentFile=/etc/default/node_exporter
ExecStart=/usr/local/sbin/node_exporter $OPTIONS
[Install]
WantedBy=multi-user.target