-
Notifications
You must be signed in to change notification settings - Fork 138
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
param agent: use systemd for supported debian/ubuntu distro #176
base: devel
Are you sure you want to change the base?
Conversation
it's already defined before, and we can't assigne twice the same variables
debian >= jessie ubuntu >= xenial
Hi @aderumier Thank you for contributing to Wazuh! Before I test your changes, I tested the changes you made in your branch aderumier/wazuh-puppet/tree/fix-agent-reload on Ubuntu/Xenial OS and it works as expected without any errors. DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS" Looking at your changes and especially, at this commit fdf4569 I have the following notes.
wazuh-puppet/manifests/params_agent.pp Lines 183 to 186 in 042ea69
And for Ubuntu/Xenial OS we then specify no value for the mentioned variables so they still have the default values defined before. But this will not prevent the task where a reload of the service concat { 'ossec.conf':
path => $wazuh::params_agent::config_file,
owner => $wazuh::params_agent::config_owner,
group => $wazuh::params_agent::config_group,
mode => $wazuh::params_agent::config_mode,
require => Package[$agent_package_name],
notify => Service[$agent_service_name],
}
When running $service_has_status = false
$ossec_service_provider = undef I suppose puppet will search for To really get to know more details about your issue which makes it necessary to have such changes, could you please paste the error message you're getting with puppet, this way I'll be guided better. Waiting for your reply. Kr, Rshad Zhran |
Hi, if you have "$service_has_status = false" , puppet can't reload the service on notify. just run puppet agent in debug mode, you'll see an extra log that it skipping it, even if it's display in standard ouput that service is reloaded. something like "Skipping restart; service is not running" https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type/service.rb def refresh |
Hi @aderumier! Happy new year! I re-tested the installation with DEBUG mode and got the following log lines corresponding to the task: concat { 'ossec.conf':
path => $wazuh::params_agent::config_file,
owner => $wazuh::params_agent::config_owner,
group => $wazuh::params_agent::config_group,
mode => $wazuh::params_agent::config_mode,
require => Package[$agent_package_name],
notify => Service[$agent_service_name],
} Log Output Debug: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/Concat_file[ossec.conf]/before: before to File[/var/ossec/etc/ossec.conf]
Debug: /Stage[main]/Apt/Apt::Setting[conf-update-stamp]/File[/etc/apt/apt.conf.d/15update-stamp]/notify: notify to Class[Apt::Update]
Debug: /Stage[main]/Wazuh::Repo/Apt::Source[wazuh]/Apt::Setting[list-wazuh]/File[/etc/apt/sources.list.d/wazuh.list]/notify: notify to Class[Apt::Update]
Debug: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/Concat_file[ossec.conf]: Skipping automatic relationship with File[/var/ossec/etc/ossec.conf] Also if we look over the log output related to the task: exec { 'agent-auth-linux':
command => $agent_auth_command,
unless => "/bin/egrep -q '.' ${::wazuh::params_agent::keys_file}",
require => Concat['ossec.conf'],
before => Service[$agent_service_name],
} Debug: Exec[agent-auth-without-pwd](provider=posix): Executing '/var/ossec/bin/agent-auth -m 172.17.0.3 '
Debug: Executing: '/var/ossec/bin/agent-auth -m 172.17.0.3 '
Notice: /Stage[main]/Wazuh::Agent/Exec[agent-auth-without-pwd]/returns: executed successfully
Debug: /Stage[main]/Wazuh::Agent/Exec[agent-auth-without-pwd]: The container Class[Wazuh::Agent] will propagate my refresh event
Debug: Service[wazuh-agent](provider=upstart): Could not find wazuh-agent.conf in /etc/init
Debug: Service[wazuh-agent](provider=upstart): Could not find wazuh-agent.conf in /etc/init.d
Debug: Service[wazuh-agent](provider=upstart): Could not find wazuh-agent in /etc/init
Debug: Service[wazuh-agent](provider=upstart): Executing 'ps -ef'
Debug: Executing: 'ps -ef'
Debug: Executing: '/etc/init.d/wazuh-agent start'
Notice: /Stage[main]/Wazuh::Agent/Service[wazuh-agent]/ensure: ensure changed 'stopped' to 'running' Note that in response to the service { $agent_service_name:
ensure => $agent_service_ensure
.
. ... Response Debug: Executing: '/etc/init.d/wazuh-agent start' I'm not getting any error or Waiting for your reply. Kind regards, Rshad |
Hi, sorry to be late, I'll test it again. |
something else related: on each puppet run, I have: Notice: /Stage[main]/Wazuh::Agent/Service[wazuh-agent]/ensure: ensure changed 'stopped' to 'running' (corrective) This is because of default ensure=>running, but status of the service can't be checked with init.d script. (don't have tested with upstart) now about the bug itself, a simple test:
service restart is skipped, because puppet can't see if the service is running or not. (because init.d status is not working).
Also this is strange:
not sure, but because we don't have hasstatus on service, I think puppet try to fallback looking at "wazuh-agent" process. But this is not exist (because with have multiple ossec process). |
Looking at your log
I think what you see the the agent stopped->running , that you can have at each run, because puppet is enable to find the status with "ps -ef" maybe check your ossec process uptime, but I'm pretty sure they are not restarted. |
Note that , $service_has_status = true fix it (without need to change to provider systemd) init.d script have status() {
|
Hi, any news about this ? |
Hey @aderumier , Our apologies for the late review, we will take this back ASAP and will let you know about anything. Please stay tuned to this thread and thanks again for contributing here. Cheers |
Hi @aderumier ! Sorry for the late update. I'll review your updates and I'll be back with an analysis. Kr, Rshad |
Hi @aderumier ! Testing with:
Thank you for the analysis. Actually I could not reproduce the case when the Running After adding a new path to the directories monitored by
<directories check_all="yes" >/etc,/usr/bin,/usr/sbin,/root/test/</directories> Notice: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]/content:
--- /var/ossec/etc/ossec.conf 2020-03-25 14:24:37.814079928 +0000
+++ /tmp/puppet-file20200325-26470-1yjsjtk 2020-03-25 14:25:15.733029928 +0000
@@ -85,7 +85,7 @@
<frequency>43200</frequency>
<scan_on_start>yes</scan_on_start>
- <directories check_all="yes" >/etc,/usr/bin,/usr/sbin,/root/test/</directories>
+ <directories check_all="yes" >/etc,/usr/bin,/usr/sbin</directories>
<directories check_all="yes" >/bin,/sbin,/boot</directories>
<ignore>/etc/mtab</ignore>
<ignore>/etc/hosts.deny</ignore>
@@ -164,4 +164,4 @@
</active-response>
-</ossec_config>
+</ossec_config>
\ No newline at end of file
Info: Computing checksum on file /var/ossec/etc/ossec.conf
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Info: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: Filebucketed /var/ossec/etc/ossec.conf to puppet with sum 4593763bcc5439a7ed8539e8554f3b47
Debug: Executing: 'diff -u /var/ossec/etc/ossec.conf /tmp/puppet-file20200325-26470-98aptl'
Notice: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]/content:
Notice: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]/content: content changed '{md5}4593763bcc5439a7ed8539e8554f3b47' to '{md5}a5598a92b34f131dc0cb64dd3bb94054'
Debug: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: The container Concat[ossec.conf] will propagate my refresh event
Debug: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: The container ossec.conf will propagate my refresh event
Debug: ossec.conf: The container Concat[ossec.conf] will propagate my refresh event
Debug: Concat[ossec.conf]: The container Class[Wazuh::Agent] will propagate my refresh event
Info: Concat[ossec.conf]: Scheduling refresh of Service[wazuh-agent]
Debug: Exec[agent-auth-linux](provider=posix): Executing check '/bin/egrep -q '.' /var/ossec/etc/client.keys'
Debug: Executing: '/bin/egrep -q '.' /var/ossec/etc/client.keys'
Debug: Executing: '/bin/systemctl is-active wazuh-agent'
Debug: Executing: '/bin/systemctl is-enabled wazuh-agent'
Debug: Executing: '/bin/systemctl is-active wazuh-agent'
Debug: Executing: '/bin/systemctl restart wazuh-agent'
Notice: /Stage[main]/Wazuh::Agent/Service[wazuh-agent]: Triggered 'refresh' from 1 events
Debug: /Stage[main]/Wazuh::Agent/Service[wazuh-agent]: The container Class[Wazuh::Agent] will propagate my refresh event
Debug: Class[Wazuh::Agent]: The container Stage[main] will propagate my refresh event
Debug: Finishing transaction 17098800
Debug: Storing state
Debug: Stored state in 0.02 seconds
Notice: Applied catalog in 6.09 seconds
Debug: Executing: 'diff -u /var/ossec/etc/ossec.conf /tmp/puppet-file20200325-28257-h9cb1i'
Notice: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]/content:
--- /var/ossec/etc/ossec.conf 2020-03-25 14:52:47.445046131 +0000
+++ /tmp/puppet-file20200325-28257-h9cb1i 2020-03-25 14:53:15.297046131 +0000
@@ -1,6 +1,6 @@
<ossec_config>
<client>
- s<server>
+ <server>
<address>172.17.0.101</address>
<protocol>udp</protocol>
<port>1514</port>
@@ -164,4 +164,4 @@
</active-response>
-</ossec_config>
+</ossec_config>
\ No newline at end of file
Info: Computing checksum on file /var/ossec/etc/ossec.conf
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Info: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: Filebucketed /var/ossec/etc/ossec.conf to puppet w ith sum 3720a938e42cbbb37322a03009638bad
Debug: Executing: 'diff -u /var/ossec/etc/ossec.conf /tmp/puppet-file20200325-28257-u1o7h6'
Notice: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]/content:
Notice: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]/content: content changed '{md5}3720a938e42cbbb373 22a03009638bad' to '{md5}1b2d40e5dea4f08ed62aef27891c50e7'
Debug: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: The container Concat[ossec.conf] will propagate m y refresh event
Debug: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: The container ossec.conf will propagate my refres h event
Debug: ossec.conf: The container Concat[ossec.conf] will propagate my refresh event
Debug: Concat[ossec.conf]: The container Class[Wazuh::Agent] will propagate my refresh event
Info: Concat[ossec.conf]: Scheduling refresh of Service[wazuh-agent]
Debug: Exec[agent-auth-linux](provider=posix): Executing check '/bin/egrep -q '.' /var/ossec/etc/client.keys'
Debug: Executing: '/bin/egrep -q '.' /var/ossec/etc/client.keys'
Debug: Executing: '/bin/systemctl is-active wazuh-agent'
Debug: Executing: '/bin/systemctl is-enabled wazuh-agent'
Debug: Executing: '/bin/systemctl is-active wazuh-agent'
Debug: Executing: '/bin/systemctl restart wazuh-agent'
Notice: /Stage[main]/Wazuh::Agent/Service[wazuh-agent]: Triggered 'refresh' from 1 events
Debug: /Stage[main]/Wazuh::Agent/Service[wazuh-agent]: The container Class[Wazuh::Agent] will propagate my refresh event
Debug: Class[Wazuh::Agent]: The container Stage[main] will propagate my refresh event
Debug: Finishing transaction 36848560
Debug: Storing state
Debug: Stored state in 0.02 seconds
Notice: Applied catalog in 6.99 seconds Running After modifying
$ossec_syscheck_directories_1 = '/etc,/usr/bin,/usr/sbin'
$ossec_syscheck_directories_1 = '/etc,/usr/bin,/usr/sbin, /root/test/' Debug: Executing: 'diff -u /var/ossec/etc/ossec.conf /tmp/puppet-file20200325-27371-1tjsc42'
Notice: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]/content:
--- /var/ossec/etc/ossec.conf 2020-03-25 14:25:15.857091929 +0000
+++ /tmp/puppet-file20200325-27371-1tjsc42 2020-03-25 14:38:55.529046131 +0000
@@ -85,7 +85,7 @@
<frequency>43200</frequency>
<scan_on_start>yes</scan_on_start>
- <directories check_all="yes" >/etc,/usr/bin,/usr/sbin</directories>
+ <directories check_all="yes" >/etc,/usr/bin,/usr/sbin,/root/test/</directories>
<directories check_all="yes" >/bin,/sbin,/boot</directories>
<ignore>/etc/mtab</ignore>
<ignore>/etc/hosts.deny</ignore>
Info: Computing checksum on file /var/ossec/etc/ossec.conf
Debug: Evicting cache entry for environment 'production'
Debug: Caching environment 'production' (ttl = 0 sec)
Info: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: Filebucketed /var/ossec/etc/ossec.conf to puppet with sum a5598a92b34f131dc0cb64dd3bb94054
Notice: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]/content: content changed '{md5}a5598a92b34f131dc0cb64dd3bb94054' to '{md5}1b2d40e5dea4f08ed62aef27891c50e7'
Debug: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: The container Concat[ossec.conf] will propagate my refresh event
Debug: /Stage[main]/Wazuh::Agent/Concat[ossec.conf]/File[/var/ossec/etc/ossec.conf]: The container ossec.conf will propagate my refresh event
Debug: ossec.conf: The container Concat[ossec.conf] will propagate my refresh event
Debug: Concat[ossec.conf]: The container Class[Wazuh::Agent] will propagate my refresh event
Info: Concat[ossec.conf]: Scheduling refresh of Service[wazuh-agent]
Debug: Exec[agent-auth-linux](provider=posix): Executing check '/bin/egrep -q '.' /var/ossec/etc/client.keys'
Debug: Executing: '/bin/egrep -q '.' /var/ossec/etc/client.keys'
Debug: Executing: '/bin/systemctl is-active wazuh-agent'
Debug: Executing: '/bin/systemctl is-enabled wazuh-agent'
Debug: Executing: '/bin/systemctl is-active wazuh-agent'
Debug: Executing: '/bin/systemctl restart wazuh-agent'
Notice: /Stage[main]/Wazuh::Agent/Service[wazuh-agent]: Triggered 'refresh' from 1 events
Debug: /Stage[main]/Wazuh::Agent/Service[wazuh-agent]: The container Class[Wazuh::Agent] will propagate my refresh event
Debug: Class[Wazuh::Agent]: The container Stage[main] will propagate my refresh event
Debug: Finishing transaction 36650120
Debug: Storing state
Debug: Stored state in 0.02 seconds
Notice: Applied catalog in 6.73 seconds
As you can see, the changes are added and Please take into account, that with the module of Waiting for your reply, Kr, Rshad |
Hi @aderumier, Changing the base of the PR generated some conflicts, please have a look at them. Best regards, Jose |
We've actually run into this on new machines (Debian Buster), as well. Setting the |
Fixed conflicts, I will test it and update with the results. Best regards, Jose |
currently we can't restart wazuh-agent service on configuration change because no service provider is defined