diff --git a/CHANGELOG.md b/CHANGELOG.md index 482fda2b..fd10dbeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. ### Added -- Adapt ossec.conf file for windows agents ([#118](https://github.com/wazuh/wazuh-ansible/pull/118)) +- Added custom name for single agent registration ([#117](https://github.com/wazuh/wazuh-ansible/pull/117)) ### Changed diff --git a/VERSION b/VERSION index 9cbf6d67..cdede417 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ WAZUH-ANSIBLE_VERSION="v3.7.2" -REVISION="3714" +REVISION="3715" diff --git a/roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml b/roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml index 2d17fb16..8cd5eaea 100644 --- a/roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml +++ b/roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml @@ -45,6 +45,7 @@ - name: Linux | Register agent (via authd) shell: > /var/ossec/bin/agent-auth + -A {{ agent_name }} -m {{ wazuh_managers.0.address }} -p {{ wazuh_agent_authd.port }} {% if authd_pass is defined %}-P {{ authd_pass }}{% endif %} @@ -55,6 +56,8 @@ {% endif %} {% if wazuh_agent_authd.ssl_auto_negotiate == 'yes' %}-a{% endif %} register: agent_auth_output + vars: + agent_name: "{% if single_agent_name is defined %}{{ single_agent_name }}{% else %}{{ ansible_hostname }}{% endif %}" when: - check_keys.stat.exists == false or check_keys.stat.size == 0 - wazuh_managers.0.address is not none @@ -87,7 +90,7 @@ url: "{{ wazuh_managers.0.api_proto }}://{{ wazuh_managers.0.address }}:{{ wazuh_managers.0.api_port }}/agents/" validate_certs: no method: POST - body: {"name":"{{ inventory_hostname }}"} + body: {"name":"{{ agent_name }}"} body_format: json status_code: 200 headers: @@ -96,6 +99,8 @@ password: "{{ api_pass }}" register: newagent_api changed_when: newagent_api.json.error == 0 + vars: + agent_name: "{% if single_agent_name is defined %}{{ single_agent_name }}{% else %}{{ inventory_hostname }}{% endif %}" when: - check_keys.stat.exists == false or check_keys.stat.size == 0 - wazuh_managers.0.address is not none