feat: add node_exporter role and integrate into site playbook
OpenVPN Ansible / Ansible Lint (push) Failing after 14s
OpenVPN Ansible / Ansible Syntax Check (push) Failing after 14s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Skipped
OpenVPN Ansible / Generate SBOM (push) Skipped
OpenVPN Ansible / Scan SBOM with Trivy (push) Skipped
OpenVPN Ansible / Ansible Lint (push) Failing after 14s
OpenVPN Ansible / Ansible Syntax Check (push) Failing after 14s
OpenVPN Ansible / Deploy VPN Networking and OpenVPN (push) Skipped
OpenVPN Ansible / Generate SBOM (push) Skipped
OpenVPN Ansible / Scan SBOM with Trivy (push) Skipped
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
---
|
||||
- name: Require the monitoring VM private source address
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- monitoring_vm_ip is defined
|
||||
- monitoring_vm_ip | length > 0
|
||||
fail_msg: Set monitoring_vm_ip to the monitoring VM's 10.100.0.x address.
|
||||
tags: [monitoring]
|
||||
|
||||
- name: Install node exporter package
|
||||
ansible.builtin.apt:
|
||||
name: prometheus-node-exporter
|
||||
state: present
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
tags: [monitoring]
|
||||
|
||||
- name: Install iptables persistence packages
|
||||
ansible.builtin.apt:
|
||||
name: [iptables, iptables-persistent]
|
||||
state: present
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
environment:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
tags: [monitoring]
|
||||
|
||||
- name: Create node exporter textfile directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ node_exporter_textfile_dir }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
tags: [monitoring]
|
||||
|
||||
- name: Configure node exporter arguments
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/default/prometheus-node-exporter
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
content: >-
|
||||
ARGS="--web.listen-address={{ node_exporter_listen_address }}:{{ node_exporter_port }}
|
||||
{% for collector in node_exporter_collectors %}--collector.{{ collector }} {% endfor %}
|
||||
--collector.systemd.unit-include={{ node_exporter_systemd_unit_filter }}
|
||||
--collector.textfile.directory={{ node_exporter_textfile_dir }}"
|
||||
notify: Restart node exporter
|
||||
tags: [monitoring]
|
||||
|
||||
- name: Allow monitoring VM to access node exporter
|
||||
ansible.builtin.iptables:
|
||||
chain: INPUT
|
||||
protocol: tcp
|
||||
destination_port: "{{ node_exporter_port }}"
|
||||
source: "{{ node_exporter_allowed_source }}"
|
||||
jump: ACCEPT
|
||||
comment: Allow monitoring VM node exporter
|
||||
action: insert
|
||||
rule_num: 1
|
||||
register: node_exporter_allow_rule
|
||||
tags: [monitoring]
|
||||
when: node_exporter_manage_firewall
|
||||
|
||||
- name: Drop other node exporter access
|
||||
ansible.builtin.iptables:
|
||||
chain: INPUT
|
||||
protocol: tcp
|
||||
destination_port: "{{ node_exporter_port }}"
|
||||
jump: DROP
|
||||
comment: Drop other node exporter access
|
||||
action: insert
|
||||
rule_num: 2
|
||||
register: node_exporter_drop_rule
|
||||
tags: [monitoring]
|
||||
when: node_exporter_manage_firewall
|
||||
|
||||
- name: Persist node exporter firewall rules
|
||||
ansible.builtin.command: netfilter-persistent save
|
||||
when:
|
||||
- node_exporter_manage_firewall
|
||||
- node_exporter_allow_rule is changed or node_exporter_drop_rule is changed
|
||||
changed_when: true
|
||||
tags: [monitoring]
|
||||
|
||||
- name: Enable and start node exporter
|
||||
ansible.builtin.systemd:
|
||||
name: prometheus-node-exporter
|
||||
state: started
|
||||
enabled: true
|
||||
tags: [monitoring]
|
||||
Reference in New Issue
Block a user