Fix password timing on fresh install and cluster settings#92
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
elasticsearch_elastic_passwordis set — the shared role was setting the password fact before ES security setup actually changed itboolfilter rejecting whitespace-padded template outputverify_fetch_password.ymlwhere a skippedregisteroverwrote theset_factresultTest 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)