mgmt/ansible/deploy-monitoring-configs.yml

64 lines
1.6 KiB
YAML

---
- name: 部署监控代理配置文件
hosts: nomad_cluster
become: yes
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: 创建promtail配置目录
file:
path: /etc/promtail
state: directory
mode: '0755'
tags:
- promtail-config
- name: 创建node-exporter配置目录
file:
path: /etc/prometheus
state: directory
mode: '0755'
tags:
- node-exporter-config
- name: 部署promtail配置
copy:
src: /root/mgmt/infrastructure/monitor/configs/promtail/promtail-config.yaml
dest: /etc/promtail/config.yaml
owner: root
group: root
mode: '0644'
backup: yes
tags:
- promtail-config
- name: 部署node-exporter配置
copy:
src: /root/mgmt/infrastructure/monitor/configs/node-exporter/node-exporter-config.yml
dest: /etc/prometheus/node-exporter-config.yml
owner: prometheus
group: prometheus
mode: '0644'
backup: yes
tags:
- node-exporter-config
- name: 重启promtail服务
systemd:
name: promtail
state: restarted
enabled: yes
when: ansible_facts['systemd']['promtail']['status'] is defined
tags:
- promtail-restart
- name: 重启node-exporter服务
systemd:
name: prometheus-node-exporter
state: restarted
enabled: yes
when: ansible_facts['systemd']['prometheus-node-exporter']['status'] is defined
tags:
- node-exporter-restart