diff --git a/roles/router-telegraf/files/telegraf.conf b/roles/router-telegraf/files/telegraf.conf new file mode 100644 index 0000000..b65d9a0 --- /dev/null +++ b/roles/router-telegraf/files/telegraf.conf @@ -0,0 +1,21 @@ +[agent] + hostname = "router" + interval = "1m" + debug = false + quiet = false + logtarget = "stderr" +[[outputs.prometheus_client]] + listen = ":9273" +[[inputs.cpu]] + percpu = false + report_active = true +[[inputs.system]] +[[inputs.mem]] +[[inputs.net]] +[[inputs.exec]] + command = "sh /usr/lib/telegraf/edgeos.sh --interfaces" + data_format = "influx" +[[inputs.exec]] + command = "sh /usr/lib/telegraf/edgeos.sh --firmware" + data_format = "influx" + interval = "24h" diff --git a/roles/router-telegraf/tasks/install_telegraf.yml b/roles/router-telegraf/tasks/install_telegraf.yml new file mode 100644 index 0000000..e0f413e --- /dev/null +++ b/roles/router-telegraf/tasks/install_telegraf.yml @@ -0,0 +1,31 @@ +--- +- name: Download telegraf + get_url: + url: https://github.com/x70b1/telegraf-edgeos/releases/download/v{{ telegraf.release }}/telegraf_{{ telegraf.release }}+{{ telegraf.flavour }}_{{ telegraf.arch }}.deb + dest: /tmp/telegraf.deb + +- name: Install telegraf + shell: + cmd: dpkg -i /tmp/telegraf.deb + +- name: create directory for configuration + file: + path: "/etc/telegraf" + state: directory + mode: 0755 + +- name: copy configuration + copy: + src: "telegraf.conf" + dest: "/etc/telegraf/telegraf.conf" + +- name: start and enable telegraf + systemd: + name: docker + state: started + enabled: true + +- name: Remove telegraf.deb file + file: + path: /tmp/telegraf.deb + state: absent \ No newline at end of file diff --git a/roles/router-telegraf/tasks/main.yml b/roles/router-telegraf/tasks/main.yml new file mode 100644 index 0000000..eb9c681 --- /dev/null +++ b/roles/router-telegraf/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- import_tasks: install_telegraf.yml + become: yes diff --git a/roles/router-telegraf/vars/main.yml b/roles/router-telegraf/vars/main.yml new file mode 100644 index 0000000..7959425 --- /dev/null +++ b/roles/router-telegraf/vars/main.yml @@ -0,0 +1,5 @@ +--- +telegraf: + release: 1.26.2-1 + flavour: prometheus + arch: mipsel \ No newline at end of file