infra-konstrukt/roles/prometheus/tasks/main.yml

68 lines
1.4 KiB
YAML

---
- name: Create prometheus user
user:
name: prometheus
shell: /bin/false
system: yes
- name: Create directories
file:
path: "{{ item }}"
state: directory
owner: prometheus
group: prometheus
mode: '0755'
loop:
- /etc/prometheus
- /var/lib/prometheus
- name: Download Prometheus
get_url:
url: "https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz"
dest: "/tmp/prometheus.tar.gz"
- name: Unarchive Prometheus
unarchive:
src: "/tmp/prometheus.tar.gz"
dest: "/tmp"
remote_src: yes
- name: Install binaries
copy:
src: "/tmp/prometheus-2.45.0.linux-amd64/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
mode: '0755'
remote_src: yes
loop:
- prometheus
- promtool
notify: Restart prometheus
- name: Copy console libraries
copy:
src: "/tmp/prometheus-2.45.0.linux-amd64/{{ item }}/"
dest: "/etc/prometheus/{{ item }}/"
remote_src: yes
loop:
- consoles
- console_libraries
- name: Configure Prometheus (Auto-Discovery)
template:
src: prometheus.yml.j2
dest: /etc/prometheus/prometheus.yml
notify: Restart prometheus
- name: Create systemd service
template:
src: prometheus.service.j2
dest: /etc/systemd/system/prometheus.service
notify: Restart prometheus
- name: Start Prometheus
systemd:
name: prometheus
state: started
enabled: yes