diff --git a/.github/workflows/molecule-test.yml b/.github/workflows/molecule-test.yml new file mode 100644 index 0000000..1294191 --- /dev/null +++ b/.github/workflows/molecule-test.yml @@ -0,0 +1,28 @@ +--- +name: Molecule Test +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + molecule_distro: ['centos7', 'centos8', 'ubuntu1804', 'ubuntu2004'] + env: + ANSIBLE_CALLBACK_WHITELIST: profile_tasks + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3 + uses: actions/setup-python@v1 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ansible-lint flake8 molecule docker + - name: Test with molecule + run: | + molecule test --all + env: + MOLECULE_DISTRO: ${{ matrix.molecule_distro }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 61097a3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -language: python -services: docker - -env: - matrix: - - MOLECULE_DISTRO: centos7 - - MOLECULE_DISTRO: ubuntu1804 - - MOLECULE_DISTRO: ubuntu1604 - -install: - # Install test dependencies. - - pip install molecule docker - -script: - # Run tests. - - molecule test - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/README.md b/README.md index 22ecea3..470f9c4 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ ansible-role-prometheus-node-exporter ===================================== -[![Build Status](https://travis-ci.org/kevincoakley/ansible-role-prometheus-node-exporter.svg?branch=master)](https://travis-ci.org/kevincoakley/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 and Ubuntu 18.04 -Use role release >= 0.15.0 on node_exporter versions >= 0.15.0. Use role release <= 0.14.0 on node_exporter versions <= 0.14.0 +Install Prometheus Node Exporter - https://github.com/prometheus/node_exporter . Tested with CentOS 7, CentOS 8, Ubuntu 18.04 and Ubuntu 20.04 Requirements ------------ diff --git a/defaults/main.yml b/defaults/main.yml index df0e8cb..98ec709 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,5 @@ --- -prometheus_node_exporter_version: 0.18.1 +prometheus_node_exporter_version: 1.0.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/meta/main.yml b/meta/main.yml index 48cc2f0..bd22173 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -10,10 +10,11 @@ galaxy_info: - name: EL versions: - 7 + - 8 - name: Ubuntu versions: - - xenial - bionic + - focal # # Below are all categories currently available. Just as with # the platforms above, uncomment those that apply to your role. diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..f73c577 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,13 @@ +--- +- name: Converge + hosts: all + become: true + + vars: + prometheus_node_exporter_enabled_collectors: + - logind + prometheus_node_exporter_disabled_collectors: + - netstat + + roles: + - role: ansible-role-prometheus-node-exporter diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 625044b..64074ea 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -3,25 +3,31 @@ dependency: name: galaxy driver: name: docker -lint: - name: yamllint - options: - config-file: molecule/default/yaml-lint.yml +lint: | + set -e + yamllint -c molecule/yaml-lint.yml . + ansible-lint + flake8 platforms: - name: instance image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-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 privileged: true pre_build_image: true provisioner: name: ansible - lint: - name: ansible-lint + log: false + options: + vvv: false + playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} scenario: name: default verifier: - name: testinfra - lint: - name: flake8 + name: ansible diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml deleted file mode 100644 index 87cf703..0000000 --- a/molecule/default/playbook.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- name: Converge - hosts: all - become: true - - vars: - prometheus_node_exporter_enabled_collectors: - - logind - prometheus_node_exporter_disabled_collectors: - - netstat - - roles: - - role: ansible-role-prometheus-node-exporter - - post_tasks: - - name: Restart any services before running the tests - meta: flush_handlers - - - name: Give the Node Exporter time to start - pause: - seconds: 30 - - - name: Verify that the Node Exporter is running on port 9100 - uri: - url: http://127.0.0.1:9100 - status_code: 200 diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..620bd4b --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,10 @@ +--- +- name: Verify + hosts: all + become: true + + tasks: + - name: Verify that the Node Exporter is running on port 9100 + uri: + url: http://127.0.0.1:9100 + status_code: 200 diff --git a/molecule/default/yaml-lint.yml b/molecule/yaml-lint.yml similarity index 100% rename from molecule/default/yaml-lint.yml rename to molecule/yaml-lint.yml