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

Elasticsearch module exec blocks running every puppet run #296

Closed
Llandros opened this issue Sep 16, 2020 · 1 comment · Fixed by #313
Closed

Elasticsearch module exec blocks running every puppet run #296

Llandros opened this issue Sep 16, 2020 · 1 comment · Fixed by #313
Assignees
Labels
community type/enhancement Enhacement or new feature

Comments

@Llandros
Copy link

In the wazuh::elasticsearch class there are two execs that run every puppet run.

Info: Applying configuration version '1600268992'
Notice: /Stage[main]/Wazuh::Elasticsearch/Exec[Insert line limits]/returns: executed successfully (corrective)
Notice: /Stage[main]/Wazuh::Elasticsearch/Exec[Verify Elasticsearch folders owner]/returns: executed successfully (corrective)

The insert line limit should only happen once.

exec { 'Insert line limits':
path => '/usr/bin:/bin/',
command => "echo 'elasticsearch - nofile 65535\nelasticsearch - memlock unlimited' >> /etc/security/limits.conf",
require => Package[$elasticsearch_package],
}

This causes the limits.conf file to have multiple entries for elasticsearch.

eg:

End of file

elasticsearch - nofile 65535
elasticsearch - memlock unlimited
elasticsearch - nofile 65535
elasticsearch - memlock unlimited
elasticsearch - nofile 65535
elasticsearch - memlock unlimited
elasticsearch - nofile 65535

The chown should only execute if the ownership changes from elasticsearch:elasticsearch

exec { 'Verify Elasticsearch folders owner':
path => '/usr/bin:/bin',
command => "chown elasticsearch:elasticsearch -R /etc/elasticsearch
&& chown elasticsearch:elasticsearch -R /usr/share/elasticsearch
&& chown elasticsearch:elasticsearch -R /var/lib/elasticsearch",
require => Package[$elasticsearch_package],
}

@Zenidd Zenidd self-assigned this Sep 17, 2020
@Zenidd
Copy link
Contributor

Zenidd commented Sep 17, 2020

Hello @Llandros,

Thanks for letting us know, we are working hard to make our puppet module completely idempotent and hints like these are really useful. Let me detail bellow the needed changes:

Insert line limits
The current insert line limit (exec - command) resource could be replaced with a file_line this resource should be enough to guarantee that the lines won't be written again if they already exist.

exec { 'Insert line limits':
path => '/usr/bin:/bin/',
command => "echo 'elasticsearch - nofile 65535\nelasticsearch - memlock unlimited' >> /etc/security/limits.conf",
require => Package[$elasticsearch_package],
}

Verify Elasticsearch folders owner
In this case we should be using a file resource instead of an exec to manage the attributes of the directories.

exec { 'Verify Elasticsearch folders owner':
path => '/usr/bin:/bin',
command => "chown elasticsearch:elasticsearch -R /etc/elasticsearch\
&& chown elasticsearch:elasticsearch -R /usr/share/elasticsearch\
&& chown elasticsearch:elasticsearch -R /var/lib/elasticsearch",
require => Package[$elasticsearch_package],
}

As soon as our workflow allows us we will address it. Thanks again for your contribution!

Greetings,

JP

@Zenidd Zenidd added community type/enhancement Enhacement or new feature labels Sep 18, 2020
@manuasir manuasir added this to the Sprint - 120 - DevOps milestone Nov 3, 2020
@neonmei neonmei linked a pull request Nov 30, 2020 that will close this issue
@neonmei neonmei self-assigned this Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community type/enhancement Enhacement or new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants