Skip to content

Commit

Permalink
Merge pull request #7 from UnderGreen/upstart_support
Browse files Browse the repository at this point in the history
Upstart support
  • Loading branch information
UnderGreen authored Jul 27, 2016
2 parents 5614ab4 + 76c57d3 commit 6eba5d0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ galaxy_info:
- jessie
- name: Ubuntu
versions:
- precise
- trusty
- xenial
galaxy_tags:
- monitoring
14 changes: 14 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- tar
- bzip2
- ca-certificates
- ssl-cert

- name: create prometheus system group
group:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions templates/etc/init/prometheus.conf.j2
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6eba5d0

Please sign in to comment.