Skip to content

Commit

Permalink
feat: add meta/argument_specs.yml file (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
antmelekhin authored Aug 9, 2024
1 parent 38fbe24 commit f52dc3c
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi

# Update latest version
sed -i "s/_version:.*$/_version: '${LATEST_VERSION}'/" 'defaults/main.yml'
sed -i "s/${CURRENT_VERSION}/${LATEST_VERSION}/" 'README.md'
yq eval -i ".argument_specs.main.options.${SOFTWARE}_version.default = \"${LATEST_VERSION}\"" 'meta/argument_specs.yml'

# Repository variables
REPO_NAME=$(git config --get remote.origin.url | sed -e 's|^https://github.com/||')
Expand All @@ -49,7 +49,7 @@ if [ "${REMOTE_BRANCH}" == null ] ; then
git checkout -b "${UPDATE_VERSION_BRANCH}"

# Push new version
git add defaults/main.yml README.md
git add defaults/main.yml meta/argument_specs.yml
git commit --signoff -m "${UPDATE_VERSION_COMMIT}"

echo -e "${GREEN}Pushing to ${UPDATE_VERSION_BRANCH} branch.${NO_COLOR}"
Expand Down
33 changes: 3 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,9 @@ Requirements
Role Variables
--------------

- `postgres_exporter_version` The version of Postgres Exporter to install (default: `0.15.0`).
- `postgres_exporter_archive_name` The Postgres Exporter archive name without an extension. Defaults:
- `postgres_exporter-0.15.0.linux-amd64` (Linux)
- `postgres_exporter-0.15.0.windows-amd64` (Windows)
- `postgres_exporter_download_url` The Postgres Exporter archive download URL (default: `https://github.com/prometheus-community/postgres_exporter/releases/download/v0.15.0`).
- `postgres_exporter_checksum_url` The Postgres Exporter checksum file URL (default: `{{ postgres_exporter_download_url }}/sha256sums.txt`).
- `postgres_exporter_download_path` Local path to download and extract the archive (default: `/tmp`).
- `postgres_exporter_user` and `postgres_exporter_group` System user and group that will be created (default: `postgres_exporter`).
- `postgres_exporter_install_path` The Postgres Exporter installation directory. Defaults:
- `/usr/local/bin` (Linux)
- `C:\Program Files\postgres_exporter` (Windows)
- `postgres_exporter_config_path` The Postgres Exporter directory, that contains the PostgreSQL connection settings. Defaults:
- `/etc/postgres_exporter` (Linux)
- `C:\Program Files\postgres_exporter` (Windows)
- `postgres_exporter_data_source_name` Accepts URI form and key=value form arguments. The URI may contain the username and password to connect with. (default: `user=postgres host=/var/run/postgresql/ sslmode=disable`).
- `postgres_exporter_data_source_uri` An alternative to `postgres_exporter_data_source_name` which exclusively accepts the hostname without a username and password component. Only for Linux.
- `postgres_exporter_data_source_user` When using `postgres_exporter_data_source_uri`, this variable is used to specify the username. Only for Linux.
- `postgres_exporter_data_source_pass` When using `postgres_exporter_data_source_uri`, this variable is used to specify the password to connect with. Only for Linux.
- `postgres_exporter_web_listen_address` The address to listen for the web interface and telemetry (default: `0.0.0.0`).
- `postgres_exporter_web_listen_port` The port number that Postgres Exporter listens on (default: `9187`).
- `postgres_exporter_web_telemetry_path` The path to expose metrics (default: `metrics`).
- `postgres_exporter_collectors` A list of collectors to use (default: `[]`).
- `postgres_exporter_tls_server_config` Certificate and key files for server to use to authenticate to client (default: `{}`).
- `postgres_exporter_http_server_config` Enable HTTP/2 support (default: `{}`). Note that HTTP/2 is only supported with TLS.
- `postgres_exporter_basic_auth_users` Users and password for basic authentication (default: `{}`). Passwords are automatically hashed with bcrypt.
- `postgres_exporter_disable_default_metrics` Use only metrics supplied from queries.yaml via `postgres_exporter_extend_query_path` (default: `false`).
- `postgres_exporter_disable_settings_metrics` Use the flag if you don't want to scrape pg_settings (default: `false`).
- `postgres_exporter_extend_query_path` Path to a YAML file containing custom queries to run. (default: `''`).
- `postgres_exporter_log_level` The Postgres Exporter logging level. Supported levels are: `debug`, `info`, `warn`, `error` (default: `info`).
- `postgres_exporter_log_format` A log message format. Supported formats are: `logfmt`, `json` (default: `logfmt`).
All variables that can be overridden are stored in the [defaults/main.yml](defaults/main.yml) file.
Please refer to the [meta/argument_specs.yml](meta/argument_specs.yml) file for a description of the available variables.
Similarly, descriptions and defaults for preset variables can be found in the [vars/main.yml](vars/main.yml) file.

Dependencies
------------
Expand Down
117 changes: 117 additions & 0 deletions meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
argument_specs:
main:
short_description: 'Postgres Exporter'
description:
- 'An Ansible role to install, configure and update the L(Postgres Exporter,https://github.com/prometheus-community/postgres_exporter).'
author:
- 'Melekhin Anton'
options:
postgres_exporter_version:
type: 'str'
description: 'The version of Postgres Exporter to install.'
default: '0.15.0'
postgres_exporter_archive_name:
type: 'str'
description: 'The Postgres Exporter archive name without an extension.'
default: 'postgres_exporter-{{ postgres_exporter_version }}.{{ __postgres_exporter_os }}-{{ __postgres_exporter_architecture }}'
postgres_exporter_download_url:
type: 'str'
description: 'The Postgres Exporter archive download URL.'
default: 'https://github.com/prometheus-community/postgres_exporter/releases/download/v{{ postgres_exporter_version }}'
postgres_exporter_checksum_url:
type: 'str'
description: 'The Postgres Exporter checksum file URL.'
default: '{{ postgres_exporter_download_url }}/sha256sums.txt'
postgres_exporter_download_path:
type: 'path'
description: 'Local path to download and extract the archive.'
default: '/tmp'
postgres_exporter_user:
type: 'str'
description: 'System user that will be created.'
default: 'postgres_exporter'
postgres_exporter_group:
type: 'str'
description: 'System group that will be created.'
default: '{{ postgres_exporter_user }}'
postgres_exporter_install_path:
type: 'path'
description: 'The Postgres Exporter installation directory.'
default: '{{ __postgres_exporter_install_path }}'
postgres_exporter_config_path:
type: 'path'
description: 'The Postgres Exporter directory, that contains the PostgreSQL connection settings.'
default: '{{ __postgres_exporter_config_path }}'
postgres_exporter_data_source_name:
type: 'str'
description: 'Accepts URI form and key=value form arguments. The URI may contain the username and password to connect with.'
default: '{{ __postgres_exporter_data_source_name }}'
postgres_exporter_data_source_uri:
type: 'str'
description:
- 'I(Only for Linux)'
- 'An alternative to C(postgres_exporter_data_source_name) which exclusively accepts the hostname without a username and password component.'
postgres_exporter_data_source_user:
type: 'str'
description:
- 'I(Only for Linux)'
- 'When using C(postgres_exporter_data_source_uri), this variable is used to specify the username.'
postgres_exporter_data_source_pass:
type: 'str'
description:
- 'I(Only for Linux)'
- 'When using C(postgres_exporter_data_source_uri), this variable is used to specify the password to connect with.'
postgres_exporter_web_listen_address:
type: 'str'
description: 'The address to listen for the web interface and telemetry.'
default: '0.0.0.0'
postgres_exporter_web_listen_port:
type: 'int'
description: 'The port number that Postgres Exporter listens on.'
default: 9187
postgres_exporter_web_telemetry_path:
type: 'str'
description: 'The path to expose metrics.'
default: '/metrics'
postgres_exporter_collectors:
type: 'list'
elements: 'str'
description: 'A list of collectors to use.'
default: []
postgres_exporter_disable_default_metrics:
type: 'bool'
description: 'Use only metrics supplied from queries.yaml via C(postgres_exporter_extend_query_path).'
default: false
postgres_exporter_disable_settings_metrics:
type: 'bool'
description: "Use the flag if you don't want to scrape pg_settings."
default: false
postgres_exporter_extend_query_path:
type: 'path'
description: 'Path to a YAML file containing custom queries to run.'
postgres_exporter_log_level:
type: 'str'
description: 'The Postgres Exporter logging level.'
choices:
- 'debug'
- 'info'
- 'warn'
- 'error'
default: 'info'
postgres_exporter_log_format:
type: 'str'
description: 'A log message output format.'
choices:
- 'logfmt'
- 'json'
default: 'logfmt'
postgres_exporter_tls_server_config:
type: 'dict'
description: 'Certificate and key files for server to use to authenticate to client'
postgres_exporter_http_server_config:
type: 'dict'
description: 'Enable HTTP/2 support. Note that HTTP/2 is only supported with TLS.'
postgres_exporter_basic_auth_users:
type: 'dict'
description: 'Users and password for basic authentication. Passwords are automatically hashed with bcrypt.'

0 comments on commit f52dc3c

Please sign in to comment.