Skip to content

Commit

Permalink
Merge pull request #12 from kevincoakley/1.4.0
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
kevincoakley authored Oct 19, 2022
2 parents 197b867 + 89be3dd commit 3ed52f3
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/molecule-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
molecule_distro: ['centos7', 'centos8', 'ubuntu1804', 'ubuntu2004']
molecule_distro: ['centos7', 'rockylinux8', 'rockylinux9', 'ubuntu1804', 'ubuntu2004', 'ubuntu2204']
env:
ANSIBLE_CALLBACK_WHITELIST: profile_tasks
ANSIBLE_CALLBACKS_ENABLED: profile_tasks

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ansible-role-prometheus-node-exporter
![](https://github.com/kevincoakley/ansible-role-prometheus-node-exporter/workflows/Molecule%20Test/badge.svg)


Install Prometheus Node Exporter - https://github.com/prometheus/node_exporter . Tested with CentOS 7, CentOS 8, Ubuntu 18.04 and Ubuntu 20.04
Install Prometheus Node Exporter - https://github.com/prometheus/node_exporter . Tested with EL 7, EL 8, EL 9, Ubuntu 18.04, Ubuntu 20.04, and Ubuntu 22.04.

Requirements
------------
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
prometheus_node_exporter_version: 1.3.1
prometheus_node_exporter_version: 1.4.0
prometheus_node_exporter_download_url: https://github.com/prometheus/node_exporter/releases/download/v{{ prometheus_node_exporter_version }}/node_exporter-{{ prometheus_node_exporter_version }}.linux-amd64.tar.gz
prometheus_node_exporter_manage_user: true
prometheus_node_exporter_service_username: node-exp
Expand Down
8 changes: 4 additions & 4 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- name: reload systemd
systemd:
- name: Reload systemd
ansible.builtin.systemd:
name: systemd
daemon_reload: true

- name: restart node_exporter
systemd:
- name: Restart node_exporter
ansible.builtin.systemd:
name: node_exporter
state: restarted
8 changes: 5 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ galaxy_info:
author: Kevin Coakley
description: Install Prometheus Node Exporter
license: BSD
min_ansible_version: 2.2
min_ansible_version: "2.10"
platforms:
- name: EL
versions:
- 7
- 8
- "7"
- "8"
- "9"
- name: Ubuntu
versions:
- bionic
- focal
- jammy
#
# Below are all categories currently available. Just as with
# the platforms above, uncomment those that apply to your role.
Expand Down
3 changes: 0 additions & 3 deletions molecule/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
---
warn_list:
- internal-error
- role-name
skip_list:
- yaml
9 changes: 3 additions & 6 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ lint: |
flake8
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
exposed_ports:
- 9100/tcp
published_ports:
- 0.0.0.0:9100:9100/tcp
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
provisioner:
Expand Down
21 changes: 11 additions & 10 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: Create the Node Exporter group
group:
ansible.builtin.group:
name: "{{ prometheus_node_exporter_service_group }}"
state: present
system: true

- name: Create the Node Exporter user
user:
ansible.builtin.user:
name: "{{ prometheus_node_exporter_service_username }}"
groups: "{{ prometheus_node_exporter_service_group }}"
append: true
Expand All @@ -17,18 +17,19 @@
# Install Prometheus Node Exporter
#
- name: Check if the version of Node Exporter already exists
stat:
ansible.builtin.stat:
path: "/opt/node_exporter-{{ prometheus_node_exporter_version }}.linux-amd64"
register: prometheus_node_exporter_install_path

- name: Download Node Exporter
get_url:
ansible.builtin.get_url:
url: "{{ prometheus_node_exporter_download_url }}"
dest: "/tmp/node_exporter-{{ prometheus_node_exporter_version }}.tar.gz"
mode: '0440'
when: not prometheus_node_exporter_install_path.stat.exists

- name: Extract Node Exporter into the install directory
unarchive:
ansible.builtin.unarchive:
src: "/tmp/node_exporter-{{ prometheus_node_exporter_version }}.tar.gz"
dest: "/opt/"
copy: false
Expand All @@ -37,7 +38,7 @@
when: not prometheus_node_exporter_install_path.stat.exists

- name: Create a symlink for /opt/node_exporter
file:
ansible.builtin.file:
src: "/opt/node_exporter-{{ prometheus_node_exporter_version }}.linux-amd64"
dest: /opt/node_exporter
owner: "{{ prometheus_node_exporter_service_username }}"
Expand All @@ -46,18 +47,18 @@
when: not prometheus_node_exporter_install_path.stat.exists

- name: Copy the Node Exporter systemd service file
template:
ansible.builtin.template:
src: node_exporter.service.j2
dest: /etc/systemd/system/node_exporter.service
owner: root
group: root
mode: 0644
notify:
- reload systemd
- restart node_exporter
- Reload systemd
- Restart node_exporter

- name: Ensure Node Exporter is started and enabled on boot
service:
ansible.builtin.service:
name: node_exporter
state: started
enabled: true

0 comments on commit 3ed52f3

Please sign in to comment.