Fix SPLUNK_LISTEN_ON_IPV6="false" being treated as truthy#901
Fix SPLUNK_LISTEN_ON_IPV6="false" being treated as truthy#901ruomeiy-splunk wants to merge 1 commit intodevelopfrom
Conversation
The string "false" passed via --env is a non-empty string, which is truthy in Python and Jinja2. This caused mgmtHostPort to be set to [::1]:8089 (IPv6) even when the user explicitly set the variable to "false". Normalize the value consistently with other boolean env vars in environ.py (e.g. SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I don't see why the original code is an issue. My understanding is:
That filter/condition should evaluate the "false" string as False and skip the play. Is there something I'm missing/wrong about? |
|
You're right that # roles/splunk_common/tasks/set_mgmt_port.yml:4
localhost_address: "{% if splunk.listen_on_ipv6 %}{{ '[::1]' }}{% else %}{{ '0.0.0.0' }}{% endif %}"In Jinja2, So the two code paths behave differently:
We could alternatively fix |
Summary
SPLUNK_LISTEN_ON_IPV6="false"passed via--envis a non-empty string, which is truthy in Python — causingmgmtHostPortinweb.confto be set to[::1]:8089(IPv6) even when the user intended to disable IPv6..lower() == "true", consistent with how other boolean env vars are handled inenviron.py(e.g.SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH).1c45c9d(Oct 7, 2024).Root cause
In
inventory/environ.py,getIPv6()stored the raw string fromos.environ.get():Test plan
--env SPLUNK_LISTEN_ON_IPV6="false"on Splunk 10.2+ and verifymgmtHostPortis0.0.0.0:8089--env SPLUNK_LISTEN_ON_IPV6="true"and verifymgmtHostPortis[::1]:8089mgmtHostPortis0.0.0.0:8089