diff --git a/.github/workflows/molecule-test.yml b/.github/workflows/molecule-test.yml index 9bdec3a..01e5bea 100644 --- a/.github/workflows/molecule-test.yml +++ b/.github/workflows/molecule-test.yml @@ -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 diff --git a/README.md b/README.md index 470f9c4..e0ff34b 100644 --- a/README.md +++ b/README.md @@ -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 ------------ diff --git a/defaults/main.yml b/defaults/main.yml index 7560e07..b99f7ce 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/handlers/main.yml b/handlers/main.yml index 7991acf..d03415a 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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 diff --git a/meta/main.yml b/meta/main.yml index 112fb4b..167f3ed 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -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. diff --git a/molecule/ansible-lint.yml b/molecule/ansible-lint.yml index bac4c46..5891ff5 100644 --- a/molecule/ansible-lint.yml +++ b/molecule/ansible-lint.yml @@ -1,6 +1,3 @@ --- -warn_list: - - internal-error - - role-name skip_list: - yaml diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 270ecf8..091198e 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -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: diff --git a/tasks/main.yml b/tasks/main.yml index 7fc2e7f..f498c7e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 @@ -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 @@ -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 }}" @@ -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