Skip to content

Commit

Permalink
Merge branch 'prometheus-setup'
Browse files Browse the repository at this point in the history
Former-commit-id: a459909
  • Loading branch information
panchoh committed Mar 19, 2019
2 parents 6693930 + 2f341b2 commit ec6b8ec
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 26 deletions.
7 changes: 6 additions & 1 deletion deploy/aws/provision/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
- vars.yml
tasks:
- include: tasks/prometheus/main.yml
handlers:
- name: Restart Prometheus
systemd:
name: prometheus
daemon_reload: yes
state: restarted
tags:
- prometheus

Expand Down Expand Up @@ -184,7 +190,6 @@
shell: >
{{ item }}
with_items:
- /var/prometheus/prometheus-start.sh
- /var/qed/exporter-start.sh
tags:
- start-prometheus
Expand Down
2 changes: 1 addition & 1 deletion deploy/aws/provision/tasks/common/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

- name: Create Node Exporter start script
template:
dest: /var/qed/exporter-{{ item }}
dest: /var/qed/exporter-{{ item }}
src: ../../templates/exporter-{{ item }}.j2
force: true
mode: 0775
Expand Down
78 changes: 57 additions & 21 deletions deploy/aws/provision/tasks/prometheus/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,70 @@
- name: Download Prometheus
unarchive:
src: https://github.com/prometheus/prometheus/releases/download/v2.8.0/prometheus-2.8.0.linux-amd64.tar.gz
dest: /var
dest: /tmp
keep_newer: true
remote_src: true

- name: Create Node Exporter link
- name: Install Prometheus binary
copy:
src: /tmp/prometheus-2.8.0.linux-amd64/prometheus
dest: /usr/bin/prometheus
remote_src: yes
mode: preserve

- name: Create Prometheus system group
group:
name: prometheus
system: yes
gid: 210

- name: Create Prometheus system user
user:
name: prometheus
system: yes
uid: 210
group: 210

- name: Create Prometheus work dir
file:
src: /var/prometheus-2.8.0.linux-amd64
dest: /var/prometheus
state: link
path: /var/lib/prometheus
owner: prometheus
group: prometheus
mode: 0755
state: directory

- name: Create Prometheus config dir
file:
path: /etc/prometheus
state: directory

- name: Create Prometheus config
template:
dest: /etc/prometheus/prometheus.yml
src: ../../templates/prometheus-config.yml.j2
force: yes
notify:
- Restart Prometheus

- name: Install Prometheus systemd service unit file
template:
dest: /etc/systemd/system/{{ item }}
src: ../../templates/{{ item }}.j2
with_items:
- prometheus.service
notify:
- Restart Prometheus

- name: Enable and run Prometheus service
systemd:
name: prometheus
state: started
enabled: yes
daemon_reload: yes

- name: Install Grafana
yum:
update_cache: yes
update_cache: yes
name: https://dl.grafana.com/oss/release/grafana-6.0.1-1.x86_64.rpm

- name: Copy Grafana config and dashboards to remote
Expand All @@ -51,18 +102,3 @@
name: grafana-server
state: restarted
when: grafana_config.changed

- name: Create Prometheus config
template:
dest: /var/prometheus/prometheus.yml
src: ../../templates/prometheus-config.yml.j2
force: yes

- name: Create Prometheus start script
template:
dest: /var/prometheus/{{ item }}
src: ../../templates/{{ item }}.j2
force: yes
mode: 0775
with_items:
- prometheus-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@
See the License for the specific language governing permissions and
limitations under the License.
#}
#!/bin/bash
[Unit]
Description=Prometheus service
Requires=network-online.target
After=network-online.target

export PROMETHEUS_HOME=/var/prometheus
nohup $PROMETHEUS_HOME/prometheus --config.file=$PROMETHEUS_HOME/prometheus.yml >> prometheus.log 2>&1 &
[Service]
User=prometheus
Group=prometheus
Restart=on-failure
ExecStart=/usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/data
ExecReload=/bin/kill -HUP $MAINPID
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full

[Install]
WantedBy=multi-user.target

0 comments on commit ec6b8ec

Please sign in to comment.