diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8aaad7d..3385023 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ name: CI defaults: run: - working-directory: 'geerlingguy.node_exporter' + working-directory: 'vgrid.frr_exporter' jobs: @@ -21,7 +21,7 @@ jobs: - name: Check out the codebase. uses: actions/checkout@v4 with: - path: 'geerlingguy.node_exporter' + path: 'vgrid.frr_exporter' - name: Set up Python 3. uses: actions/setup-python@v5 @@ -49,7 +49,7 @@ jobs: - name: Check out the codebase. uses: actions/checkout@v4 with: - path: 'geerlingguy.node_exporter' + path: 'vgrid.frr_exporter' - name: Set up Python 3. uses: actions/setup-python@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a999f18..355517c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ name: Release defaults: run: - working-directory: 'geerlingguy.node_exporter' + working-directory: 'vgrid.frr_exporter' jobs: @@ -24,7 +24,7 @@ jobs: - name: Check out the codebase. uses: actions/checkout@v4 with: - path: 'geerlingguy.node_exporter' + path: 'vgrid.frr_exporter' - name: Set up Python 3. uses: actions/setup-python@v5 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 767bd10..0000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -name: Close inactive issues -'on': - schedule: - - cron: "55 17 * * 6" # semi-random time - -jobs: - close-issues: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/stale@v8 - with: - days-before-stale: 120 - days-before-close: 60 - exempt-issue-labels: bug,pinned,security,planned - exempt-pr-labels: bug,pinned,security,planned - stale-issue-label: "stale" - stale-pr-label: "stale" - stale-issue-message: | - This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! - - Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. - close-issue-message: | - This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. - stale-pr-message: | - This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! - - Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. - close-pr-message: | - This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. - repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index aee484a..25e068b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -# Ansible Role: Node exporter +# Ansible Role: FRR exporter -[![CI](https://github.com/geerlingguy/ansible-role-node_exporter/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-node_exporter/actions?query=workflow%3ACI) +[![CI](https://github.com/vgrid/ansible-role-frr_exporter/workflows/CI/badge.svg?event=push)](https://github.com/vgrid/ansible-role-frr_exporter/actions?query=workflow%3ACI) -This role installs Prometheus' [Node exporter](https://github.com/prometheus/node_exporter) on Linux hosts, and configures a systemd unit file so the service can run and be controlled by systemd. +This role installs Prometheus' [FRR Exporter](https://github.com/tynany/frr_exporter) on Linux hosts, and configures a systemd unit file so the service can run and be controlled by systemd. -**Note**: If you're running in a Kubernetes cluster, you could run Node exporter as a DaemonSet in the cluster, instead of installing it on individual nodes. +## Credit + +This role is a modified version of the ansible-role-node exporter by by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). Thanks to Jeff it was very quick to get this up and running. ## Requirements @@ -14,34 +16,34 @@ N/A Available variables are listed below, along with default values (see `defaults/main.yml`): - node_exporter_version: '0.18.1' + frr_exporter_version: '1.1.3' -The version of Node exporter to install. Available releases can be found on the [tags](https://github.com/prometheus/node_exporter/tags) listing in the Node exporter repository. Drop the `v` off the tag. +The version of FRR Exporter to install. Available releases can be found on the [tags](https://github.com/tynany/frr_exporter/tags) listing in the FRR Exporter repository. Drop the `v` off the tag. -If you change the version, the `node_exporter` binary will be replaced with the updated version, and the service will be restarted. +If you change the version, the `frr_exporter` binary will be replaced with the updated version, and the service will be restarted. - node_exporter_arch: 'amd64' - node_exporter_download_url: https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ node_exporter_arch }}.tar.gz + frr_exporter_arch: 'amd64' + frr_exporter_download_url: https://github.com/tynany/frr_exporter/releases/download/v{{ frr_exporter_version }}/frr_exporter-{{ frr_exporter_version }}.linux-{{ frr_exporter_arch }}.tar.gz -The architecture and download URL for Node exporter. If you're on a Raspberry Pi running Raspbian, you may need to override the `arch` value with `armv7`. +The architecture and download URL for FRR Exporter. If you're on a Raspberry Pi running Raspbian, you may need to override the `arch` value with `armv7`. - node_exporter_bin_path: /usr/local/bin/node_exporter + frr_exporter_bin_path: /usr/local/bin/frr_exporter -The path where the `node_exporter` binary will be installed. +The path where the `frr_exporter` binary will be installed. - node_exporter_host: 'localhost' - node_exporter_port: 9100 + frr_exporter_host: 'localhost' + frr_exporter_port: 9100 -Host and port on which node exporter will listen. +Host and port on which FRR Exporter will listen. - node_exporter_options: '' + frr_exporter_options: '' -Any additional options to pass to `node_exporter` when it starts, e.g. `--no-collector.wifi` if you want to ignore any WiFi data. +Any additional options to pass to `frr_exporter` when it starts, e.g. `--no-collector.bgp` if you want to ignore BGP collection - node_exporter_state: started - node_exporter_enabled: true + frr_exporter_state: started + frr_exporter_enabled: true -Controls for the `node_exporter` service. +Controls for the `frr_exporter` service. ## Dependencies @@ -51,12 +53,9 @@ None. - hosts: all roles: - - role: geerlingguy.node_exporter + - role: vgrid.frr_exporter ## License MIT / BSD -## Author Information - -This role was created in 2020 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/defaults/main.yml b/defaults/main.yml index 274bc69..c9f6979 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,21 +1,21 @@ --- -# Use the latest node_exporter release -node_exporter_version: 'latest' +# Use the latest frr_exporter release +frr_exporter_version: 'latest' # Alternatively, set a specific version -# See available releases: https://github.com/prometheus/node_exporter/releases/ -# node_exporter_version: '0.18.1' +# See available releases: https://github.com/tynany/frr_exporter/releases/ +# frr_exporter_version: '1.1.3' -node_exporter_arch: 'amd64' -node_exporter_download_url: https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ node_exporter_arch }}.tar.gz +frr_exporter_arch: 'amd64' +frr_exporter_download_url: https://github.com/tynany/frr_exporter/releases/download/v{{ frr_exporter_version }}/frr_exporter-{{ frr_exporter_version }}.linux-{{ frr_exporter_arch }}.tar.gz -node_exporter_bin_path: /usr/local/bin/node_exporter +frr_exporter_bin_path: /usr/local/bin/frr_exporter -# Set node_exporter_host to localhost if you wish to expose node_exporter on localhost only. -node_exporter_host: '' -node_exporter_port: 9100 -node_exporter_options: '' +# Set frr_exporter_host to localhost if you wish to expose frr_exporter on localhost only. +frr_exporter_host: '' +frr_exporter_port: 9432 +frr_exporter_options: '' -node_exporter_state: started -node_exporter_enabled: true -node_exporter_restart: on-failure +frr_exporter_state: started +frr_exporter_enabled: true +frr_exporter_restart: on-failure diff --git a/handlers/main.yml b/handlers/main.yml index 9095182..2a31382 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,5 @@ --- -- name: restart node_exporter +- name: restart frr_exporter service: - name: node_exporter + name: frr_exporter state: restarted diff --git a/meta/main.yml b/meta/main.yml index 09af865..369ece1 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,10 +1,10 @@ --- dependencies: [] galaxy_info: - author: geerlingguy - role_name: node_exporter - description: Prometheus' node_exporter for Linux hosts. - company: Midwestern Mac, LLC + author: vgrid + role_name: frr_exporter + description: Prometheus' frr_exporter for Linux hosts. + company: SaferCities license: license (MIT) min_ansible_version: 2.10 platforms: @@ -41,6 +41,6 @@ galaxy_info: - containers - monitoring - prometheus - - node + - frr - exporter - metrics diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 01c0a89..bdafa4d 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -10,4 +10,4 @@ changed_when: false roles: - - role: geerlingguy.node_exporter + - role: vgrid.frr_exporter diff --git a/tasks/config-version.yaml b/tasks/config-version.yaml index f8efff8..c3312ea 100644 --- a/tasks/config-version.yaml +++ b/tasks/config-version.yaml @@ -3,18 +3,18 @@ delegate_to: localhost become: false uri: - url: "https://api.github.com/repos/prometheus/node_exporter/releases/latest" + url: "https://api.github.com/repos/tynany/frr_exporter/releases/latest" body_format: json register: _github_release until: _github_release.status == 200 run_once: true retries: 5 -- name: Set node_exporter_version +- name: Set frr_exporter_version set_fact: - node_exporter_version: "{{ _github_release.json.tag_name + frr_exporter_version: "{{ _github_release.json.tag_name | regex_replace('^v?([0-9\\.]+)$', '\\1') }}" -- name: Set node_exporter_download_url +- name: Set frr_exporter_download_url set_fact: - node_exporter_download_url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ node_exporter_arch }}.tar.gz" + frr_exporter_download_url: "https://github.com/tynany/frr_exporter/releases/download/v{{ frr_exporter_version }}/frr_exporter-{{ frr_exporter_version }}.linux-{{ frr_exporter_arch }}.tar.gz" diff --git a/tasks/main.yml b/tasks/main.yml index 874cf26..deee6da 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,66 +1,71 @@ --- -- name: Check current node_exporter version. - command: "{{ node_exporter_bin_path }} --version" +- name: Check current frr_exporter version. + command: "{{ frr_exporter_bin_path }} --version" failed_when: false changed_when: false - register: node_exporter_version_check + register: frr_exporter_version_check - name: Configure latest version include_tasks: config-version.yaml when: > - node_exporter_version is match("latest") - or node_exporter_version is not defined + frr_exporter_version is match("latest") + or frr_exporter_version is not defined -- name: Download and unarchive node_exporter into temporary location. +- name: Download and unarchive frr_exporter into temporary location. unarchive: - src: "{{ node_exporter_download_url }}" + src: "{{ frr_exporter_download_url }}" dest: /tmp remote_src: true mode: 0755 when: > - node_exporter_version_check.stdout is not defined - or node_exporter_version not in node_exporter_version_check.stdout - register: node_exporter_download_check + frr_exporter_version_check.stdout is not defined + or frr_exporter_version not in frr_exporter_version_check.stdout + register: frr_exporter_download_check -- name: Move node_exporter binary into place. +- name: Move frr_exporter binary into place. copy: - src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ node_exporter_arch }}/node_exporter" - dest: "{{ node_exporter_bin_path }}" + src: "/tmp/frr_exporter-{{ frr_exporter_version }}.linux-{{ frr_exporter_arch }}/frr_exporter" + dest: "{{ frr_exporter_bin_path }}" mode: 0755 remote_src: true - notify: restart node_exporter + notify: restart frr_exporter when: > - node_exporter_download_check is changed - or node_exporter_version_check.stdout | length == 0 + frr_exporter_download_check is changed + or frr_exporter_version_check.stdout | length == 0 -- name: Create node_exporter user. +- name: Create frr_exporter user. user: - name: node_exporter + name: frr_exporter shell: /sbin/nologin state: present -- name: Copy the node_exporter systemd unit file. +- name: Add frr_exporter user to frr group + user: + name: frr_exporter + groups: frrvty + +- name: Copy the frr_exporter systemd unit file. template: - src: node_exporter.service.j2 - dest: /etc/systemd/system/node_exporter.service + src: frr_exporter.service.j2 + dest: /etc/systemd/system/frr_exporter.service mode: 0644 - register: node_exporter_service + register: frr_exporter_service - name: Reload systemd daemon if unit file is changed. systemd: daemon_reload: true - notify: restart node_exporter - when: node_exporter_service is changed + notify: restart frr_exporter + when: frr_exporter_service is changed -- name: Ensure node_exporter is running and enabled at boot. +- name: Ensure frr_exporter is running and enabled at boot. service: - name: node_exporter - state: "{{ node_exporter_state }}" - enabled: "{{ node_exporter_enabled }}" + name: frr_exporter + state: "{{ frr_exporter_state }}" + enabled: "{{ frr_exporter_enabled }}" -- name: Verify node_exporter is responding to requests. +- name: Verify frr_exporter is responding to requests. uri: - url: "http://{% if node_exporter_host !='' %}{{ node_exporter_host }}{% else %}localhost{% endif %}:{{ node_exporter_port }}/" + url: "http://{% if frr_exporter_host !='' %}{{ frr_exporter_host }}{% else %}localhost{% endif %}:{{ frr_exporter_port }}/" return_content: true register: metrics_output failed_when: "'Metrics' not in metrics_output.content" diff --git a/templates/frr_exporter.service.j2 b/templates/frr_exporter.service.j2 new file mode 100644 index 0000000..599f0ef --- /dev/null +++ b/templates/frr_exporter.service.j2 @@ -0,0 +1,11 @@ +[Unit] +Description=FrrExporter + +[Service] +TimeoutStartSec=0 +User=frr_exporter +ExecStart={{ frr_exporter_bin_path }} --web.listen-address={{ frr_exporter_host }}:{{ frr_exporter_port }} {{ frr_exporter_options }} +Restart={{ frr_exporter_restart }} + +[Install] +WantedBy=multi-user.target diff --git a/templates/node_exporter.service.j2 b/templates/node_exporter.service.j2 deleted file mode 100644 index 42cb98c..0000000 --- a/templates/node_exporter.service.j2 +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=NodeExporter - -[Service] -TimeoutStartSec=0 -User=node_exporter -ExecStart={{ node_exporter_bin_path }} --web.listen-address={{ node_exporter_host }}:{{ node_exporter_port }} {{ node_exporter_options }} -Restart={{ node_exporter_restart }} - -[Install] -WantedBy=multi-user.target