--- # tasks file for ossec-agent - name: "Install the correct repository" include: "RedHat.yml" when: ansible_os_family == "RedHat" - name: Install the correct repository include: "Debian.yml" when: ansible_os_family == "Debian" - name: "Check if client.keys exists" stat: path=/var/ossec/etc/client.keys register: check_keys tags: - config - name: "Register client" shell: /var/ossec/bin/agent-auth -m {{ ossec_server_ip }} -p 1515 when: ossec_server_ip and check_keys.stat.size == 0 tags: - config - name: "Installing the ossec.conf" template: src=var-ossec-etc-ossec-agent.conf.j2 dest=/var/ossec/etc/ossec.conf owner=root group=root mode=0644 notify: restart wazuh-agent tags: - init - config - name: Ensure Wazuh Manager service is started and enabled service: name: "{{ item }}" enabled: yes state: started with_items: - wazuh-agent