Skip to content

Commit

Permalink
Merge pull request #422 from gardar/ci/detect_unused_vars
Browse files Browse the repository at this point in the history
minor(ci): detect unused ansible variables
  • Loading branch information
gardar authored Oct 2, 2024
2 parents 4e881c6 + 60b5c5f commit 36a91f0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
13 changes: 10 additions & 3 deletions .github/scripts/discover_role_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
# Description: Discover the upstream repo from each role default vars.

result=$(
for defaults_file in roles/*/vars/main.yml ; do
role="$(echo "${defaults_file}" | cut -f2 -d'/')"
yq eval "[{\"repo\": ._${role}_repo, \"role\": \"${role}\", \"type\": ._${role}_repo_type // \"github\"}]" "${defaults_file}"
for role_dir in roles/*/ ; do
role="$(basename "${role_dir}")"
role_repo=$(yq eval "._${role}_repo" "${role_dir}/vars/main.yml" 2>/dev/null)
yq eval "[{
\"repo\": \"${role_repo}\",
\"role\": \"${role}\",
\"type\": (.${role}_binary_url | split(\"/\")[2] | split(\".\")[0] // \"github\")
}]" "${role_dir}/defaults/main.yml" 2>/dev/null
done | yq -o json -I=0
)

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ansible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ jobs:
- name: Lint arguments spec
run: ./.github/scripts/lint_arguments_spec.sh

check-unused-variables:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run action
uses: hoo29/little-timmy@v1-action

discover-ansible-versions:
runs-on: ubuntu-latest
outputs:
Expand Down
1 change: 0 additions & 1 deletion roles/fail2ban_exporter/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ go_arch_map:

go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
_fail2ban_exporter_repo: 24199687
_fail2ban_exporter_repo_type: gitlab
1 change: 0 additions & 1 deletion roles/smokeping_prober/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ smokeping_prober_checksums_url: "https://github.com/{{ _smokeping_prober_repo }}
smokeping_prober_skip_install: false

smokeping_prober_web_listen_address: "0.0.0.0:9374"
smokeping_prober_web_telemetry_path: "/metrics"

# List of smokeping_prober targets.
# See: https://github.com/SuperQ/smokeping_prober/#configuration
Expand Down
3 changes: 0 additions & 3 deletions roles/smokeping_prober/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ argument_specs:
smokeping_prober_web_listen_address:
description: "Address on which Smokeping Prober will listen"
default: "0.0.0.0:9374"
smokeping_prober_web_telemetry_path:
description: "Path under which to expose metrics"
default: "/metrics"
smokeping_prober_config_dir:
description: "The directory of the smokeping_prober probes config files"
default: "/etc/smokeping_prober"
Expand Down

0 comments on commit 36a91f0

Please sign in to comment.