mgmt/ansible/deploy-prometheus-config.yml

36 lines
826 B
YAML

---
- name: 部署Prometheus配置
hosts: influxdb
become: yes
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: 备份原Prometheus配置
copy:
src: /etc/prometheus/prometheus.yml
dest: /etc/prometheus/prometheus.yml.backup
remote_src: yes
backup: yes
tags:
- backup-config
- name: 部署新Prometheus配置
copy:
src: /root/mgmt/infrastructure/monitor/configs/prometheus/prometheus.yml
dest: /etc/prometheus/prometheus.yml
owner: prometheus
group: prometheus
mode: '0644'
backup: yes
tags:
- deploy-config
- name: 重启Prometheus服务
systemd:
name: prometheus
state: restarted
enabled: yes
tags:
- restart-service