Merge pull request #127 from singuliere/126-agent-registration

make agent registration delegate_to configurable
This commit is contained in:
Manuel J. Bernal 2020-05-12 21:51:55 +02:00 committed by GitHub
commit cb8f330da4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -39,6 +39,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_centos: 'centos, centos7, centos7.6' wazuh_profile_centos: 'centos, centos7, centos7.6'
wazuh_profile_ubuntu: 'ubuntu, ubuntu18, ubuntu18.04' wazuh_profile_ubuntu: 'ubuntu, ubuntu18, ubuntu18.04'
wazuh_auto_restart: 'yes' wazuh_auto_restart: 'yes'

View File

@ -123,15 +123,15 @@
user: "{{ wazuh_managers.0.api_user }}" user: "{{ wazuh_managers.0.api_user }}"
password: "{{ api_pass }}" password: "{{ api_pass }}"
register: newagent_api register: newagent_api
notify: restart wazuh-agent delegate_to: "{{ 'localhost' if not wazuh_api_reachable_from_agent else inventory_hostname }}"
# changed_when: newagent_api.json.error == 0 become: no
vars: changed_when: newagent_api.json.error == 0
agent_name: "{% if single_agent_name is defined %}{{ single_agent_name }}{% else %}{{ inventory_hostname }}{% endif %}"
when: when:
- not check_keys.stat.exists or check_keys.stat.size == 0 - check_keys.stat.exists == false or check_keys.stat.size == 0
- wazuh_agent_authd.registration_address is not none - wazuh_managers.0.address is not none
become: false tags:
ignore_errors: true - config
- api
- name: Linux | Retieve new agent data via rest-API - name: Linux | Retieve new agent data via rest-API
uri: uri:
@ -148,8 +148,11 @@
- wazuh_agent_authd.registration_address is not none - wazuh_agent_authd.registration_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: false become: no
tags:
- config
- api
- name: Linux | Register agent (via rest-API) - name: Linux | Register agent (via rest-API)
command: /var/ossec/bin/manage_agents command: /var/ossec/bin/manage_agents