-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusion surrounding how to register agents #502
Comments
Hi @dragospe, first of all, thank you for taking the time to write such a nice described issue.
Sure, let me explain the differences between the current and the previous playbook structure and variables: wazuh-agent role and agents registration in Wazuh 3.x
vars:
wazuh_managers:
- address: <your manager IP>
port: 1514
protocol: udp
api_port: 55000
api_proto: 'http'
api_user: ansible
max_retries: 5
retry_interval: 5
wazuh_agent_authd:
registration_address: <registration IP>
enable: true
port: 1515
ssl_agent_ca: null
ssl_auto_negotiate: 'no'
wazuh-agent role and agents registration in Wazuh 4.x
- hosts: <your wazuh agents hosts>
roles:
- ../roles/wazuh/ansible-wazuh-agent
vars:
wazuh_managers:
- address: <your manager IP>
port: 1514
protocol: tcp
api_port: 55000
api_proto: 'http'
api_user: ansible
max_retries: 5
retry_interval: 5 OK, but the current wazuh-agent playbook is not working
Setting enrollment to another issue on agents registrationsAfter checking that enrollment works I disabled it and tried the agent-auth method. It threw an error related to the registration verification. After some tests, I realized that the output for OLD agent-auth logs:
Current agent-auth logs:
Seems like we should review the examples on https://documentation.wazuh.com/4.0/deploying-with-ansible/roles/wazuh-agent.html. Also your edit on wazuh/wazuh-documentation#3138 seems ok to me, thanks ! I hope it helps. Greetings, JP |
Thanks for your help JP! Unfortunately, this doesn't seem to help. As far as I can tell, there are two blocks in First block (registering via authd)The first, starting here registers via authd, but the conditional clause here only executes when
so the suggested change of setting Second block (registering via rest API)The second block pertaining to registration starts here. The conditions (starting here) are again
so setting So on my system, while making the change to Are you seeing differently on your end? Many thanks, again! |
Hello again @dragospe,
Let's sort it out! When enabling enrollment, both the first block (registering via authd) and the second block (registering via rest API) should be omitted. The registration is done automatically through the agent's internal enrollment feature. That's why both blocks include the statement checking for the enrollment options to be disabled - not wazuh_agent_config.enrollment.enabled | length > 0 or wazuh_agent_config.enrollment.enabled == 'no'
I think whether the playbook ended without errors the agents should have been registered by the enrollment feature. I just tried deploying some agents into my lab environment using Could you try deploying the agent again using enrollment and, in case the agents keep failing to register, check the agent cat /var/ossec/logs/ossec.log | grep "Requesting a key from server"
cat /var/ossec/logs/ossec.log | grep "INFO: Trying to connect to server"
cat /var/ossec/logs/ossec.log | grep server
cat /var/ossec/logs/ossec.log | grep ERROR **The PR here enables enrollment by default. It also fixes other issues on registration tasks. Let me know if it helps. Greetings, JP |
Hi JP! Thanks again for your response. I hadn't realized that there was a third way to register an agent, leading to some of my confusion! I'm new to Wazuh, so this is probably an oversight on my part. Checking the logs on the agent revealed a misconfigured manager IP address in my playbooks -- I hadn't thought to check agent logs, since I wasn't seeing any registration-related tasks being executed! Fixing this IP makes everything go smoothly, as long as I specify each I'm looking through the docs, and it appears to be sparse on what this automatic enrollment process actually entails -- both from the ansible deployment side and from the technical side. Since the feature is relatively new, I'm assuming this is in the works -- I'd love to contribute to the write up if I have the time! |
I am having some difficulty understanding how to register agents using the
ansible-wazuh-agent
role. I managed to work around the problem (and subsequently forgot what I did to do so), but I'd like to understand what the original intention was, and hopefully add these to the documentation.There's a good chance I'm just misunderstanding something fundamental, but I would appreciate it if someone could help troubleshoot and subsequently review my edits to the docs.
I modified the example playbook to my environment:
but running this gives me
Putting in a debug statement before that task shows:
Which makes sense, because the following task only checks when
wazuh_agent_config.enrollment.enabled == 'yes'
:This variable doesn't seem to be listed in the variables reference, but I tried setting it to yes in the playbook anyways. The playbook runs through without error, but no agents are registered.
Taking a look at
roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml
, we see that the block "Linux | Agent registration via authd" only runs when:and the block "Linux | Agent registration via rest-API" only runs when
Which leads me to wonder what the variable
wazuh_agent_config.enrollment.enabled
actually means. Is it:1.) A variable indicating that the agent is already enabled, which is why it skips registration?
2.) A variable indicating that the agents should be enabled?
Either way, I'm confused about what set of options was intended by the developer.
The text was updated successfully, but these errors were encountered: