--- - name: Install Prometheus node-exporter apt: update_cache: true name: prometheus-node-exporter install_recommends: false # Do not install smartmontools register: apt_result retries: 3 until: apt_result is succeeded when: - ansible_lsb.codename != 'stretch' # Prometheus 2 node is in stretch-backports - name: Install Prometheus node-exporter (stretch-backports) apt: update_cache: true name: prometheus-node-exporter install_recommends: false default_release: stretch-backports register: apt_result retries: 3 until: apt_result is succeeded when: - ansible_lsb.codename == 'stretch' - name: Activate prometheus-node-exporter service systemd: name: prometheus-node-exporter enabled: true state: started # Doesn't work on Debian Stretch with the old prometheus package - name: Make Prometheus node-exporter listen on adm only lineinfile: path: /etc/default/prometheus-node-exporter regexp: '^ARGS=' line: | ARGS="--web.listen-address={{ ansible_hostname }}.adm.auro.re:9100" notify: Restart prometheus-node-exporter - name: Add monitoring for apt on bullseye block: - name: Install moreutils # we need the sponge command apt: name: - moreutils state: latest update_cache: true register: apt_result retries: 3 until: apt_result is succeeded - name: Ensure /usr/share/prometheus-node-exporter exist file: path: /usr/share/prometheus-node-exporter/ state: directory group: root owner: root mode: u=rwx,g=rx,o=rx - name: Add the script copy: src: apt.sh dest: /usr/share/prometheus-node-exporter/apt.sh group: root owner: root mode: u=rwx,g=rx,o=rx - name: Add the timer copy: src: prometheus-node-exporter-apt.timer dest: /lib/systemd/system/prometheus-node-exporter-apt.timer group: root owner: root mode: u=rw,g=r,o=r - name: Add the service copy: src: prometheus-node-exporter-apt.service dest: /lib/systemd/system/prometheus-node-exporter-apt.service group: root owner: root mode: u=rw,g=r,o=r - name: Enable the timer systemd: name: prometheus-node-exporter-apt.timer state: started enabled: true when: ansible_facts['lsb']['codename'] == 'bullseye'