Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add test for argument_specs matching #177

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/scripts/lint_arguments_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
#
# Description: Lint the defaults/main.yml against the meta/arguments_spec.yml

lint_diff() {
diff -u \
<(yq 'keys | .[]' "${role}/defaults/main.yml" | sort -u) \
<(yq '.argument_specs.main.options | keys | .[] ' "${role}/meta/argument_specs.yml" | sort -u)
return $?
}

error=0

for role in roles/* ; do
echo "Checking ${role}"
if ! lint_diff ; then
echo "ERROR: ${role}: meta/argument_specs.yml doesn't match defaults/main.yml"
error=1
fi
done

exit "${error}"
9 changes: 9 additions & 0 deletions .github/workflows/ansible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ jobs:
- name: Lint collection
uses: ansible/ansible-lint-action@main

arguments-spec-lint:
runs-on: ubuntu-latest
container:
image: quay.io/prometheus/golang-builder:base
steps:
- uses: actions/checkout@v3
- name: Lint arguments spec
run: ./.github/scripts/lint_arguments_spec.sh

discover-ansible-versions:
runs-on: ubuntu-latest
outputs:
Expand Down
6 changes: 6 additions & 0 deletions roles/blackbox_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ argument_specs:
blackbox_exporter_config_dir:
description: "Directory where the blackbox exporter configuration file is placed"
default: "/etc"
blackbox_exporter_user:
description: "The user the exporter runs as"
default: "blackbox-exp"
blackbox_exporter_group:
description: "The group the exporter runs as"
default: "blackbox-exp"
4 changes: 2 additions & 2 deletions roles/mysqld_exporter/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ mysqld_exporter_username: exporter
mysqld_exporter_password: secret

mysqld_exporter_config_file: "mysqld_exporter.cnf"
# mysqld_exporter_host: localhost
# mysqld_exporter_port: 3306
mysqld_exporter_host: null
mysqld_exporter_port: null
mysqld_exporter_socket: "/run/mysqld/mysqld.sock"

mysqld_exporter_tls_server_config: {}
Expand Down
9 changes: 9 additions & 0 deletions roles/mysqld_exporter/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ argument_specs:
mysqld_exporter_web_telemetry_path:
description: "Path under which to expose metrics"
default: "/metrics"
mysqld_exporter_config_dir:
description: "The path where exporter configuration is stored"
default: "/etc/mysqld_exporter"
mysqld_exporter_config_file:
description: "The filename of the exporter mysql config file"
default: "mysqld_exporter.cnf"
Expand All @@ -42,6 +45,12 @@ argument_specs:
mysqld_exporter_socket:
description: "The target MySQL unix socket"
default: "/run/mysqld/mysqld.sock"
mysqld_exporter_username:
description: "The username for MySQL login"
default: "exporter"
mysqld_exporter_password:
description: "The password for MySQL login"
default: "secret"
mysqld_exporter_enabled_collectors:
description:
- "List of dicts defining additionally enabled collectors and their configuration."
Expand Down