diff --git a/ansible/galaxy-requirements.yml b/ansible/galaxy-requirements.yml index 2cfe7f9..01c5e2f 100644 --- a/ansible/galaxy-requirements.yml +++ b/ansible/galaxy-requirements.yml @@ -2,6 +2,7 @@ collections: - ansible.posix - community.general - community.docker + - amazon.aws # Dependency of rossmcdonald.telegraf roles: - src: geerlingguy.docker @@ -10,3 +11,4 @@ roles: - src: https://github.com/IronicBadger/ansible-role-proxmox-nag-removal name: proxmox-nag-removal - src: chmduquesne.iptables_persistent + - src: rossmcdonald.telegraf diff --git a/ansible/group_vars/all/pve.yml b/ansible/group_vars/all/pve.yml index cc5cbca..e0c9cde 100644 --- a/ansible/group_vars/all/pve.yml +++ b/ansible/group_vars/all/pve.yml @@ -15,3 +15,6 @@ pve_hosts: internal_ip: 10.23.1.99 deluge: internal_ip: 10.23.1.52 + pve: + internal_ip: 10.23.1.1 + ip: 192.168.2.200 diff --git a/ansible/host_vars/pve.yml b/ansible/host_vars/pve.yml index b68272e..d5de81a 100644 --- a/ansible/host_vars/pve.yml +++ b/ansible/host_vars/pve.yml @@ -1,5 +1,8 @@ expose_ssh: true +private_ip: "{{ pve_hosts.pve.ip }}" +protected_ip: "{{ pve_hosts.pve.internal_ip }}" + zpools_to_scrub: - tank - rpool diff --git a/ansible/main.yml b/ansible/main.yml index 6e702a6..9ca4949 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -76,6 +76,7 @@ - pve - zfs - pve_nebula_route + - telegraf - hosts: forrest roles: diff --git a/ansible/roles/forrest/files/prometheus/prometheus.yml b/ansible/roles/forrest/files/prometheus/prometheus.yml index 3941499..82665ab 100644 --- a/ansible/roles/forrest/files/prometheus/prometheus.yml +++ b/ansible/roles/forrest/files/prometheus/prometheus.yml @@ -7,7 +7,7 @@ scrape_configs: static_configs: - targets: - - telegraf:9273 + - 10.23.1.1:9273 - job_name: traefik metric_relabel_configs: - source_labels: [__name__] diff --git a/ansible/roles/forrest/files/telegraf/docker-compose.yml b/ansible/roles/forrest/files/telegraf/docker-compose.yml deleted file mode 100644 index 8a16720..0000000 --- a/ansible/roles/forrest/files/telegraf/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: "2.3" - -services: - telegraf: - image: telegraf:alpine - restart: unless-stopped - networks: - - default - - prometheus - volumes: - - ./telegraf.conf:/etc/telegraf/telegraf.conf:ro - -networks: - prometheus: - external: true diff --git a/ansible/roles/forrest/tasks/main.yml b/ansible/roles/forrest/tasks/main.yml index 04a7d45..8b35f5a 100644 --- a/ansible/roles/forrest/tasks/main.yml +++ b/ansible/roles/forrest/tasks/main.yml @@ -6,6 +6,3 @@ - name: Prometheus include: prometheus.yml - -- name: Telegraf - include: telegraf.yml diff --git a/ansible/roles/forrest/tasks/telegraf.yml b/ansible/roles/forrest/tasks/telegraf.yml deleted file mode 100644 index 217fd0f..0000000 --- a/ansible/roles/forrest/tasks/telegraf.yml +++ /dev/null @@ -1,26 +0,0 @@ -- name: Create telegraf install directory - file: - path: /opt/telegraf - state: directory - owner: "{{ docker_user.name }}" - mode: "{{ docker_compose_directory_mask }}" - become: true - -- name: Install telegraf config - template: - src: files/telegraf/telegraf.conf - dest: /opt/telegraf/telegraf.conf - mode: "{{ docker_compose_file_mask }}" - owner: "{{ docker_user.name }}" - notify: restart telegraf - become: true - -- name: Install telegraf compose file - template: - src: files/telegraf/docker-compose.yml - dest: /opt/telegraf/docker-compose.yml - mode: "{{ docker_compose_file_mask }}" - owner: "{{ docker_user.name }}" - validate: docker-compose -f %s config - notify: restart telegraf - become: true diff --git a/ansible/roles/forrest/files/telegraf/telegraf.conf b/ansible/roles/telegraf/files/telegraf.conf similarity index 99% rename from ansible/roles/forrest/files/telegraf/telegraf.conf rename to ansible/roles/telegraf/files/telegraf.conf index a1dcd2b..563554e 100644 --- a/ansible/roles/forrest/files/telegraf/telegraf.conf +++ b/ansible/roles/telegraf/files/telegraf.conf @@ -85,7 +85,7 @@ ############################################################################### [[outputs.prometheus_client]] - listen = ":9273" + listen = "{{ protected_ip }}:9273" metric_version = 2 diff --git a/ansible/roles/telegraf/tasks/main.yml b/ansible/roles/telegraf/tasks/main.yml new file mode 100644 index 0000000..b80d1d0 --- /dev/null +++ b/ansible/roles/telegraf/tasks/main.yml @@ -0,0 +1,4 @@ +- name: Install and configure telegraf + import_role: + name: rossmcdonald.telegraf + become: true diff --git a/ansible/roles/telegraf/vars/main.yml b/ansible/roles/telegraf/vars/main.yml new file mode 100644 index 0000000..350ee4f --- /dev/null +++ b/ansible/roles/telegraf/vars/main.yml @@ -0,0 +1,2 @@ +telegraf_configuration_template: files/telegraf.conf +telegraf_aws_tags: false