Skip to content

Fix password timing on fresh install and cluster settings#92

Merged
Oddly merged 2 commits intomainfrom
fix/password-timing-and-cluster-settings
Mar 10, 2026
Merged

Fix password timing on fresh install and cluster settings#92
Oddly merged 2 commits intomainfrom
fix/password-timing-and-cluster-settings

Conversation

@Oddly
Copy link
Owner

@Oddly Oddly commented Mar 10, 2026

Summary

  • Fix 401 failures on fresh install when elasticsearch_elastic_password is set — the shared role was setting the password fact before ES security setup actually changed it
  • Fix cluster settings silently not being applied due to Ansible 2.19+ bool filter rejecting whitespace-padded template output
  • Fix verify_fetch_password.yml where a skipped register overwrote the set_fact result

Test plan

  • molecule test -s elasticsearch_default (ES 9, user-defined password + cluster settings + LogsDB)
  • molecule test -s logstash_default (Logstash + ES)
  • molecule test -s elasticstack_default (full stack: ES + Logstash + Kibana + Beats)

Oddly added 2 commits March 10, 2026 09:42
The elasticstack shared role sets elasticstack_password to the user-defined
value before the elasticsearch role's security setup has actually changed the
password in ES. On fresh install the passwords file doesn't exist yet, so the
fetch-from-file task is skipped and the premature value stays, causing a 401
on the API availability check. We now clear it to {stdout: ''} so the check
is safely skipped, and added fallback logic that detects a 401 from a prior
password change and switches to the user-defined password for re-runs.

The cluster settings comparison template produced whitespace-padded output
("          True") which Ansible 2.19+ bool filter now coerces to False
instead of True, silently skipping the PUT. Added | trim to fix that.

Also fixed verify_fetch_password.yml where Ansible's register directive on a
skipped shell task overwrote the set_fact result with a dict lacking .stdout.
Swapped the task order so set_fact always runs last and wins.
The ternary() filter eagerly evaluates all arguments, crashing when
_es_cgroup_memory.content is undefined on real VMs (not cgroup-limited).
Replaced with an if/else block. The comment('#') filter style was removed
in Ansible 2.19+ so we use the default (no-arg) form instead. On fresh
installs the elastic password wasn't re-fetched after security setup
created it, leaving downstream tasks without credentials. The Kibana
external certs flow tried to write files before creating /etc/kibana/certs.
@Oddly Oddly merged commit 1be7388 into main Mar 10, 2026
44 of 45 checks passed
@Oddly Oddly deleted the fix/password-timing-and-cluster-settings branch March 10, 2026 11:55
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.

1 participant