结构
[root@master modules]# pwd
/srv/salt/prod/modules
[root@master modules]# tree prometheus/
prometheus/
├── files
│ ├── grafana-enterprise-8.2.5-1.x86_64.rpm
│ ├── prometheus-2.32.0-beta.0.linux-amd64.tar.gz
│ ├── prometheus.service
│ └── prometheus.yml.j2
├── grafana.sls
└── install.sls
编写Prometheus状态文件
include:
- modules.prometheus.grafana
prometheus:
user.present:
- system: true
- createhome: false
- shell: /sbin/nologin
tar-prometheus:
archive.extracted:
- source: salt://modules/prometheus/files/prometheus-2.32.0-beta.0.linux-amd64.tar.gz
- name: /usr/local
file.symlink:
- name: /usr/local/prometheus
- target: /usr/local/prometheus-2.32.0-beta.0.linux-amd64
- unless: test $(ls /usr/local/prometheus | wc -l) -gt 1
/usr/local/prometheus:
file.directory:
- user: prometheus
- group: prometheus
- mode: '0644'
- recurse:
- user
- group
/usr/local/prometheus/prometheus.yml:
file.managed:
- source: salt://modules/prometheus/files/prometheus.yml.j2
- template: jinja
/usr/local/prometheus/data:
file.directory:
- makedirs: true
/usr/lib/systemd/system/prometheus.service:
file.managed:
- source: salt://modules/prometheus/files/prometheus.service
prometheus.service:
service.running:
- enable: true
安装grafana
/usr/src/grafana-enterprise-8.2.5-1.x86_64.rpm:
file.managed:
- source: salt://modules/prometheus/files/grafana-enterprise-8.2.5-1.x86_64.rpm
install-grafana:
pkg.installed:
- name: grafana
grafana-server.service:
service.running:
- enable: true
评论区