Skip to content
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

Use elasticsearch_network_host for connection tests if defined #315

Merged
merged 4 commits into from
Feb 12, 2024

Conversation

ivareri
Copy link
Contributor

@ivareri ivareri commented Feb 9, 2024

When elasticsearch_network_host is set to something not including localhost, all connection tests fails.

This uses elasticsearch_network_host for connections if it is defined, and falls back to localhost if not.

(There might be more places this change should be made, but the role works for me with this fix)

@widhalmt
Copy link
Member

widhalmt commented Feb 9, 2024

Thanks for your contribution! The more we can configure, the better. :-)

@widhalmt widhalmt enabled auto-merge February 9, 2024 15:46
Copy link
Member

@widhalmt widhalmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean and neat. Thank you.

elasticsearch_network_host is a string consisting of different entries in a single string. So this will fail if you set more than one entry for it. I'm afraid we need to rework the logic of this variable so we can still have several values and have your change work.

@widhalmt
Copy link
Member

widhalmt commented Feb 9, 2024

If you want, I can propose a change so the variable will work as a list instead of a string. Then you can fix your PR and we can merge it.

@widhalmt
Copy link
Member

widhalmt commented Feb 9, 2024

When looking at the code, this seems to be even more complicated than I thought. What if someone uses macros like _local_ or _site_ in their elasticsearch_network_host configuration? curl and uri can't use that. Any idea?

@widhalmt
Copy link
Member

widhalmt commented Feb 9, 2024

I opened #317 to work on a larger scale on this.

For now I guess the easiest solution would be if you changed your change request and introduced a new variable like elasticsearch_api_host. Set it to localhost in https://github.com/NETWAYS/ansible-collection-elasticstack/tree/main/roles/elasticsearch/defaults and add a line of documentation to https://github.com/NETWAYS/ansible-collection-elasticstack/blob/main/docs/role-elasticsearch.md .

Maybe we can come up with a way to automatically fill it depending on elasticsearch_network_host automatically.

I really don't like it but if you have a look at #317 I guess you see why I'm struggling with a clean solution.

The reason why I proposed api instead of http or bind_host is that these can also take arrays so we would merely be shifting the problem.

@ivareri ivareri marked this pull request as draft February 10, 2024 07:32
auto-merge was automatically disabled February 10, 2024 07:32

Pull request was converted to draft

@ivareri
Copy link
Contributor Author

ivareri commented Feb 10, 2024

Well duh, I had a feeling this was too neat of a fix.

I agree, elasticsearch_api_host is ugly, but probably the best solution. I'll update the PR.

@ivareri ivareri marked this pull request as ready for review February 10, 2024 09:00
@ivareri
Copy link
Contributor Author

ivareri commented Feb 10, 2024

Note: I have not had a chance to do any extensive testing on this.

I changed all the places I found that does connection checks, so it should hopefully be consistent across the role.

@widhalmt widhalmt enabled auto-merge February 12, 2024 11:41
Copy link
Member

@widhalmt widhalmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work. Even if you missed an occurrence, that's not a problem. Especially since there's more to come. Some connections will be replaced with a module and others should have their own variable (e.g. other roles).

So, approved. Thank you so much.

@widhalmt widhalmt added this pull request to the merge queue Feb 12, 2024
Merged via the queue into NETWAYS:main with commit 7db905b Feb 12, 2024
6 checks passed
@ivareri ivareri deleted the fix/connection-network_host branch February 14, 2024 13:20
@ivareri ivareri mentioned this pull request Mar 7, 2024
2 tasks
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.

2 participants