You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Ansible 2.19 the elasticsearch role handlers in PR #137 fail at runtime with Conditional expressions must be strings.. Ansible 2.19 has tightened conditional evaluation to require pure string expressions, and the dict-literal default({'changed': false}) pattern now triggers this error.
Run any playbook that triggers the Restart Elasticsearch handler on Ansible 2.19.x (e.g. a config change that notifies the handler).
Handler fails before it can run.
Error
[ERROR]: Task failed: Conditional expressions must be strings.
Origin: .../collections/oddly/elasticstack/roles/elasticsearch/handlers/main.yml:10:7
8 - not ansible_check_mode
9 - elasticsearch_enable | bool
10 - not (_elasticsearch_freshstart | default({'changed': false})).changed | bool
^ column 7
Same pattern (8 occurrences across 4 handlers) in roles/elasticsearch/handlers/main.yml:
Mark Elasticsearch restart requested
Restart Elasticsearch directly
and the two follow-up handlers
Suggested fix
Replace the dict-literal default with a default on the attribute:
```diff
not (_elasticsearch_freshstart | default({'changed': false})).changed | bool
not (_elasticsearch_freshstart_security | default({'changed': false})).changed | bool
not (_elasticsearch_freshstart.changed | default(false) | bool)
not (_elasticsearch_freshstart_security.changed | default(false) | bool)
```
Semantically equivalent: both return `false` (don't block restart) when the fact is undefined or when `.changed` is missing. Avoids dict literals inside the conditional, which the 2.19 evaluator rejects.
Summary
With Ansible 2.19 the
elasticsearchrole handlers in PR #137 fail at runtime withConditional expressions must be strings.. Ansible 2.19 has tightened conditional evaluation to require pure string expressions, and the dict-literaldefault({'changed': false})pattern now triggers this error.Reproduction
main(includes fix(elasticsearch): roll config restarts #137 "fix(elasticsearch): roll config restarts").Restart Elasticsearchhandler on Ansible 2.19.x (e.g. a config change that notifies the handler).Error
Same pattern (8 occurrences across 4 handlers) in
roles/elasticsearch/handlers/main.yml:Mark Elasticsearch restart requestedRestart Elasticsearch directlySuggested fix
Replace the dict-literal default with a default on the attribute:
```diff
```
Semantically equivalent: both return `false` (don't block restart) when the fact is undefined or when `.changed` is missing. Avoids dict literals inside the conditional, which the 2.19 evaluator rejects.
Environment
Workaround
Set `ANSIBLE_ALLOW_BROKEN_CONDITIONALS=1` — temporary, not recommended.