Use the authd service only when the agent is not registered.

This commit is contained in:
Miguelangel Freitas 2017-08-21 17:32:25 -04:00
parent f072a35f26
commit 7dce48315b
3 changed files with 22 additions and 8 deletions

View File

@ -1,7 +1,8 @@
--- ---
wazuh_manager_ip: 127.0.0.1 wazuh_manager_ip: null
wazuh_authd_port: 1515
wazuh_profile: null wazuh_profile: null
wazuh_manager_proto: udp wazuh_manager_proto: tcp
wazuh_register_client: false wazuh_register_client: false
wazuh_notify_time: null wazuh_notify_time: null
wazuh_time_reconnect: null wazuh_time_reconnect: null

View File

@ -10,20 +10,29 @@
tags: tags:
- init - init
- name: "Register agent" - name: Check if client.keys exists
shell: /var/ossec/bin/agent-auth -m {{ wazuh_manager_ip }} -p {{ wazuh_authd_port }} stat: path=/var/ossec/etc/client.keys
register: agent_auth_output register: check_keys
when: wazuh_register_client == true
tags: tags:
- config - config
- name: "Verify agent registration" - name: Register agent
shell: /var/ossec/bin/agent-auth -m {{ wazuh_manager_ip }} -p {{ wazuh_authd_port }}
register: agent_auth_output
when:
- wazuh_register_client == true
- check_keys.stat.size == 0
- wazuh_manager_ip is not none
tags:
- config
- name: Verify agent registration
shell: echo {{ agent_auth_output }} | grep "Valid key created" shell: echo {{ agent_auth_output }} | grep "Valid key created"
when: wazuh_register_client == true when: wazuh_register_client == true
tags: tags:
- config - config
- name: "Installing agent configuration (ossec.conf)" - name: Installing agent configuration (ossec.conf)
template: src=var-ossec-etc-ossec-agent.conf.j2 template: src=var-ossec-etc-ossec-agent.conf.j2
dest=/var/ossec/etc/ossec.conf dest=/var/ossec/etc/ossec.conf
owner=root owner=root

View File

@ -7,7 +7,11 @@
<ossec_config> <ossec_config>
<client> <client>
{% if wazuh_manager_ip is not none %}
<server-ip>{{ wazuh_manager_ip }}</server-ip> <server-ip>{{ wazuh_manager_ip }}</server-ip>
{% else %}
<server-ip>SERVER-IP</server-ip>
{% endif %}
{% if wazuh_profile is not none %} {% if wazuh_profile is not none %}
<config-profile>{{ wazuh_profile }}</config-profile> <config-profile>{{ wazuh_profile }}</config-profile>
{% endif %} {% endif %}