make agent registration delegate_to configurable
Registering to the API requires the port 55000 of the wazuh manager is
open. Depending on the firewall policy, it may be true from the
ansible controller, reason why it was delegated to localhost in the
original implementation at 6cb6d3bda8
The role should be more flexible and allow for the API call to be made
from the ansible controller or the host.
Implementation note: although it would be more elegant to use omit
instead of inventory_hostname, it is not possible because of an
ansible bug at this time https://github.com/ansible/ansible/issues/26009
Fixes: https://github.com/wazuh/wazuh-ansible/issues/126
Signed-off-by: singuliere <singuliere@autistici.org>
This commit is contained in:
parent
9327f052de
commit
7cce8e9490
@ -6,6 +6,7 @@ wazuh_managers:
|
|||||||
api_port: 55000
|
api_port: 55000
|
||||||
api_proto: 'http'
|
api_proto: 'http'
|
||||||
api_user: null
|
api_user: null
|
||||||
|
wazuh_api_reachable_from_agent: false
|
||||||
wazuh_profile: null
|
wazuh_profile: null
|
||||||
wazuh_auto_restart: 'yes'
|
wazuh_auto_restart: 'yes'
|
||||||
wazuh_agent_authd:
|
wazuh_agent_authd:
|
||||||
|
|||||||
@ -95,11 +95,12 @@
|
|||||||
user: "{{ wazuh_managers.0.api_user }}"
|
user: "{{ wazuh_managers.0.api_user }}"
|
||||||
password: "{{ api_pass }}"
|
password: "{{ api_pass }}"
|
||||||
register: newagent_api
|
register: newagent_api
|
||||||
|
delegate_to: "{{ 'localhost' if not wazuh_api_reachable_from_agent else inventory_hostname }}"
|
||||||
|
become: no
|
||||||
changed_when: newagent_api.json.error == 0
|
changed_when: newagent_api.json.error == 0
|
||||||
when:
|
when:
|
||||||
- check_keys.stat.exists == false or check_keys.stat.size == 0
|
- check_keys.stat.exists == false or check_keys.stat.size == 0
|
||||||
- wazuh_managers.0.address is not none
|
- wazuh_managers.0.address is not none
|
||||||
become: no
|
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
- api
|
- api
|
||||||
@ -117,7 +118,7 @@
|
|||||||
- wazuh_managers.0.address is not none
|
- wazuh_managers.0.address is not none
|
||||||
- newagent_api.json.error == 0
|
- newagent_api.json.error == 0
|
||||||
register: newagentdata_api
|
register: newagentdata_api
|
||||||
delegate_to: localhost
|
delegate_to: "{{ 'localhost' if not wazuh_api_reachable_from_agent else inventory_hostname }}"
|
||||||
become: no
|
become: no
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user