### Basic Playbook Example Source: https://github.com/prometheus-community/ansible/blob/main/roles/mysqld_exporter/README.md Use this playbook to deploy the mysqld_exporter role. Ensure the prometheus.prometheus collection is installed. ```yaml - hosts: all collections: - prometheus.prometheus roles: - prometheus.prometheus.mysqld_exporter ``` -------------------------------- ### Alertmanager Ansible Playbook Example Source: https://github.com/prometheus-community/ansible/blob/main/roles/alertmanager/README.md Example playbook to deploy Alertmanager with custom configurations for version, Slack integration, receivers, and routing. ```yaml --- hosts: all roles: - prometheus.prometheus.alertmanager vars: alertmanager_version: latest alertmanager_slack_api_url: "http://example.com" alertmanager_receivers: - name: slack slack_configs: - send_resolved: true channel: '#alerts' alertmanager_route: group_by: ['alertname', 'cluster', 'service'] group_wait: 30s group_interval: 5m repeat_interval: 3h receiver: slack ``` -------------------------------- ### Playbook with TLS and Basic Auth Configuration Source: https://github.com/prometheus-community/ansible/blob/main/roles/mysqld_exporter/README.md This example demonstrates configuring TLS certificates and basic authentication users for the mysqld_exporter. Ensure certificates and keys are provisioned before running. ```yaml - hosts: all pre_tasks: - name: Create mysqld_exporter cert dir ansible.builtin.file: path: "/etc/mysqld_exporter" state: directory owner: root group: root - name: Create cert and key community.crypto.x509_certificate: path: /etc/mysqld_exporter/tls.cert csr_path: /etc/mysqld_exporter/tls.csr privatekey_path: /etc/mysqld_exporter/tls.key provider: selfsigned collections: - prometheus.prometheus roles: - prometheus.prometheus.mysqld_exporter vars: mysqld_exporter_tls_server_config: cert_file: /etc/mysqld_exporter/tls.cert key_file: /etc/mysqld_exporter/tls.key mysqld_exporter_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### Install Tox Source: https://github.com/prometheus-community/ansible/blob/main/roles/prometheus/README.md Install the tox testing tool using pip. This is a prerequisite for running automated tests across different Python and Ansible versions. ```sh pip3 install tox ``` -------------------------------- ### Prometheus Targets Configuration Example Source: https://github.com/prometheus-community/ansible/blob/main/roles/prometheus/README.md Defines file-based service discovery targets for Prometheus. The top-level keys become filenames in the `file_sd` directory. ```yaml prometheus_targets: node: # This is a base file name. File is located in "{{ prometheus_config_dir }}/file_sd/<>.yml" - targets: # - localhost:9100 # All this is a targets section in file_sd format labels: # env: test # ``` -------------------------------- ### Playbook with TLS and Basic Auth Configuration Source: https://github.com/prometheus-community/ansible/blob/main/roles/chrony_exporter/README.md This example demonstrates how to configure TLS certificates and basic authentication for the chrony_exporter. It requires pre-provisioned certificates and keys, and specifies user credentials. ```yaml - hosts: all pre_tasks: - name: Create chrony_exporter cert dir file: path: "/etc/chrony_exporter" state: directory owner: root group: root - name: Create cert and key openssl_certificate: path: /etc/chrony_exporter/tls.cert csr_path: /etc/chrony_exporter/tls.csr privatekey_path: /etc/chrony_exporter/tls.key provider: selfsigned roles: - prometheus.prometheus.chrony_exporter vars: chrony_exporter_tls_server_config: cert_file: /etc/chrony_exporter/tls.cert key_file: /etc/chrony_exporter/tls.key chrony_exporter_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### Deploy Apache Exporter with Ansible Source: https://github.com/prometheus-community/ansible/blob/main/roles/apache_exporter/README.md Basic playbook to deploy the Apache Exporter role. Ensure the prometheus.prometheus collection is installed. ```yaml - hosts: all collections: - prometheus.prometheus roles: - prometheus.prometheus.apache_exporter ``` -------------------------------- ### TLS Configuration for smokeping_prober Source: https://github.com/prometheus-community/ansible/blob/main/roles/smokeping_prober/README.md Configure TLS for the smokeping_prober by creating a certificate directory and generating a self-signed certificate and key. This example also sets up basic authentication. ```yaml - hosts: all pre_tasks: - name: Create smokeping_prober cert dir ansible.builtin.file: path: "/etc/smokeping_prober" state: directory owner: root group: root - name: Create cert and key community.crypto.x509_certificate: path: /etc/smokeping_prober/tls.cert csr_path: /etc/smokeping_prober/tls.csr privatekey_path: /etc/smokeping_prober/tls.key provider: selfsigned collections: - prometheus.prometheus roles: - prometheus.prometheus.smokeping_prober vars: smokeping_prober_tls_server_config: cert_file: /etc/smokeping_prober/tls.cert key_file: /etc/smokeping_prober/tls.key smokeping_prober_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### Ansible Collection Plugins Directory Structure Source: https://github.com/prometheus-community/ansible/blob/main/plugins/README.md This example shows the typical directory layout for shipping various plugins inside an Ansible collection. It includes common plugin types and directories for module utilities and modules. ```directory └── plugins ├── action ├── become ├── cache ├── callback ├── cliconf ├── connection ├── filter ├── httpapi ├── inventory ├── lookup ├── module_utils ├── modules ├── netconf ├── shell ├── strategy ├── terminal ├── test └── vars ``` -------------------------------- ### Deploy BIND exporter using Ansible Role Source: https://github.com/prometheus-community/ansible/blob/main/roles/bind_exporter/README.md Use this playbook to deploy the BIND exporter role. Ensure the prometheus.prometheus collection is installed. ```yaml - hosts: all collections: - prometheus.prometheus roles: - prometheus.prometheus.bind_exporter ``` -------------------------------- ### Basic Playbook Deployment Source: https://github.com/prometheus-community/ansible/blob/main/roles/postgres_exporter/README.md Use this snippet to include the PostgreSQL exporter role in your Ansible playbook. Ensure the 'prometheus.prometheus' collection is installed. ```yaml - hosts: all collections: - prometheus.prometheus roles: - prometheus.prometheus.postgres_exporter ``` -------------------------------- ### TLS Configuration for Consul Exporter Source: https://github.com/prometheus-community/ansible/blob/main/roles/consul_exporter/README.md Configure TLS for the consul_exporter by provisioning a certificate and key, and specifying their paths in the role variables. This example also demonstrates setting up basic authentication users. ```yaml - hosts: all pre_tasks: - name: Create consul_exporter cert dir file: path: "/etc/consul_exporter" state: directory owner: root group: root - name: Create cert and key openssl_certificate: path: /etc/consul_exporter/tls.cert csr_path: /etc/consul_exporter/tls.csr privatekey_path: /etc/consul_exporter/tls.key provider: selfsigned roles: - prometheus.prometheus.consul_exporter vars: consul_exporter_tls_server_config: cert_file: /etc/consul_exporter/tls.cert key_file: /etc/consul_exporter/tls.key consul_exporter_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### Deploy Blackbox Exporter with Ansible Role Source: https://github.com/prometheus-community/ansible/blob/main/roles/blackbox_exporter/README.md This playbook demonstrates how to include and configure the Blackbox Exporter role in your Ansible deployment. Ensure the role is correctly installed in your Ansible environment. ```yaml - hosts: all become: true roles: - prometheus.prometheus.blackbox_exporter ``` -------------------------------- ### TLS and Basic Auth Configuration Source: https://github.com/prometheus-community/ansible/blob/main/roles/postgres_exporter/README.md Configure TLS for secure communication and set up basic authentication for the PostgreSQL exporter. This requires pre-provisioning a certificate and key. ```yaml - hosts: all pre_tasks: - name: Create postgres_exporter cert dir ansible.builtin.file: path: "/etc/postgres_exporter" state: directory owner: root group: root - name: Create cert and key community.crypto.x509_certificate: path: /etc/postgres_exporter/tls.cert csr_path: /etc/postgres_exporter/tls.csr privatekey_path: /etc/postgres_exporter/tls.key provider: selfsigned collections: - prometheus.prometheus roles: - prometheus.prometheus.postgres_exporter vars: postgres_exporter_tls_server_config: cert_file: /etc/postgres_exporter/tls.cert key_file: /etc/postgres_exporter/tls.key postgres_exporter_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### Configure TLS for Apache Exporter Source: https://github.com/prometheus-community/ansible/blob/main/roles/apache_exporter/README.md Playbook snippet to set up TLS certificates and keys for the Apache Exporter. Requires pre-provisioned certificates or using the x509_certificate module for self-signed certificates. Basic authentication users can also be configured. ```yaml - hosts: all pre_tasks: - name: Create apache_exporter cert dir ansible.builtin.file: path: "/etc/apache_exporter" state: directory owner: root group: root - name: Create cert and key community.crypto.x509_certificate: path: /etc/apache_exporter/tls.cert csr_path: /etc/apache_exporter/tls.csr privatekey_path: /etc/apache_exporter/tls.key provider: selfsigned collections: - prometheus.prometheus roles: - prometheus.prometheus.apache_exporter vars: apache_exporter_tls_server_config: cert_file: /etc/apache_exporter/tls.cert key_file: /etc/apache_exporter/tls.key apache_exporter_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### TLS and Basic Auth Configuration Source: https://github.com/prometheus-community/ansible/blob/main/roles/node_exporter/README.md Configure TLS for secure communication and basic authentication for user access. Ensure certificates and keys are provisioned before running the role. ```yaml - hosts: all pre_tasks: - name: Create node_exporter cert dir file: path: "/etc/node_exporter" state: directory owner: root group: root - name: Create cert and key openssl_certificate: path: /etc/node_exporter/tls.cert csr_path: /etc/node_exporter/tls.csr privatekey_path: /etc/node_exporter/tls.key provider: selfsigned roles: - prometheus.prometheus.node_exporter vars: node_exporter_tls_server_config: cert_file: /etc/node_exporter/tls.cert key_file: /etc/node_exporter/tls.key node_exporter_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### TLS Configuration for Pushgateway Source: https://github.com/prometheus-community/ansible/blob/main/roles/pushgateway/README.md Configure TLS for the Pushgateway by providing certificate and key files. Ensure the certificate directory exists and is owned by root. ```yaml - hosts: all pre_tasks: - name: Create pushgateway cert dir file: path: "/etc/pushgateway" state: directory owner: root group: root - name: Create cert and key openssl_certificate: path: /etc/pushgateway/tls.cert csr_path: /etc/pushgateway/tls.csr privatekey_path: /etc/pushgateway/tls.key provider: selfsigned roles: - prometheus.prometheus.pushgateway vars: pushgateway_tls_server_config: cert_file: /etc/pushgateway/tls.cert key_file: /etc/pushgateway/tls.key pushgateway_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### Basic Playbook Usage Source: https://github.com/prometheus-community/ansible/blob/main/roles/node_exporter/README.md Include the node_exporter role in your playbook to deploy it to all hosts. ```yaml - hosts: all roles: - prometheus.prometheus.node_exporter ``` -------------------------------- ### Configure TLS for BIND exporter with Ansible Source: https://github.com/prometheus-community/ansible/blob/main/roles/bind_exporter/README.md This playbook configures TLS certificates and keys for the BIND exporter and sets up basic authentication. It requires the community.crypto collection for x509_certificate module. ```yaml - hosts: all pre_tasks: - name: Create bind_exporter cert dir ansible.builtin.file: path: "/etc/bind_exporter" state: directory owner: root group: root - name: Create cert and key community.crypto.x509_certificate: path: /etc/bind_exporter/tls.cert csr_path: /etc/bind_exporter/tls.csr privatekey_path: /etc/bind_exporter/tls.key provider: selfsigned collections: - prometheus.prometheus roles: - prometheus.prometheus.bind_exporter vars: bind_exporter_tls_server_config: cert_file: /etc/bind_exporter/tls.cert key_file: /etc/bind_exporter/tls.key bind_exporter_basic_auth_users: randomuser: examplepassword ``` -------------------------------- ### Basic Playbook Usage Source: https://github.com/prometheus-community/ansible/blob/main/roles/pushgateway/README.md Include the pushgateway role in your Ansible playbook to deploy the service. ```yaml - hosts: all roles: - prometheus.prometheus.pushgateway ``` -------------------------------- ### Ansible Playbook for Prometheus Deployment Source: https://github.com/prometheus-community/ansible/blob/main/roles/prometheus/README.md A basic Ansible playbook to deploy the Prometheus role. It includes a sample `prometheus_targets` variable. ```yaml --- - hosts: all roles: - prometheus.prometheus.prometheus vars: prometheus_targets: node: - targets: - localhost:9100 - node.demo.do.prometheus.io labels: env: demosite ``` -------------------------------- ### Run All Tox Tests Source: https://github.com/prometheus-community/ansible/blob/main/roles/prometheus/README.md Execute all defined test environments using tox. This command runs tests across multiple Ansible versions and can take a significant amount of time. ```sh tox ``` -------------------------------- ### Prometheus Configuration for cAdvisor Source: https://github.com/prometheus-community/ansible/blob/main/roles/cadvisor/README.md Configure Prometheus to scrape metrics from cAdvisor, ensuring correct handling of timestamps and staleness. ```yaml prometheus_scrape_configs: - job_name: cadvisor scrape_interval: 10s track_timestamps_staleness: true ``` -------------------------------- ### Prometheus Scrape Configs with File SD Source: https://github.com/prometheus-community/ansible/blob/main/roles/prometheus/README.md Configures Prometheus scrape jobs, including one that loads targets from a file generated by `prometheus_targets`. ```yaml prometheus_scrape_configs: - job_name: "prometheus" # Custom scrape job, here using `static_config` metrics_path: "/metrics" static_configs: - targets: - "localhost:9090" - job_name: "example-node-file-servicediscovery" file_sd_configs: - files: - "{{ prometheus_config_dir }}/file_sd/node.yml" # This line loads file created from `prometheus_targets` ``` -------------------------------- ### Run Custom Molecule Command with Tox Source: https://github.com/prometheus-community/ansible/blob/main/roles/prometheus/README.md Run a specific molecule command within a custom tox environment. This allows for targeted testing on a particular Ansible version (e.g., py35-ansible28) and a specific molecule scenario (e.g., default). ```sh tox -e py35-ansible28 -- molecule test -s default ``` -------------------------------- ### Basic Playbook Integration Source: https://github.com/prometheus-community/ansible/blob/main/roles/systemd_exporter/README.md Integrate the systemd_exporter role into your Ansible playbook to deploy the exporter on all hosts. ```yaml - hosts: all roles: - prometheus.prometheus.systemd_exporter ``` -------------------------------- ### TLS Server Configuration for systemd exporter Source: https://github.com/prometheus-community/ansible/blob/main/roles/systemd_exporter/README.md Configure TLS for the systemd exporter. This requires systemd_exporter version 0.5.0 or later. Ensure the cert_file and key_file paths are correct. ```yaml systemd_exporter_tls_server_config: cert_file: /etc/systemd_exporter/tls.cert key_file: /etc/systemd_exporter/tls.key ``` -------------------------------- ### Enable Textfile Collector in node_exporter Source: https://github.com/prometheus-community/ansible/blob/main/roles/node_exporter/TROUBLESHOOTING.md Configure the node_exporter to enable the textfile collector by including 'textfile' in the `node_exporter_enabled_collectors` list. Ensure the `node_exporter_textfile_dir` variable points to the correct directory for metrics files. ```yaml node_exporter_enabled_collectors: - textfile: directory: "{{ node_exporter_textfile_dir }}" ``` -------------------------------- ### Basic Playbook Integration Source: https://github.com/prometheus-community/ansible/blob/main/roles/smokeping_prober/README.md Integrate the smokeping_prober role into your Ansible playbook. Ensure the prometheus collection is included. ```yaml - hosts: all collections: - prometheus.prometheus roles: - prometheus.prometheus.smokeping_prober ``` -------------------------------- ### Deploy process-exporter with Ansible Source: https://github.com/prometheus-community/ansible/blob/main/roles/process_exporter/README.md Use this playbook to include the process_exporter role in your Ansible deployment. Ensure the role is correctly referenced for your environment. ```yaml - hosts: all roles: - prometheus.prometheus.process_exporter ``` -------------------------------- ### Basic Playbook Usage Source: https://github.com/prometheus-community/ansible/blob/main/roles/chrony_exporter/README.md Include the chrony_exporter role in your Ansible playbook to deploy the exporter. Ensure the role is correctly referenced in your playbook. ```yaml - hosts: all roles: - prometheus.prometheus.chrony_exporter ``` -------------------------------- ### Deploy cAdvisor with Ansible Role Source: https://github.com/prometheus-community/ansible/blob/main/roles/cadvisor/README.md Integrate the cAdvisor Ansible role into your playbook to deploy cAdvisor on all hosts. ```yaml - hosts: all roles: - prometheus.prometheus.cadvisor ``` -------------------------------- ### Deploy Nvidia GPU Exporter with Ansible Source: https://github.com/prometheus-community/ansible/blob/main/roles/nvidia_gpu_exporter/README.md Use this playbook snippet to include the Nvidia GPU exporter role in your Ansible deployment. Ensure the role is correctly referenced by its fully qualified collection name. ```yaml - hosts: all roles: - prometheus.prometheus.nvidia_gpu_exporter ``` -------------------------------- ### Basic Playbook Usage Source: https://github.com/prometheus-community/ansible/blob/main/roles/consul_exporter/README.md Include the consul_exporter role in your Ansible playbook to deploy the exporter. ```yaml - hosts: all roles: - prometheus.prometheus.consul_exporter ``` -------------------------------- ### Deploy InfluxDB Exporter with Ansible Role Source: https://github.com/prometheus-community/ansible/blob/main/roles/influxdb_exporter/README.md Use this playbook snippet to include the InfluxDB exporter role in your Ansible deployment. Ensure the role is correctly referenced by its fully qualified collection name. ```yaml - hosts: all roles: - prometheus.prometheus.influxdb_exporter ``` -------------------------------- ### Unset NETRC Variable (Shell) Source: https://github.com/prometheus-community/ansible/blob/main/roles/bind_exporter/TROUBLESHOOTING.md Unset the NETRC environment variable to prevent conflicts with the netrc mechanism when running ansible-playbook. ```shell $ NETRC= ansible-playbook ... ``` ```shell $ export NETRC= $ ansible-playbook ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.