Skip to content
Snippets Groups Projects
Commit 6a6425fb authored by Jonas Leder's avatar Jonas Leder
Browse files

add install task for elasticsearch exporter

parent a38e5643
Branches
No related tags found
No related merge requests found
[Unit]
Description=Metrics Exporter for Prometheus
After=network.target
Wants=network-online.target
[Service]
Restart=always
Type=simple
ExecStart=/usr/local/bin/ --es.uri=http://localhost:9200
Environment=
[Install]
WantedBy=multi-user.target
\ No newline at end of file
- name: Install Prometheus node exporter
hosts: all
vars:
elasticsearch_exporter_version: 1.7.0
arch: "{% if ansible_architecture == 'x86_64' %}amd64{% elif ansible_architecture == 'aarch64' %}arm64{% endif %}"
tasks:
- name: download elasticsearch-exporter release
get_url:
url: "https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v{{ elasticsearch_exporter_version }}/elasticsearch_exporter-{{ elasticsearch_exporter_version }}.linux-{{ arch }}.tar.gz"
dest: /tmp/elasticsearch_exporter.tar.gz
- name: extract elasticsearch-exporter release
unarchive:
src: /tmp/elasticsearch_exporter.tar.gz
dest: /tmp
remote_src: yes
- name: delete old binary if exists
file:
path: /usr/local/bin/elasticsearch_exporter
state: absent
- name: move elasticsearch-exporter binary
shell: cp /tmp/elasticsearch_exporter-{{ elasticsearch_exporter_version }}.linux-{{ arch }}/elasticsearch_exporter /usr/local/bin/elasticsearch_exporter
- name: install systemd-service
copy:
src: files/elasticsearch_exporter.service
dest: /etc/systemd/system/elasticsearch_exporter.service
mode: 0644
- name: reload systemd
systemd:
daemon_reload: yes
- name: enable elasticsearch-exporter service
systemd:
name: elasticsearch_exporter
enabled: yes
state: started
- name: delete temporary files
file:
path: /tmp/elasticsearch_exporter*
state: absent
- name: check elasticsearch-exporter status
uri:
url: http://localhost:9114/metrics
status_code: 200
timeout: 5
return_content: yes
register: elasticsearch_exporter_status
until: elasticsearch_exporter_status.status == 200
retries: 5
delay: 5
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment