--- # Installs Telegraf and configures it to collect Unbound stats (via # unbound-control) and expose them as Prometheus metrics on # telegraf_prometheus_port for the central Prometheus server to scrape. - name: Import InfluxData package signing key (RedHat) ansible.builtin.rpm_key: key: "{{ telegraf_influxdata_gpgkey }}" state: present when: ansible_facts['os_family'] == "RedHat" - name: Add InfluxData package repository (RedHat) ansible.builtin.yum_repository: name: influxdata description: InfluxData Repository - Stable baseurl: "{{ telegraf_influxdata_baseurl }}" gpgcheck: true gpgkey: "{{ telegraf_influxdata_gpgkey }}" enabled: true when: ansible_facts['os_family'] == "RedHat" - name: Install Telegraf (RedHat) ansible.builtin.dnf: name: telegraf state: present when: ansible_facts['os_family'] == "RedHat" - name: Deploy Telegraf configuration ansible.builtin.template: src: telegraf.conf.j2 dest: /etc/telegraf/telegraf.conf owner: root group: root mode: "0644" notify: Restart telegraf - name: Allow Prometheus scrape of the metrics port from the scrape subnet (firewalld) ansible.posix.firewalld: zone: public rich_rule: >- rule family="ipv4" source address="{{ telegraf_scrape_allow_cidr }}" port port="{{ telegraf_prometheus_port }}" protocol="tcp" accept permanent: true immediate: true state: enabled when: ansible_facts['os_family'] == "RedHat" - name: Enable and start Telegraf ansible.builtin.systemd: name: telegraf state: started enabled: true daemon_reload: true