fix typo and prevent agent from getting re-added

This commit is contained in:
Wes Lambert
2019-12-30 17:47:00 +00:00
parent ffc116085e
commit df722c173f
2 changed files with 8 additions and 2 deletions

View File

@@ -179,7 +179,7 @@
<log_format>syslog</log_format>
<location>/var/ossec/logs/active-responses.log</location>
</localfile>
%- if grains['os'] == 'Ubuntu' %}
{%- if grains['os'] == 'Ubuntu' %}
<localfile>
<log_format>syslog</log_format>
<location>/var/log/auth.log</location>

View File

@@ -31,6 +31,7 @@ USER="foo"
PASSWORD="bar"
AGENT_NAME=$(hostname)
AGENT_IP="{{ip}}"
AGENT_ID=001
display_help() {
cat <<HELP_USAGE
@@ -135,5 +136,10 @@ shift $(($OPTIND - 1))
# Default action -> try to register the agent
sleep 10s
register_agent
STATUS=$(curl -s -k -u $USER:$PASSWORD $PROTOCOL://$API_IP:$API_PORT/agents/$AGENT_ID | jq .data.status | sed s'/"//g')
if [[ $STATUS == "Active" ]]; then
echo "Agent $AGENT_ID already registered!"
else
register_agent
fi
#remove_agent