Skip to content
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

Fix custom sca policies remote checks #717

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions etc/kayobe/ansible/wazuh-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@
register: custom_sca_policies
when: custom_sca_policies_folder.stat.exists

- name: Allow Wazuh agents to execute commands in SCA policies sent from the Wazuh manager
blockinfile:
path: "/var/ossec/etc/local_internal_options.conf"
state: present
owner: wazuh
group: wazuh
block: |
sca.remote_commands=1
when: custom_sca_policies.files | length > 0

- name: Copy custom SCA policy files to Wazuh manager
copy:
# Note the trailing slash to copy directory contents
Expand Down Expand Up @@ -125,3 +115,40 @@
service:
name: wazuh-dashboard
state: restarted

- hosts: wazuh-agent
MoteHue marked this conversation as resolved.
Show resolved Hide resolved
become: yes
become_user: root
tasks:
- name: Check if custom SCA policies directory exists
stat:
path: "{{ local_custom_sca_policies_path }}"
register: custom_sca_policies_folder
delegate_to: localhost
become: no
MoteHue marked this conversation as resolved.
Show resolved Hide resolved

- name: Gather list of custom SCA policies
MoteHue marked this conversation as resolved.
Show resolved Hide resolved
find:
paths: "{{ local_custom_sca_policies_path }}"
patterns: '*.yml'
delegate_to: localhost
register: custom_sca_policies
when: custom_sca_policies_folder.stat.exists

- name: Allow Wazuh agents to execute commands in SCA policies sent from the Wazuh manager
blockinfile:
path: "/var/ossec/etc/local_internal_options.conf"
state: present
owner: wazuh
group: wazuh
block: |
MoteHue marked this conversation as resolved.
Show resolved Hide resolved
sca.remote_commands=1
when: custom_sca_policies.files | length > 0
notify:
- Restart wazuh-agent

handlers:
- name: Restart wazuh-agent
service:
name: wazuh-agent
state: restarted
3 changes: 3 additions & 0 deletions etc/kayobe/inventory/group_vars/all/wazuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# Ansible custom SCA policies directory
local_custom_sca_policies_path: "{{ kayobe_env_config_path }}/wazuh/custom_sca_policies"
3 changes: 0 additions & 3 deletions etc/kayobe/inventory/group_vars/wazuh-manager/wazuh-manager
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ local_certs_path: "{{ playbook_dir }}/wazuh/certificates"
# Ansible control host custom certificates directory
local_custom_certs_path: "{{ playbook_dir }}/wazuh/custom_certificates"

# Ansible custom SCA policies directory
local_custom_sca_policies_path: "{{ kayobe_env_config_path }}/wazuh/custom_sca_policies"

# Indexer variables
indexer_node_name: "{{ inventory_hostname }}"

Expand Down
Loading