diff --git a/roles/wazuh/ansible-wazuh-agent/tasks/macOS.yml b/roles/wazuh/ansible-wazuh-agent/tasks/macOS.yml index 49fe677d..3988d126 100644 --- a/roles/wazuh/ansible-wazuh-agent/tasks/macOS.yml +++ b/roles/wazuh/ansible-wazuh-agent/tasks/macOS.yml @@ -206,6 +206,16 @@ - config - api +- name: macOS | Agent registration via auto-enrollment + debug: + msg: Agent registration will be performed through enrollment option in templated ossec.conf + when: wazuh_agent_config.enrollment.enabled == 'yes' + +- name: macOS | Ensure group "wazuh" exists + ansible.builtin.group: + name: wazuh + state: present + - name: macOS | Installing agent configuration (ossec.conf) template: src: var-ossec-etc-ossec-agent.conf.j2 @@ -230,6 +240,20 @@ - init - config +- name: Create auto-enrollment password file + template: + src: authd_pass.j2 + dest: "{{ wazuh_macos_config.install_dir }}/etc/authd.pass" + owner: wazuh + group: wazuh + mode: 0640 + when: + - wazuh_agent_config.enrollment.enabled == 'yes' + - wazuh_agent_config.enrollment.authorization_pass_path_macos | length > 0 + - authd_pass | length > 0 + tags: + - config + - name: macOS | Delete downloaded Wazuh agent installer file file: path: "{{ wazuh_macos_config.download_dir }}{{ wazuh_macos_package_name }}" diff --git a/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 b/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 index dd40b21e..1ae07862 100644 --- a/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 +++ b/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 @@ -67,8 +67,10 @@ {% if wazuh_agent_config.enrollment.agent_key_path | length > 0 %} {{ wazuh_agent_config.enrollment.agent_key_path }} {% endif %} - {% if wazuh_agent_config.enrollment.authorization_pass_path | length > 0 %} + {% if wazuh_agent_config.enrollment.authorization_pass_path | length > 0 and ansible_system != "Darwin" %} {{ wazuh_agent_config.enrollment.authorization_pass_path }} + {% else %} + {{ wazuh_agent_config.enrollment.authorization_pass_path_macos }} {% endif %} {% if wazuh_agent_config.enrollment.auto_method | length > 0 %} {{ wazuh_agent_config.enrollment.auto_method }}