diff --git a/defaults/main.yml b/defaults/main.yml index f08898d..54a32d4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -22,6 +22,7 @@ prometheus_rules_dir: "{{ prometheus_config_dir }}/rules" prometheus_file_sd_config_dir: "{{ prometheus_config_dir }}/tgroups" prometheus_config_dir: /etc/prometheus +prometheus_log_dir: /var/log/prometheus prometheus_pid_path: /var/run/prometheus.pid prometheus_db_dir: /var/lib/prometheus diff --git a/meta/main.yml b/meta/main.yml index 63870ed..a96c4f6 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -14,6 +14,8 @@ galaxy_info: - jessie - name: Ubuntu versions: + - precise + - trusty - xenial galaxy_tags: - monitoring diff --git a/tasks/main.yml b/tasks/main.yml index d555d69..cbb2f89 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,6 +9,7 @@ - tar - bzip2 - ca-certificates + - ssl-cert - name: create prometheus system group group: @@ -40,6 +41,7 @@ - "{{ prometheus_rules_dir }}" - "{{ prometheus_file_sd_config_dir }}" - "{{ prometheus_db_dir }}" + - "{{ prometheus_log_dir }}" - name: download prometheus server binary get_url: @@ -88,10 +90,22 @@ owner: root group: root mode: 0644 + when: ansible_service_mgr == 'systemd' notify: - service reenable - restart prometheus +- name: create init service unit + template: + src: etc/init/prometheus.conf.j2 + dest: /etc/init/prometheus.conf + owner: root + group: root + mode: 0644 + when: ansible_service_mgr == 'upstart' + notify: + - restart prometheus + - name: ensure prometheus service is enabled service: name: prometheus diff --git a/templates/etc/init/prometheus.conf.j2 b/templates/etc/init/prometheus.conf.j2 new file mode 100644 index 0000000..7bb47a9 --- /dev/null +++ b/templates/etc/init/prometheus.conf.j2 @@ -0,0 +1,15 @@ +description "Prometheus Monitoring" +start on (local-filesystems and net-device-up IFACE!=lo) +stop on runlevel [016] + +respawn +env GOMAXPROCS={{ prometheus_gomaxprocs }} +setuid {{ prometheus_user }} +setgid {{ prometheus_group }} + +script + exec >> "{{ prometheus_log_dir }}/prometheus.log" + exec 2>&1 + exec {{ prometheus_bin_dir }}/prometheus {% for flag, flag_value in prometheus_config_flags.iteritems() %}-{{ flag }}={{ flag_value }} {% endfor %} + +end script