60 lines
1.4 KiB
YAML
60 lines
1.4 KiB
YAML
---
|
|
- include: "RedHat.yml"
|
|
when: ansible_os_family == "RedHat"
|
|
|
|
- include: "Debian.yml"
|
|
when: ansible_os_family == "Debian"
|
|
|
|
- name: Linux | Install wazuh-agent
|
|
package: name=wazuh-agent state=latest
|
|
tags:
|
|
- init
|
|
|
|
- name: Linux | Check if client.keys exists
|
|
stat: path=/var/ossec/etc/client.keys
|
|
register: check_keys
|
|
tags:
|
|
- config
|
|
|
|
- name: Linux | 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: Linux | Verify agent registration
|
|
shell: echo {{ agent_auth_output }} | grep "Valid key created"
|
|
when:
|
|
- wazuh_register_client == true
|
|
- check_keys.stat.size == 0
|
|
- wazuh_manager_ip is not none
|
|
tags:
|
|
- config
|
|
|
|
- name: Linux | Installing agent configuration (ossec.conf)
|
|
template: src=var-ossec-etc-ossec-agent.conf.j2
|
|
dest=/var/ossec/etc/ossec.conf
|
|
owner=root
|
|
group=ossec
|
|
mode=0644
|
|
notify: restart wazuh-agent
|
|
tags:
|
|
- init
|
|
- config
|
|
|
|
- name: Linux | Ensure Wazuh Agent service is started and enabled
|
|
service:
|
|
name: wazuh-agent
|
|
enabled: yes
|
|
state: started
|
|
|
|
- include: "RMRedHat.yml"
|
|
when: ansible_os_family == "RedHat"
|
|
|
|
- include: "RMDebian.yml"
|
|
when: ansible_os_family == "Debian"
|