elan.monitoring_prometheus
Prometheus的Ansible角色
使用Ansible安装最新的Prometheus版本。 这个角色是多操作系统的Ansible版本,等同于https://github.com/lkiesow/prometheus-rpm。
角色变量
您可以指定用于配置的模板文件。
角色会安装默认配置,您可能希望扩展或更改它。
要传递自己的配置文件,请在变量prometheus_config_template
中指定jinja模板的路径。
此外,还安装了一个 .env
文件,用于扩展systemd调用Prometheus的命令行参数。
您也可以通过变量prometheus_env_file
传递自己的文件,因此不受这些值的限制。
示例剧本
只需将角色添加到您的剧本中:
- hosts: all
become: true
roles:
- role: elan.monitoring_prometheus
prometheus_config_template: 'custom_templates/prometheus.yml.j2'
开发
用于开发和测试,您可以使用molecule。
使用podman作为驱动程序,可以通过以下方式安装 – 最好在虚拟环境中(如果使用docker,请将podman
替换为docker
):
pip install -r .dev_requirements.txt
然后您可以使用以下命令创建测试实例,应用Ansible配置(converge)并销毁测试实例:
molecule create
molecule converge
molecule destroy
如果您想检查正在运行的测试实例,请使用molecule login --host <instance_name>
,将<instance_name>
替换为所需值。