Skip to content

Code quality: lint fix, variable cleanup, template and task dedup#114

Open
Oddly wants to merge 4 commits intomainfrom
fix/lint-and-variable-cleanup
Open

Code quality: lint fix, variable cleanup, template and task dedup#114
Oddly wants to merge 4 commits intomainfrom
fix/lint-and-variable-cleanup

Conversation

@Oddly
Copy link
Copy Markdown
Owner

@Oddly Oddly commented Mar 27, 2026

Four code quality improvements:

#27 — Fixed the 2 remaining ansible-lint warnings (name[casing]).

#36 — Moved sentinel variables (*_cert_will_expire_soon) from defaults/ to vars/ across all 5 roles. These are internal state that users should never set.

#35 — Extracted shared output/logging blocks from the 3 beats templates into _beats_output.j2 and _beats_logging.j2 partials. Net ~80 lines removed.

#34 — Created shared restart_and_verify_service.yml (used by ES and Logstash) and cert_detect_content_mode.yml (used by beats and kibana). ~135 lines of duplication consolidated.

Closes #27, partial fix for #34, #35, #36.

Oddly added 4 commits March 27, 2026 23:29
Capitalize 'main' to 'Main' in two task names to satisfy the
production profile's requirement that names start with uppercase.

Closes #27
The *_cert_will_expire_soon flags are internal state set by the role
during execution. Users should never set them. Moved from defaults/
(user-overridable) to vars/ (role-internal) in all 5 roles: beats,
elasticsearch, kibana, logstash, elasticstack.

Partial fix for #36
The Elasticsearch/Logstash output and logging configuration was
duplicated across auditbeat.yml.j2, filebeat.yml.j2, and
metricbeat.yml.j2 (~50 lines each, differing only in variable names).

Extracted into two shared partials:
- _beats_output.j2: ES and Logstash output with SSL config
- _beats_logging.j2: logging configuration

Each parent template sets _beat_output, _beat_loadbalance, and
_beat_name before including the partials. Net reduction of ~80 lines.

Partial fix for #35
Shared restart_and_verify_service.yml replaces the near-identical
elasticsearch and logstash versions. Both now delegate to the shared
file with _service_name and _daemon_reload parameters. Kibana kept
separate (has extra HTTP readiness logic). Beats already parameterized.

Shared cert_detect_content_mode.yml extracts the content-vs-file
cert detection pattern from beats and kibana security tasks. Each
caller includes the shared task and maps output facts to service-
specific names. Elasticsearch kept separate (dual transport+HTTP
layers with fallback logic don't fit the single-layer pattern).

Partial fix for #34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix all ansible-lint violations with strict config

1 participant