Skip to content

Commit

Permalink
Merge pull request #2 from kevincoakley/0.15.0
Browse files Browse the repository at this point in the history
0.15.0
  • Loading branch information
kevincoakley authored Nov 1, 2017
2 parents 16226d3 + 53912c8 commit 6c68306
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 28 deletions.
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ before_install:
# Ansible doesn't play well with virtualenv
- deactivate
- sudo apt-get update -qq
- sudo apt-get install -y -o Dpkg::Options::="--force-confnew" docker-engine
- sudo apt-get install -y -o Dpkg::Options::="--force-confnew" docker-ce
- mkdir -p ~/.ssh/
- printf "Host 127.0.0.1\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile=/dev/null" > ~/.ssh/config

Expand All @@ -26,11 +26,22 @@ install:
- sudo apt-get install -y ansible
- sudo rm /usr/bin/python && sudo ln -s /usr/bin/python2.7 /usr/bin/python
- ansible --version
- sudo pip install ansible-lint
- ansible-lint --version

script:
# ansible-lint checks playbooks for practices and behaviour that could potentially be improved
- ansible-lint -R .
# Perform a syntax check on the playbook
- ansible-playbook -i tests/inventory tests/test.yml --syntax-check
# Run the playbook, don't bother stopping the Docker containers
- ansible-playbook -i tests/inventory --skip-tags=docker-stop tests/test.yml -vvvv
# Run again to test idempotence
- >
ansible-playbook -i tests/inventory --tags=node-exporter tests/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ 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)

Install Prometheus Node Exporter and Ganglia Gmond (if necessary) - https://github.com/prometheus/node_exporter . Tested with CentOS 7 and Ubuntu 16.04
Install Prometheus Node Exporter - https://github.com/prometheus/node_exporter . Tested with CentOS 7 and Ubuntu 16.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

Requirements
------------
Expand All @@ -13,12 +15,12 @@ None
Role Variables
--------------

See defaults/main.yml. This role supports all collectors, just list the collectors using the prometheus_node_exporter_enabled_collectors variable. If the gmond collector is selected then Ganglia Gmond will be installed and started as a system service.
See defaults/main.yml. This role supports all collectors, just list the collectors using the prometheus_node_exporter_enabled_collectors variable.

Dependencies
------------

Node
None

Example Playbook
----------------
Expand All @@ -30,8 +32,9 @@ Example Playbook

vars:
prometheus_node_exporter_enabled_collectors:
- gmond
- loadavg
- logind
prometheus_node_exporter_disabled_collectors:
- netstat

roles:
- ansible-role-prometheus-node-exporter
Expand Down
20 changes: 3 additions & 17 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
---
prometheus_node_exporter_version: 0.14.0
prometheus_node_exporter_version: 0.15.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_service_username: node-exp
prometheus_node_exporter_service_group: node-exp

prometheus_node_exporter_enabled_collectors:
- conntrack
- diskstats
- entropy
- filefd
- filesystem
- hwmon
- loadavg
- mdadm
- meminfo
- netdev
- netstat
- stat
- textfile
- time
- vmstat
prometheus_node_exporter_enabled_collectors: []
prometheus_node_exporter_disabled_collectors: []

prometheus_node_exporter_config_flags:
'web.listen-address': '0.0.0.0:9100'
Expand Down
6 changes: 4 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
- name: reload systemd
command: systemctl daemon-reload
systemd:
name: systemd
daemon_reload: yes

- name: restart node_exporter
service:
systemd:
name: node_exporter
state: restarted
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ galaxy_info:
description: Install Prometheus Node Exporter
# If the issue tracker for your role is not on github, uncomment the
license: BSD
min_ansible_version: 2.0
min_ansible_version: 2.2
platforms:
- name: EL
versions:
Expand Down
2 changes: 1 addition & 1 deletion templates/node_exporter.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=network.target
Type=simple
User={{ prometheus_node_exporter_service_username }}
Group={{ prometheus_node_exporter_service_group }}
ExecStart=/opt/node_exporter/node_exporter -collectors.enabled {{ prometheus_node_exporter_enabled_collectors | join(',') }} {% for flag, flag_value in prometheus_node_exporter_config_flags.iteritems() %}-{{ flag }}={{ flag_value }} {% endfor %}
ExecStart=/opt/node_exporter/node_exporter {% for enabled in prometheus_node_exporter_enabled_collectors %}--collector.{{ enabled }} {% endfor %} {% for disabled in prometheus_node_exporter_disabled_collectors %}--no-collector.{{ disabled }} {% endfor %} {% for flag, flag_value in prometheus_node_exporter_config_flags.items() %}--{{ flag }}={{ flag_value }} {% endfor %}

SyslogIdentifier=prometheus_node_exporter
Restart=always
Expand Down
3 changes: 3 additions & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ansible_user=root
ansible_ssh_pass=docker
ansible_host=127.0.0.1

[local]
localhost ansible_connection=local

[node-exporter]
ubuntu-system ansible_ssh_host=127.0.0.1 ansible_port=2200
centos-system ansible_ssh_host=127.0.0.1 ansible_port=2222
4 changes: 3 additions & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

vars:
prometheus_node_exporter_enabled_collectors:
- loadavg
- logind
prometheus_node_exporter_disabled_collectors:
- netstat

roles:
- ansible-role-prometheus-node-exporter
Expand Down

0 comments on commit 6c68306

Please sign in to comment.