diff --git a/node_exporter/defaults/main.yml b/node_exporter/defaults/main.yml index 64192f55f057c3f5ed24d5fc22a24edfe932adae..a8c1c89c1fa91b8ba6a4c52680286d1bfaaa5d8f 100644 --- a/node_exporter/defaults/main.yml +++ b/node_exporter/defaults/main.yml @@ -1,2 +1,3 @@ --- node_exporter_args: "" +force_smartmontools_on_vm_guest: false diff --git a/node_exporter/tasks/main.yml b/node_exporter/tasks/main.yml index 0f2fccccd2bcf355b66a75a218bf9b4292147093..e6d83a20237e9671f1b8134a1038622efd3e6974 100644 --- a/node_exporter/tasks/main.yml +++ b/node_exporter/tasks/main.yml @@ -19,6 +19,26 @@ - prometheus - prometheus-exporter +- name: Install additional node_exporter collectors + apt: + name: prometheus-node-exporter-collectors + state: present + when: ansible_distribution_major_version|int >= 11 + tags: + - prometheus + - prometheus-exporter + +- name: Ensure smartmontools is present only on bare-metal hosts + apt: + name: smartmontools + state: >- + {% if force_smartmontools_on_vm_guest or (ansible_virtualization_role is defined + and not ansible_virtualization_role == "guest") -%} + present + {%- else -%} + absent + {%- endif %} + - name: Configure node_exporter template: src: prometheus-node-exporter.j2