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

Incorrect Exit Statuses #107

Closed
paulcalabro opened this issue Dec 14, 2018 · 6 comments
Closed

Incorrect Exit Statuses #107

paulcalabro opened this issue Dec 14, 2018 · 6 comments

Comments

@paulcalabro
Copy link
Contributor

paulcalabro commented Dec 14, 2018

A new installation of the ansible-wazuh-manager role does not, by default, enable the following daemons:

  • ossec-maild
  • wazuh-clusterd

As a result, service wazuh-manager status returns an exit code of 1, which is customarily reserved for failures.

This behavior is caused by the following code, found in /var/ossec/bin/ossec-control :

DAEMONS="wazuh-modulesd ossec-monitord ossec-logcollector ossec-remoted ossec-syscheckd ossec-analysisd ossec-maild ossec-execd wazuh-db ${DB_DAEMON} ${CSYSLOG_DAEMON} ${AGENTLESS_DAEMON} ${INTEGRATOR_DAEMON} ${AUTH_DAEMON

...

if ! is_rhel_le_5
then
    DAEMONS="wazuh-clusterd $DAEMONS"
fi

...

    for i in ${DAEMONS}; do
        if [ $USE_JSON = true ] && [ $first = false ]; then
            echo -n ','
        else
            first=false
        fi
        pstatus ${i};
        if [ $? = 0 ]; then
            if [ $USE_JSON = true ]; then
                echo -n '{"daemon":"'${i}'","status":"stopped"}'
            else
                echo "${i} not running..."
            fi
            RETVAL=1
        else
            if [ $USE_JSON = true ]; then
                echo -n '{"daemon":"'${i}'","status":"running"}'
            else
                echo "${i} is running..."
            fi
        fi
    done

Given that a user might not want clustering nor email email notifications, having those services not enabled is not necessarily indicative of a failure. Having a return code of 1 causes misreporting of playbook executions.

A better test might be: checking the configuration to see if they are configured to be enabled, but are not able to start successfully.

Or, less ideally IMO, configuring a one node cluster with email support by default.

@paulcalabro
Copy link
Contributor Author

Some additional debug information:

# bash -x /var/ossec/bin/ossec-control status 2>&1 | egrep -i 'echo.*running|retval' 

+ RETVAL=0
+ echo 'wazuh-clusterd not running...'
+ RETVAL=1
+ echo 'wazuh-modulesd is running...'
+ echo 'ossec-monitord is running...'
+ echo 'ossec-logcollector is running...'
+ echo 'ossec-remoted is running...'
+ echo 'ossec-syscheckd is running...'
+ echo 'ossec-analysisd is running...'
+ echo 'ossec-maild not running...'
+ RETVAL=1
+ echo 'ossec-execd is running...'
+ echo 'wazuh-db is running...'
+ echo 'ossec-authd is running...'

@paulcalabro
Copy link
Contributor Author

Now that I look at the other Wazuh project, it looks like this should be working based on this code:

https://github.com/wazuh/wazuh/blob/af6c7fcde4c169966d4b81d4c4d845d6f5388e4f/src/init/ossec-server.sh#L305

...digging further.

@paulcalabro
Copy link
Contributor Author

paulcalabro commented Dec 14, 2018

I think this is actually an error in the other project. I've opened a PR there that should resolve the issue:

wazuh/wazuh#2103

@dj-wasabi
Copy link

I encounter this issue while making the Ansible roles idempotent. The molecule test command will fail on this task, but I can disable the idempotence check for now until this is resolved/merged.

@manuasir manuasir added the bug label Apr 16, 2019
@jm404 jm404 added community and removed bug labels Mar 30, 2020
@jm404
Copy link
Contributor

jm404 commented Mar 31, 2020

Hi @paulcalabro , @dj-wasabi,

I'm moving this issue to wazuh/wazuh as it's related with the binaries and not with Ansible directly.

Best regards,

Jose

@jm404
Copy link
Contributor

jm404 commented Mar 31, 2020

Issue moved to wazuh/wazuh #4811 via ZenHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants