Skip to content

Using environment variable for square brackets is not documented, not obvious #6352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthughes opened this issue May 30, 2014 · 9 comments · Fixed by #57370
Closed

Using environment variable for square brackets is not documented, not obvious #6352

matthughes opened this issue May 30, 2014 · 9 comments · Fixed by #57370
Assignees
Labels
:Core/Infra/Core Core issues without another label >docs General docs changes >enhancement good first issue low hanging fruit help wanted adoptme Team:Core/Infra Meta label for core/infra team Team:Docs Meta label for docs team

Comments

@matthughes
Copy link
Contributor

The example config in elasticsearch.yml is:

#discovery.zen.ping.unicast.hosts: ["host1", "host2:port"]

Using environment variables, I would assume to replace everything in square brackets:
export ES_HOSTS="[host1, host2:port]" discovery.zen.ping.unicast.hosts: $ES_HOSTS

This does not parse correctly though. The only way I could get it to work was omit the brackets:
export ES_HOSTS="host1, host2:port" discovery.zen.ping.unicast.hosts: $ES_HOSTS

Given that this is not documented, not obvious, and also parses fine as:
#discovery.zen.ping.unicast.hosts: "host1", "host2:port"

I propose we change the default config file. There is also no other use of square brackets in the config file.

@matthughes
Copy link
Contributor Author

@matthughes matthughes changed the title Format for Using environment variable for square brackets is not documented, not obvious May 30, 2014
@clintongormley
Copy link
Contributor

Hi @matthughes

Sorry it has taken a while to look at this. The config file is just YAML, and arrays are perfectly acceptable in YAML, so I don't think it is worth preventing arrays from working.

I agree though that the documentation could be improved, specifically here: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-configuration.html#styles

@clintongormley clintongormley added >docs General docs changes >enhancement help wanted adoptme good first issue low hanging fruit labels Dec 30, 2014
@palecur palecur self-assigned this Dec 2, 2015
@clintongormley clintongormley assigned debadair and unassigned palecur Jan 15, 2016
@debadair
Copy link
Contributor

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@colings86 colings86 added the :Core/Infra/Core Core issues without another label label Apr 24, 2018
@rajat-garg
Copy link

Hey, I want to pick this up as my first OS contribution. Can someone help me?

@debadair
Copy link
Contributor

[docs issue triage]

@rjernst rjernst added Team:Core/Infra Meta label for core/infra team Team:Docs Meta label for docs team labels May 4, 2020
@lockewritesdocs
Copy link
Contributor

lockewritesdocs commented May 12, 2020

Looking at the Configuring Elasticsearch page for 7.6, there are no brackets included in examples. The only inclusions of brackets in a supported version are in the 6.8 version, which shows:

Enter value for [node.name]:

@debadair, is that a worthwhile change? Otherwise, it seems this issue is no longer relevant.

@lockewritesdocs
Copy link
Contributor

Talked to @jrodewig about this one, and he thinks that there's value in documenting how arrays work for environment variables.

@lockewritesdocs
Copy link
Contributor

lockewritesdocs commented May 26, 2020

I did some limited testing with the following variables in elasticsearch.yml:

node.name: ${HOSTNAME}
discovery.seed_hosts: ${HOST1}, ${HOST2}

If I include brackets around the variables [] like in an array, Elasticsearch throws an error and fails to start. Entering the variables without the brackets (as shown), I then ran:

export HOST1="127.0.0.1"
export HOST2="127.0.0.1:12"
export HOSTNAME="valhalla"

I then started Elasticsearch, which started normally. My takeaway is that brackets are not required when passing multiple variables in elasticsearch.yml. I think that we can enhance the examples in the Environment variable substitution section to show multiple variables and indicate that brackets are not required.

@rjernst, can you please review my findings and let me know if I'm on the right track? I'm still learning who does what, but I think that this is your area of expertise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >docs General docs changes >enhancement good first issue low hanging fruit help wanted adoptme Team:Core/Infra Meta label for core/infra team Team:Docs Meta label for docs team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants