Ansible role to install and configure Prometheus.
Building and improving this Ansible role have been sponsored by my current and previous employers like Cloudpunks GmbH and Proact Deutschland GmbH.
- Requirements
- Default Variables
- prometheus_alertmanagers
- prometheus_arch
- prometheus_cpu_shares
- prometheus_default_folders
- prometheus_default_labels
- prometheus_default_publish
- prometheus_default_rules
- prometheus_default_volumes
- prometheus_domain
- prometheus_download
- prometheus_enable_remote_write_receiver
- prometheus_evaluation_interval
- prometheus_extra_folders
- prometheus_extra_labels
- prometheus_extra_publish
- prometheus_extra_rules
- prometheus_extra_volumes
- prometheus_image
- prometheus_installation
- prometheus_listen_address
- prometheus_memory_limit
- prometheus_memory_soft_limit
- prometheus_memory_swap
- prometheus_network
- prometheus_number_of_cpus
- prometheus_oauth2_access_logging
- prometheus_oauth2_allowed_groups
- prometheus_oauth2_arch
- prometheus_oauth2_client_id
- prometheus_oauth2_client_secret
- prometheus_oauth2_cookie_secret
- prometheus_oauth2_cpu_shares
- prometheus_oauth2_default_labels
- prometheus_oauth2_default_publish
- prometheus_oauth2_download
- prometheus_oauth2_enabled
- prometheus_oauth2_extra_labels
- prometheus_oauth2_extra_publish
- prometheus_oauth2_image
- prometheus_oauth2_keycloak_url
- prometheus_oauth2_listen_address
- prometheus_oauth2_memory_limit
- prometheus_oauth2_memory_soft_limit
- prometheus_oauth2_memory_swap
- prometheus_oauth2_network
- prometheus_oauth2_number_of_cpus
- prometheus_oauth2_provider
- prometheus_oauth2_pull_image
- prometheus_oauth2_request_logging
- prometheus_oauth2_static_groups
- prometheus_oauth2_static_users
- prometheus_oauth2_upstream
- prometheus_oauth2_version
- prometheus_pull_image
- prometheus_rule_files
- prometheus_scrape_configs
- prometheus_scrape_interval
- prometheus_tsdb_retention_size
- prometheus_tsdb_retention_time
- prometheus_version
- Discovered Tags
- Dependencies
- License
- Author
- Minimum Ansible version:
2.10
List of alertmanager configuration
prometheus_alertmanagers: []prometheus_alertmanagers:
- scheme: http
static_configs:
- targets:
- loclhost:9093Target system architecture of the binary
prometheus_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' or ansible_architecture
== 'arm64' else 'amd64' }}"CPU shares with Docker deployment
prometheus_cpu_shares:prometheus_cpu_shares: '512'List of default folders to create
prometheus_default_folders:
- /etc/prometheus
- /etc/prometheus/rules
- /var/lib/prometheusList of default labels to assign to docker
prometheus_default_labels: []List of default port publishing for docker
prometheus_default_publish: []prometheus_default_publish:
- 127.0.0.1:9090:9090List of default rule file definitions
prometheus_default_rules: []prometheus_default_rules:
- name: example
content:
groups:
- name: example
rules:
- alert: ...
expr: ...
for: 5m
- name: example-from-url
url: http://example.com/example.yml
- name: example-from-template
src: path/to/template.j2
- name: example-to-remove
state: absentList of default volumes to mount for docker
prometheus_default_volumes:
- /var/lib/prometheus:/var/lib/prometheus
- /etc/prometheus/rules:/etc/prometheus/rulesDomain for external access
prometheus_domain:prometheus_domain: https://prometheus.example.comURL to the archive of the release to install
prometheus_download:
https://github.com/prometheus/prometheus/releases/download/v{{
prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{
prometheus_arch }}.tar.gzEnable remote-write receiver in Prometheus
prometheus_enable_remote_write_receiver: falseGlobal default evaluation interval
prometheus_evaluation_interval: 15sList of extra folders to create
prometheus_extra_folders: []prometheus_extra_folders:
- /path/to/host/folder1
- /path/to/host/folder2
- /path/to/host/folder3List of extra labels to assign to docker
prometheus_extra_labels: []List of extra port publishing for docker
prometheus_extra_publish: []prometheus_extra_publish:
- 127.0.0.1:9000:9000List of extra rule file definitions
prometheus_extra_rules: []prometheus_extra_rules:
- name: example
content:
groups:
- name: example
rules:
- alert: ...
expr: ...
for: 5m
- name: example-from-url
url: http://example.com/example.yml
- name: example-from-template
src: path/to/template.j2
- name: example-to-remove
state: absentList of extra volumes to mount for docker
prometheus_extra_volumes: []prometheus_extra_volumes:
- /path/to/host/folder1:/path/within/container1
- /path/to/host/folder2:/path/within/container2
- /path/to/host/folder3:/path/within/container3Docker image to use for deployment on OAuth2 Proxy
prometheus_image: quay.io/prometheus/prometheus:v{{ prometheus_version }}Select installation method, could be native or docker
prometheus_installation: nativeListen address for the prometheus
prometheus_listen_address: 0.0.0.0:9090Memory limit with Docker deployment
prometheus_memory_limit:prometheus_memory_limit: 1024mSoft memory limit with Docker deployment
prometheus_memory_soft_limit:prometheus_memory_soft_limit: 512mSwap usage with Docker deployment
prometheus_memory_swap:prometheus_memory_swap: 2048mOptional docker network to attach on OAuth2 Proxy
prometheus_network:Number of CPUs with Docker deployment
prometheus_number_of_cpus:prometheus_number_of_cpus: '1.0'Enable access logging for OAuth2 proxy
prometheus_oauth2_access_logging: falseList of groups to allow access
prometheus_oauth2_allowed_groups: []prometheus_oauth2_allowed_groups:
- /Group1
- /Group2
- /Group3Target system architecture of the binary
prometheus_oauth2_arch: '{{ prometheus_arch }}'Client ID for OAuth2 authentication
prometheus_oauth2_client_id:Client secret for OAuth2 authentication
prometheus_oauth2_client_secret:Cookie secret used by OAuth2 proxy
prometheus_oauth2_cookie_secret:CPU shares with Docker deployment
prometheus_oauth2_cpu_shares:prometheus_oauth2_cpu_shares: '512'List of default labels to assign to docker on OAuth2 Proxy
prometheus_oauth2_default_labels: []List of default port publishing for docker on OAuth2 Proxy
prometheus_oauth2_default_publish: []prometheus_oauth2_default_publish:
- 127.0.0.1:9089:9089prometheus_oauth2_download:
https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v{{
prometheus_oauth2_version }}/oauth2-proxy-v{{ prometheus_oauth2_version
}}.linux-{{ prometheus_oauth2_arch }}.tar.gzURL of the OAuth2 Proxy to download
prometheus_oauth2_enabled: falseList of extra labels to assign to docker on OAuth2 Proxy
prometheus_oauth2_extra_labels: []List of extra port publishing for docker on OAuth2 Proxy
prometheus_oauth2_extra_publish: []prometheus_oauth2_extra_publish:
- 127.0.0.1:9089:9089prometheus_oauth2_image: quay.io/oauth2-proxy/oauth2-proxy:v{{
prometheus_oauth2_version }}URL of the Keycloak realm
prometheus_oauth2_keycloak_url:Listem address for the OAuth2 proxy
prometheus_oauth2_listen_address: 0.0.0.0:9089Memory limit with Docker deployment
prometheus_oauth2_memory_limit:prometheus_oauth2_memory_limit: 1024mSoft memory limit with Docker deployment
prometheus_oauth2_memory_soft_limit:prometheus_oauth2_memory_soft_limit: 512mSwap usage with Docker deployment
prometheus_oauth2_memory_swap:prometheus_oauth2_memory_swap: 2048mprometheus_oauth2_network: '{{ prometheus_network }}'Number of CPUs with Docker deployment
prometheus_oauth2_number_of_cpus:prometheus_oauth2_number_of_cpus: '1.5'Provider for OAuth2 authentication
prometheus_oauth2_provider: keycloakprometheus_oauth2_pull_image: trueEnable request logging for OAuth2 proxy
prometheus_oauth2_request_logging: falseList of groups assigned to static users
prometheus_oauth2_static_groups: []List of users to allow access
prometheus_oauth2_static_users: []prometheus_oauth2_static_users:
- username: username1
password: p455w0rd
- username: username2
password: p455w0rd
- username: username3
password: p455w0rdUpstream target for the OAuth2 proxy
prometheus_oauth2_upstream: http://{{ prometheus_listen_address if
prometheus_installation == 'native' else 'prometheus:9090' }}Version of the OAuth2 Proxy to download
prometheus_oauth2_version: 7.13.0Pull image as part of the tasks
prometheus_pull_image: trueList of paths to read rule files from
prometheus_rule_files:
- /etc/prometheus/rules/*.ymlList of scrape configuration
prometheus_scrape_configs: []prometheus_scrape_configs:
- job_name: prometheus
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- localhost:9090Global default scrape interval
prometheus_scrape_interval: 15sRetention size to define the maximum size of the data
prometheus_tsdb_retention_size:Retention time to define the maximum age of the data
prometheus_tsdb_retention_time: 30dVersion of the release to install
prometheus_version: 3.7.3oauth2
prometheus
Apache-2.0