-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from smartlogic/redis_exporter
Setup ability to template out redis_exporter with systemd
- Loading branch information
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
- name: "Create the prometheus user" | ||
user: | ||
name: prometheus | ||
comment: "Prometheus" | ||
become: true | ||
|
||
- name: "Create version folder" | ||
file: | ||
path: "/home/prometheus/redis_exporter/{{ redis_exporter_version }}" | ||
state: directory | ||
mode: 0700 | ||
become: yes | ||
become_user: prometheus | ||
|
||
- name: "Download the redis_exporter file" | ||
get_url: | ||
url: "https://github.com/oliver006/redis_exporter/releases/download/v{{ redis_exporter_version }}/redis_exporter-v{{ redis_exporter_version }}.linux-amd64.tar.gz" | ||
dest: "/home/prometheus/redis_exporter/{{ redis_exporter_version }}/redis_exporter.tar.gz" | ||
mode: 0400 | ||
checksum: "sha256:{{ redis_exporter_checksum }}" | ||
become: yes | ||
become_user: prometheus | ||
|
||
- name: stat final file | ||
stat: path="/home/prometheus/redis_exporter/{{ redis_exporter_version }}/redis_exporter" | ||
register: redis_exporter_stat | ||
become: yes | ||
become_user: prometheus | ||
|
||
- name: "Extract archive" | ||
unarchive: | ||
src: "/home/prometheus/redis_exporter/{{ redis_exporter_version }}/redis_exporter.tar.gz" | ||
dest: "/home/prometheus/redis_exporter/{{ redis_exporter_version }}/" | ||
remote_src: yes | ||
when: redis_exporter_stat.stat.exists == False | ||
become: yes | ||
become_user: prometheus | ||
|
||
- name: Template out the service file | ||
template: | ||
src: redis_exporter.service.j2 | ||
dest: /etc/systemd/system/redis_exporter.service | ||
mode: 0644 | ||
become: yes | ||
notify: | ||
- reload systemd | ||
- restart redis_exporter | ||
|
||
- name: Enable redis exporter | ||
systemd: | ||
enabled: yes | ||
name: redis_exporter | ||
become: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Prometheus Redis Exporter | ||
After=network-online.target | ||
|
||
[Service] | ||
User=prometheus | ||
Restart=on-failure | ||
WorkingDirectory=/home/prometheus/redis_exporter/{{ redis_exporter_version }} | ||
ExecStart=/home/prometheus/redis_exporter/{{ redis_exporter_version }}/redis_exporter | ||
|
||
[Install] | ||
WantedBy=multi-user.target |