Add pre-commit hooks for code quality and fix all lint violations

Introduces pre-commit framework with hooks for:
- General file hygiene (trailing whitespace, EOF, large files)
- Secret detection (TruffleHog)
- YAML linting (yamllint)
- Ansible linting (ansible-lint)
- Python linting/formatting (ruff)
- Shell script analysis (shellcheck, shfmt)
- TOML formatting (taplo)
- JSON formatting (prettier)

Fixes 91+ ansible-lint violations:
- Renamed variables to use role prefixes (e.g., brew_start -> alloy_brew_start)
- Capitalized handler names per convention
- Added changed_when to command tasks
- Fixed template usage in task names

Fixes shellcheck warnings:
- Removed unused variables
- Fixed SC2155 (declare and assign separately)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-01-16 19:29:53 -08:00
commit 5894d134a8
57 changed files with 1013 additions and 625 deletions

View file

@ -9,17 +9,17 @@
src: prometheus.yml.j2
dest: /opt/homebrew/etc/prometheus.yml
mode: '0644'
notify: restart prometheus
notify: Restart prometheus
- name: Configure prometheus.args
ansible.builtin.template:
src: prometheus.args.j2
dest: /opt/homebrew/etc/prometheus.args
mode: '0644'
notify: restart prometheus
notify: Restart prometheus
- name: Ensure prometheus service is started
ansible.builtin.command: brew services start prometheus
register: brew_start
changed_when: "'Successfully started' in brew_start.stdout"
register: prometheus_brew_start
changed_when: "'Successfully started' in prometheus_brew_start.stdout"
failed_when: false