diff --git a/README.md b/README.md index 42333ec..b5c405b 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ -## ansible-role-ping_exporter +## Ansible role ping_exporter + +Deploys [ping_exporter](https://github.com/ajdelgado/ping_exporter) script and install it as a systemd service unit. + +# Configuration + +Check [defaults](/defaults/main.yml) but create a dictionary *ping_exporter* with this values: +- prometheus_host: IP or hostname of prometheus host to open access in UFW (if specified) +- targets: List of IPs to ping +- log_file: Log file for debug information (A logrotate rule will be added to rotate it) +- count: Number of pings to send to each host +- port: Port for the web service to listen +- frequency: Delay between pings to each host +- interval: Time between packets sent +- timeout: The maximum waiting time for receiving a reply in seconds +- family: IP family version to use (A string "4" or "6") +- handle_ufw: Whether to create an "allow" rule in UFW for the port and the Prometheus server IP or hostname. \ No newline at end of file diff --git a/defaults/main.yml b/defaults/main.yml index 711a2b1..f525360 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,14 @@ --- -# Default values for variables of the role -# variable_name: value +ping_exporter: + prometheus_host: 192.168.1.1 + targets: + - 1.1.1.1 + - 8.8.8.8 + log_file: /var/log/ping_exporter.log + count: 4 + port: 8787 + frequency: 10 + interval: 1 + timeout: 2 + family: "4" + handle_ufw: yes \ No newline at end of file diff --git a/tasks/configure.yml b/tasks/configure.yml index 3bf0602..a3f6d95 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -20,6 +20,7 @@ rule: allow port: "{{ ping_exporter['port'] }}" src: "{{ ping_exporter['prometheus_host'] }}" + when: ping_exporter['handle_ufw'] - name: Ensure there is a logrotate rule for ping_exporter template: dest: /etc/logrotate.d/ping_exporter diff --git a/tasks/main.yml b/tasks/main.yml index cbe813e..b407b74 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Ensure installation +- name: Ensure installation of script ping_exporter include_tasks: install.yml -- name: Ensure configuration +- name: Ensure configuration of script ping_exporter include_tasks: configure.yml \ No newline at end of file