Skip to content

Commit f49a774

Browse files
committed
Fix custom sca policies remote checks
The config option to allow for remote commands needs to be set on the agents, not the manager. This fixes many benchmarks being makred as not applicable.
1 parent cea3108 commit f49a774

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

etc/kayobe/ansible/wazuh-manager.yml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@
3333
register: custom_sca_policies
3434
when: custom_sca_policies_folder.stat.exists
3535

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
45-
4636
- name: Copy custom SCA policy files to Wazuh manager
4737
copy:
4838
# Note the trailing slash to copy directory contents
@@ -125,3 +115,40 @@
125115
service:
126116
name: wazuh-dashboard
127117
state: restarted
118+
119+
- hosts: wazuh-agent
120+
become: yes
121+
become_user: root
122+
tasks:
123+
- name: Check if custom SCA policies directory exists
124+
stat:
125+
path: "{{ local_custom_sca_policies_path }}"
126+
register: custom_sca_policies_folder
127+
delegate_to: localhost
128+
become: no
129+
130+
- name: Gather list of custom SCA policies
131+
find:
132+
paths: "{{ local_custom_sca_policies_path }}"
133+
patterns: '*.yml'
134+
delegate_to: localhost
135+
register: custom_sca_policies
136+
when: custom_sca_policies_folder.stat.exists
137+
138+
- name: Allow Wazuh agents to execute commands in SCA policies sent from the Wazuh manager
139+
blockinfile:
140+
path: "/var/ossec/etc/local_internal_options.conf"
141+
state: present
142+
owner: wazuh
143+
group: wazuh
144+
block: |
145+
sca.remote_commands=1
146+
when: custom_sca_policies.files | length > 0
147+
notify:
148+
- Restart wazuh-agent
149+
150+
handlers:
151+
- name: Restart wazuh-agent
152+
service:
153+
name: wazuh-agent
154+
state: restarted
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

0 commit comments

Comments
 (0)