Skip to content

Commit bbaf7bb

Browse files
authored
Merge pull request #717 from stackhpc/wazuh-remote-commands-fix
Fix custom sca policies remote checks
2 parents 4261905 + a801224 commit bbaf7bb

File tree

5 files changed

+41
-14
lines changed

5 files changed

+41
-14
lines changed

etc/kayobe/ansible/wazuh-agent.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,35 @@
55
tasks:
66
- import_role:
77
name: "wazuh-ansible/wazuh-ansible/roles/wazuh/ansible-wazuh-agent"
8+
post_tasks:
9+
- name: Check if custom SCA policies directory exists
10+
stat:
11+
path: "{{ local_custom_sca_policies_path }}"
12+
register: custom_sca_policies_folder
13+
delegate_to: localhost
14+
15+
- name: Gather list of custom SCA policies
16+
find:
17+
paths: "{{ local_custom_sca_policies_path }}"
18+
patterns: '*.yml'
19+
delegate_to: localhost
20+
register: custom_sca_policies
21+
when: custom_sca_policies_folder.stat.exists
22+
23+
- name: Allow Wazuh agents to execute commands in SCA policies sent from the Wazuh manager
24+
become: yes
25+
blockinfile:
26+
path: "/var/ossec/etc/local_internal_options.conf"
27+
state: present
28+
owner: wazuh
29+
group: wazuh
30+
block: sca.remote_commands=1
31+
when: custom_sca_policies.files | length > 0
32+
notify:
33+
- Restart wazuh-agent
34+
35+
handlers:
36+
- name: Restart wazuh-agent
37+
service:
38+
name: wazuh-agent
39+
state: restarted

etc/kayobe/ansible/wazuh-manager.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,7 @@
3232
delegate_to: localhost
3333
register: custom_sca_policies
3434
when: custom_sca_policies_folder.stat.exists
35-
36-
- name: Allow Wazuh agents to execute commands in SCA policies sent from the Wazuh manager
37-
blockinfile:
38-
path: "/var/ossec/etc/local_internal_options.conf"
39-
state: present
40-
owner: wazuh
41-
group: wazuh
42-
block: |
43-
sca.remote_commands=1
44-
when: custom_sca_policies.files | length > 0
35+
become: no
4536

4637
- name: Copy custom SCA policy files to Wazuh manager
4738
copy:
@@ -112,7 +103,6 @@
112103
- name: Perform health check against filebeat
113104
command: filebeat test output
114105
changed_when: false
115-
become: true
116106
retries: 2
117107

118108
handlers:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
# Ansible custom SCA policies directory
3+
local_custom_sca_policies_path: "{{ kayobe_env_config_path }}/wazuh/custom_sca_policies"

etc/kayobe/inventory/group_vars/wazuh-manager/wazuh-manager

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ local_certs_path: "{{ playbook_dir }}/wazuh/certificates"
2424
# Ansible control host custom certificates directory
2525
local_custom_certs_path: "{{ playbook_dir }}/wazuh/custom_certificates"
2626

27-
# Ansible custom SCA policies directory
28-
local_custom_sca_policies_path: "{{ kayobe_env_config_path }}/wazuh/custom_sca_policies"
29-
3027
# Indexer variables
3128
indexer_node_name: "{{ inventory_hostname }}"
3229

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
When using custom SCA policies for Wazuh, the agents are now correctly
5+
configured to allow commands to be executed from the manager.

0 commit comments

Comments
 (0)