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

Fixes for Elasticsearch issue #184 - Testing Elasticsearch functionality when network.host is not localhost. #212

Merged
merged 3 commits into from
Jul 24, 2019

Conversation

rshad
Copy link
Contributor

@rshad rshad commented Jul 24, 2019

Hi team!

In this PR, we resolved the error reported in the issue #184.

As @kravietz reported

The test in roles/wazuh-ansible/roles/elastic-stack/ansible-elasticsearch/tasks/main.yml line 87 only works if the elasticsearch_network_host is set to localhost but ElasticSearch uses this parameter to configure its bind address, so in many real-world instances it will be set to 0.0.0.0 or ::, in which case the test fails.

  • name: Make sure Elasticsearch is running before proceeding
    wait_for: host={{ elasticsearch_network_host }} port={{ elasticsearch_http_port }} delay=3 timeout=300
    tags:
    - configure
    - init

To solve such issue it's needed to have 2 different variables, 1 for network.host and one for representing Elasticsearch host. In this case, we now have:

  • elasticsearch_network_host: 0.0.0.0 : Indicates the hosts which Elasticsearch API will accepts requests from.

network.host
By default, Elasticsearch binds to loopback addresses only — e.g. 127.0.0.1 and [::1]. This is sufficient to run a single development node on a serve

  • elasticsearch_host: 127.0.0.1 : By now, it's used to check if Elasticsearch is running by checking if 127.0.0.1:9200 is available.

- name: Make sure Elasticsearch is running before proceeding
wait_for: host={{ elasticsearch_host }} port={{ elasticsearch_http_port }} delay=3 timeout=400
tags:
- configure
- init

elasticsearch_http_port: 9200
elasticsearch_network_host: 0.0.0.0
elasticsearch_host: 127.0.0.1

In this case, we set elasticsearch_host to 127.0.0.1 instead of 0.0.0.0 because 0.0.0.0 will not be considered as a valid IP, but will refer to the big-world domain.

We also fixed some Ansible-Linting errors by refactoring Ansible tasks in the role of Elasticsearch.

Kind regards,

Rshad

@manuasir manuasir self-requested a review July 24, 2019 11:56
@manuasir manuasir added this to To Review in Wazuh 3.9.x via automation Jul 24, 2019
@manuasir
Copy link
Contributor

Please @rshad , change the PR title.

@@ -2,7 +2,8 @@
elasticsearch_cluster_name: wazuh
elasticsearch_node_name: node-1
elasticsearch_http_port: 9200
elasticsearch_network_host: 127.0.0.1
elasticsearch_network_host: 0.0.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should set this default value as 127.0.0.1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @manuasir ,

No problem. We set it to 0.0.0.0 to simulate the error reported in the related issue.

I've just changed its value to 127.0.0.1 in 125b211 .

.

Kind regards,

Rshad

@@ -26,7 +26,7 @@

- name: Install Oracle Java 8
become: true
apt: name=openjdk-8-jdk state=latest
apt: name=openjdk-8-jdk
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the state=latest statement not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @manuasir,

This change came as result to Ansible-Linting error:

Package installs should not use latest reported in this issue: ansible/ansible-lint#479

This change was made in this commit: ansible/ansible-lint@f5fcee4#diff-42252eea388ddb7d54414f584e9ebc78.

Sincerely, and like many other users facing this issue, I think this restriction has no logic due to the need to upgrade a package to its latest version without worrying about specifying a determined one.

Anyway, I think apt will take the last version by default, so no worries.

Kind regards,

Rshad

@rshad rshad changed the title 3.9.3 7.2.0 issue #184 - Fixes for Elasticsearch issue #184 - Testing Elasticsearch functionality when network.host is not localhost. Jul 24, 2019
@manuasir manuasir changed the base branch from 3.9.3_7.2.0 to 3.9.4_7.2.0 July 24, 2019 13:19
@manuasir manuasir merged commit befe2b6 into 3.9.4_7.2.0 Jul 24, 2019
Wazuh 3.9.x automation moved this from To Review to Done Jul 24, 2019
@manuasir manuasir deleted the 3.9.3_7.2.0_issue_#184 branch July 24, 2019 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Wazuh 3.9.x
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants