Skip to content

Commit

Permalink
Merge branch 'prometheus-community:main' into preflight_checksum_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alkinks authored Feb 13, 2024
2 parents fead918 + f189e53 commit f2e7e55
Show file tree
Hide file tree
Showing 38 changed files with 883 additions and 14 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ Prometheus.Prometheus Release Notes

.. contents:: Topics

v0.12.0
=======

Minor Changes
-------------

- feat: Add nginx_exporter role (https://github.com/prometheus-community/ansible/pull/287)

v0.11.3
=======

Bugfixes
--------

- fix: Don't reload services when restarting (https://github.com/prometheus-community/ansible/pull/283)

v0.11.2
=======

v0.11.1
=======
Expand Down
2 changes: 1 addition & 1 deletion changelogs/.plugin-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ plugins:
shell: {}
strategy: {}
vars: {}
version: 0.11.1
version: 0.12.0
18 changes: 18 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
---
ancestor:
releases:
0.12.0:
changes:
minor_changes:
- 'feat: Add nginx_exporter role (https://github.com/prometheus-community/ansible/pull/287)'
release_date: '2024-02-12'
0.11.3:
changes:
bugfixes:
- "fix: Don't reload services when restarting (https://github.com/prometheus-community/ansible/pull/283)"
trivial:
- 'patch: New prometheus-community/ipmi_exporter upstream release 1.8.0! (https://github.com/prometheus-community/ansible/pull/282)'
release_date: '2024-01-24'
0.11.2:
changes:
trivial:
- 'patch: New prometheus/pushgateway upstream release 1.7.0! (https://github.com/prometheus-community/ansible/pull/281)'
- 'patch: New prometheus/prometheus upstream release 2.49.1! (https://github.com/prometheus-community/ansible/pull/278)'
release_date: '2024-01-16'
0.11.1:
changes:
trivial:
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: prometheus
name: prometheus
version: 0.11.1
version: 0.12.0

Check warning on line 4 in galaxy.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

galaxy[version-incorrect]

collection version should be greater than or equal to 1.0.0
readme: README.md
authors:
- "Ben Kochie (https://github.com/SuperQ)"
Expand Down
2 changes: 2 additions & 0 deletions roles/alertmanager/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
daemon_reload: true
name: alertmanager
state: restarted
register: alertmanager_restarted

- name: Reload alertmanager
listen: "reload alertmanager"
become: true
ansible.builtin.systemd:
name: alertmanager
state: reloaded
when: alertmanager_restarted is not defined
2 changes: 2 additions & 0 deletions roles/blackbox_exporter/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
daemon_reload: true
name: blackbox_exporter
state: restarted
register: blackbox_exporter_restarted

- name: Reload blackbox_exporter
listen: "reload blackbox_exporter"
become: true
ansible.builtin.systemd:
name: blackbox_exporter
state: reloaded
when: blackbox_exporter_restarted is not defined
2 changes: 1 addition & 1 deletion roles/ipmi_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
ipmi_exporter_version: 1.7.0
ipmi_exporter_version: 1.8.0
ipmi_exporter_binary_local_dir: ""
ipmi_exporter_binary_url: "https://github.com/{{ _ipmi_exporter_repo }}/releases/download/v{{ ipmi_exporter_version }}/\
ipmi_exporter-{{ ipmi_exporter_version }}.linux-{{ go_arch }}.tar.gz"
Expand Down
2 changes: 1 addition & 1 deletion roles/ipmi_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ argument_specs:
options:
ipmi_exporter_version:
description: "ipmi_exporter package version. Also accepts latest as parameter."
default: "0.14.2"
default: "1.8.0"
ipmi_exporter_skip_install:
description: "ipmi_exporter installation tasks gets skipped when set to true."
type: bool
Expand Down
44 changes: 44 additions & 0 deletions roles/nginx_exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<p><img src="https://www.circonus.com/wp-content/uploads/2015/03/sol-icon-itOps.png" alt="graph logo" title="graph" align="right" height="60" /></p>

# Ansible Role: nginx_exporter

## Description

Deploy prometheus [nginx_exporter](https://github.com/nginxinc/nginx-prometheus-exporter) using ansible.

## Requirements

- Ansible >= 2.9 (It might work on previous versions, but we cannot guarantee it)
- gnu-tar on Mac deployer host (`brew install gnu-tar`)
- Passlib is required when using the basic authentication feature (`pip install passlib[bcrypt]`)

## Role Variables

All variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in [meta/argument_specs.yml](meta/argument_specs.yml).
Please refer to the [collection docs](https://prometheus-community.github.io/ansible/branch/main/nginx_exporter_role.html) for description and default values of the variables.

## Example

### Demo site

We provide demo site for full monitoring solution based on prometheus and grafana. Repository with code and links to running instances is [available on github](https://github.com/prometheus/demo-site) and site is hosted on [DigitalOcean](https://digitalocean.com).

## Local Testing

The preferred way of locally testing the role is to use Docker and [molecule](https://github.com/ansible-community/molecule) (v3.x). You will have to install Docker on your system. See "Get started" for a Docker package suitable to for your system. Running your tests is as simple as executing `molecule test`.

## Continuous Intergation

Combining molecule and circle CI allows us to test how new PRs will behave when used with multiple ansible versions and multiple operating systems. This also allows use to create test scenarios for different role configurations. As a result we have a quite large test matrix which can take more time than local testing, so please be patient.

## Contributing

See [contributor guideline](CONTRIBUTING.md).

## Troubleshooting

See [troubleshooting](TROUBLESHOOTING.md).

## License

This project is licensed under MIT License. See [LICENSE](/LICENSE) for more details.
25 changes: 25 additions & 0 deletions roles/nginx_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
nginx_exporter_version: 1.1.0
nginx_exporter_binary_local_dir: ""
nginx_exporter_binary_url: "https://github.com/{{ _nginx_exporter_repo }}/releases/download/v{{ nginx_exporter_version }}/\
nginx-prometheus-exporter_{{ nginx_exporter_version }}_linux_{{ go_arch }}.tar.gz"
nginx_exporter_checksums_url: "https://github.com/{{ _nginx_exporter_repo }}/releases/download/v{{ nginx_exporter_version }}/\
nginx-prometheus-exporter_{{ nginx_exporter_version }}_checksums.txt"
nginx_exporter_skip_install: false
nginx_exporter_plus: false
nginx_exporter_scrape_uri: "http://127.0.0.1/stub_status"
nginx_exporter_web_listen_address: "0.0.0.0:9113"
nginx_exporter_web_telemetry_path: "/metrics"

nginx_exporter_tls_server_config: {}

nginx_exporter_http_server_config: {}

nginx_exporter_basic_auth_users: {}

nginx_exporter_log_level: "info"
nginx_exporter_log_format: "logfmt"

nginx_exporter_binary_install_dir: "/usr/local/bin"
nginx_exporter_system_group: "nginx-exp"
nginx_exporter_system_user: "{{ nginx_exporter_system_group }}"
10 changes: 10 additions & 0 deletions roles/nginx_exporter/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Restart nginx_exporter
listen: "restart nginx_exporter"
become: true
ansible.builtin.systemd:
daemon_reload: true
name: nginx_exporter
state: restarted
when:
- not ansible_check_mode
75 changes: 75 additions & 0 deletions roles/nginx_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
# yamllint disable rule:line-length
argument_specs:
main:
short_description: "Prometheus nginx_exporter"
description:
- "Deploy prometheus L(nginx exporter,https://github.com/nginxinc/nginx-prometheus-exporter) using ansible"
author:
- "Prometheus Community"
options:
nginx_exporter_version:
description: "nginx_exporter package version. Also accepts latest as parameter."
default: "1.1.0"
nginx_exporter_skip_install:
description: "nginx_exporter installation tasks gets skipped when set to true."
type: bool
default: false
nginx_exporter_plus:
description: "Start the exporter for NGINX Plus."
type: bool
default: false
nginx_exporter_binary_local_dir:
description:
- "Enables the use of local packages instead of those distributed on github."
- "The parameter may be set to a directory where the C(nginx_exporter) binary is stored on the host where ansible is run."
- "This overrides the I(nginx_exporter_version) parameter"
nginx_exporter_binary_url:
description: "URL of the nginx_exporter binaries .tar.gz file"
default: "https://github.com/{{ _nginx_exporter_repo }}/releases/download/v{{ nginx_exporter_version }}/nginx_exporter-{{ nginx_exporter_version }}.linux-{{ go_arch }}.tar.gz"
nginx_exporter_checksums_url:
description: "URL of the nginx_exporter checksums file"
default: "https://github.com/{{ _nginx_exporter_repo }}/releases/download/v{{ nginx_exporter_version }}/nginx-prometheus-exporter_{{ nginx_exporter_version }}_checksums.txt"
nginx_exporter_web_listen_address:
description: "Address on which nginx exporter will listen"
default: "0.0.0.0:9113"
nginx_exporter_web_telemetry_path:
description: "Path under which to expose metrics"
default: "/metrics"
nginx_exporter_tls_server_config:
description:
- "Configuration for TLS authentication."
- "Keys and values are the same as in L(nginx_exporter docs,https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md)."
type: "dict"
nginx_exporter_http_server_config:
description:
- "Config for HTTP/2 support."
- "Keys and values are the same as in L(nginx_exporter docs,https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md)."
type: "dict"
nginx_exporter_basic_auth_users:
description: "Dictionary of users and password for basic authentication. Passwords are automatically hashed with bcrypt."
type: "dict"
nginx_exporter_log_level:
description: "Only log messages with the given severity or above. One of: [debug, info, warn, error]"
default: "info"
nginx_exporter_log_format:
description: "Output format of log messages. One of: [logfmt, json]"
default: "logfmt"
nginx_exporter_scrape_uri:
description: "A URI or unix domain socket path for scraping NGINX or NGINX Plus metrics. For NGINX, the stub_status page must be available through the URI."
default: "http://127.0.0.1/stub_status"
nginx_exporter_binary_install_dir:
description:
- "I(Advanced)"
- "Directory to install nginx_exporter binary"
default: "/usr/local/bin"
nginx_exporter_system_group:
description:
- "I(Advanced)"
- "System group for nginx_exporter"
default: "nginx-exp"
nginx_exporter_system_user:
description:
- "I(Advanced)"
- "nginx_exporter user"
default: "nginx-exp"
30 changes: 30 additions & 0 deletions roles/nginx_exporter/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
galaxy_info:
author: "Prometheus Community"
description: "Prometheus nginx_exporter"
license: "Apache"
min_ansible_version: "2.9"
platforms:
- name: "Ubuntu"
versions:
- "focal"
- "jammy"
- name: "Debian"
versions:
- "bullseye"
- "buster"
- name: "EL"
versions:
- "7"
- "8"
- "9"
- name: "Fedora"
versions:
- "37"
- '38'
galaxy_tags:
- "monitoring"
- "prometheus"
- "exporter"
- "metrics"
- "system"
17 changes: 17 additions & 0 deletions roles/nginx_exporter/molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
provisioner:
inventory:
group_vars:
all:
nginx_exporter_binary_local_dir: "/tmp/nginx_exporter-linux-amd64_local"
nginx_exporter_web_listen_address: "127.0.0.1:9113"

nginx_exporter_tls_server_config:
cert_file: /etc/nginx_exporter/tls.cert
key_file: /etc/nginx_exporter/tls.key
nginx_exporter_http_server_config:
http2: true
nginx_exporter_basic_auth_users:
randomuser: examplepassword
go_arch: amd64
nginx_exporter_version: 1.1.0
74 changes: 74 additions & 0 deletions roles/nginx_exporter/molecule/alternative/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
- name: Run local preparation
hosts: localhost
gather_facts: false
tasks:
- name: Download nginx_exporter binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v{{ nginx_exporter_version }}/\
nginx-prometheus-exporter_{{ nginx_exporter_version }}_linux_{{ go_arch }}.tar.gz"
dest: "/tmp/nginx-prometheus-exporter_{{ nginx_exporter_version }}_linux_{{ go_arch }}.tar.gz"
mode: 0644
register: _download_binary
until: _download_binary is succeeded
retries: 5
delay: 2
check_mode: false

- name: Create local directory for binary
ansible.builtin.file:
path: "{{ nginx_exporter_binary_local_dir }}"
state: directory
mode: '0755'

- name: Unpack nginx_exporter binary
become: false
ansible.builtin.unarchive:
src: "/tmp/nginx-prometheus-exporter_{{ nginx_exporter_version }}_linux_{{ go_arch }}.tar.gz"
dest: "{{ nginx_exporter_binary_local_dir }}"
creates: "{{ nginx_exporter_binary_local_dir }}/nginx-prometheus-exporter"
check_mode: false

- name: Install pyOpenSSL for certificate generation
ansible.builtin.pip:
name: "pyOpenSSL"

- name: Create private key
community.crypto.openssl_privatekey:
path: "/tmp/tls.key"

- name: Create CSR
community.crypto.openssl_csr:
path: "/tmp/tls.csr"
privatekey_path: "/tmp/tls.key"

- name: Create certificate
community.crypto.x509_certificate:
path: "/tmp/tls.cert"
csr_path: "/tmp/tls.csr"
privatekey_path: "/tmp/tls.key"
provider: selfsigned

- name: Run target preparation
hosts: all
any_errors_fatal: true
tasks:
- name: Create nginx_exporter cert dir
ansible.builtin.file:
path: "{{ nginx_exporter_tls_server_config.cert_file | dirname }}"
state: directory
owner: root
group: root
mode: u+rwX,g+rwX,o=rX

- name: Copy cert and key
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode | default('0644') }}"
loop:
- src: "/tmp/tls.cert"
dest: "{{ nginx_exporter_tls_server_config.cert_file }}"
- src: "/tmp/tls.key"
dest: "{{ nginx_exporter_tls_server_config.key_file }}"
Loading

0 comments on commit f2e7e55

Please sign in to comment.