You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.6 KiB

---
- name: Create prometheus user and group
import_tasks: prometheus_user.yml
- name: Check if Prometheus is installed
stat:
path: /opt/prometheus/prometheus
register: prometheus_binary
- name: Download and install Prometheus
when: not prometheus_binary.stat.exists
block:
- name: Download Prometheus from GitHub
get_url:
dest: /tmp/prometheus-{{ prometheus_version }}.tar.gz
url: https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-amd64.tar.gz
checksum: sha256:e12917b25b32980daee0e9cf879d9ec197e2893924bd1574604eb0f550034d46
- name: Create Prometheus directory
file:
path: /opt/prometheus
state: directory
owner: prometheus
group: prometheus
mode: 0755
- name: Extract Prometheus
unarchive:
remote_src: true
src: /tmp/prometheus-{{ prometheus_version }}.tar.gz
dest: /opt/prometheus
owner: prometheus
group: prometheus
extra_opts:
- --strip-components=1
- name: Create Prometheus service file
copy:
src: prometheus.service
dest: /etc/systemd/system/prometheus.service
owner: root
group: root
mode: 0644
- name: Add Prometheus config file
template:
src: prometheus.yml.jinja2
dest: /opt/prometheus/prometheus.yml
owner: prometheus
group: prometheus
mode: 0644
notify:
- Restart prometheus
- name: Start and enable prometheus service
service:
name: prometheus
state: started
enabled: true