diff --git a/ansible-wazuh-agent/defaults/main.yml b/ansible-wazuh-agent/defaults/main.yml
index bf9956ca..22682137 100644
--- a/ansible-wazuh-agent/defaults/main.yml
+++ b/ansible-wazuh-agent/defaults/main.yml
@@ -1,31 +1,40 @@
---
wazuh_manager_ip: 127.0.0.1
+wazuh_manager_proto: udp
wazuh_authd_port: 1515
-wazuh_register_client: true
+wazuh_register_client: false
wazuh_agent_config:
- frequency_check: 43200
- syscheck_scan_on_start: 'yes'
- ignore_files:
- - /etc/mtab
- - /etc/mnttab
- - /etc/hosts.deny
- - /etc/mail/statistics
- - /etc/random-seed
- - /etc/random.seed
- - /etc/adjtime
- - /etc/httpd/logs
- - /etc/utmpx
- - /etc/wtmpx
- - /etc/cups/certs
- - /etc/dumpdates
- - /etc/svc/volatile
- no_diff:
- - /etc/ssl/private.key
- directories:
- - check_all: 'yes'
- dirs: /etc,/usr/bin,/usr/sbin
- - check_all: 'yes'
- dirs: /bin,/sbin
+ syscheck:
+ frequency: 43200
+ scan_on_start: 'yes'
+ ignore:
+ - /etc/mtab
+ - /etc/mnttab
+ - /etc/hosts.deny
+ - /etc/mail/statistics
+ - /etc/random-seed
+ - /etc/random.seed
+ - /etc/adjtime
+ - /etc/httpd/logs
+ - /etc/utmpx
+ - /etc/wtmpx
+ - /etc/cups/certs
+ - /etc/dumpdates
+ - /etc/svc/volatile
+ no_diff:
+ - /etc/ssl/private.key
+ directories:
+ - dirs: /etc,/usr/bin,/usr/sbin
+ checks: 'check_all="yes"'
+ - dirs: /bin,/sbin
+ checks: 'check_all="yes"'
+ rootcheck:
+ frequency: 43200
+ openscap:
+ disable: 'yes'
+ timeout: 1800
+ interval: '1d'
+ scan_on_start: 'yes'
localfiles:
- format: 'syslog'
location: '/var/log/messages'
diff --git a/ansible-wazuh-agent/tasks/Debian.yml b/ansible-wazuh-agent/tasks/Debian.yml
index 1c4ed03a..a11899e6 100644
--- a/ansible-wazuh-agent/tasks/Debian.yml
+++ b/ansible-wazuh-agent/tasks/Debian.yml
@@ -3,9 +3,10 @@
apt: name="{{ item }}" state=present update_cache=yes
with_items:
- apt-transport-https
+ - ca-certificates
- name: Debian/Ubuntu | Installing repository key
- shell: curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | apt-key add -
+ apt_key: url=https://packages.wazuh.com/key/GPG-KEY-WAZUH
- name: Debian/Ubuntu | Add Wazuh repositories
apt_repository:
@@ -13,7 +14,32 @@
state: present
update_cache: yes
-- name: Set Distribution CIS filename for debian
+- name: Debian/Ubuntu | Set Distribution CIS filename for debian
set_fact:
cis_distribution_filename: cis_debian_linux_rcl.txt
when: ansible_os_family == "Debian"
+
+- name: Debian/Ubuntu | Install OpenScap
+ package: name={{ item }} state=present
+ when: wazuh_agent_config.openscap.disable == 'no'
+ with_items:
+ - libopenscap8
+ - xsltproc
+ tags:
+ - init
+
+- name: Debian/Ubuntu | Get OpenScap installed version
+ shell: "dpkg-query --showformat='${Version}' --show libopenscap8"
+ register: openscap_version
+ when: wazuh_agent_config.openscap.disable == 'no'
+ changed_when: true
+ tags:
+ - config
+
+- name: Debian/Ubuntu | Check OpenScap version
+ shell: "dpkg --compare-versions '{{ openscap_version.stdout }}' '>=' '1.2'; echo $?"
+ register: openscap_version_valid
+ when: wazuh_agent_config.openscap.disable == 'no'
+ changed_when: true
+ tags:
+ - config
diff --git a/ansible-wazuh-agent/tasks/RedHat.yml b/ansible-wazuh-agent/tasks/RedHat.yml
index cd74640f..6eb304fc 100644
--- a/ansible-wazuh-agent/tasks/RedHat.yml
+++ b/ansible-wazuh-agent/tasks/RedHat.yml
@@ -43,5 +43,6 @@
- name: RedHat/CentOS/RedHat | Install openscap
package: name=openscap-scanner state=present
+ when: wazuh_agent_config.openscap.disable == 'no'
tags:
- init
diff --git a/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 b/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2
index 20a47807..35c83fbb 100644
--- a/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2
+++ b/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2
@@ -11,7 +11,14 @@
{% if wazuh_profile is defined %}
{{ wazuh_profile }}
{% endif %}
- udp
+ {{ wazuh_manager_proto }}
+ {% if wazuh_manager_port is defined %}
+ {{ wazuh_manager_port }}
+ {% endif %}
+ {% if wazuh_notify_time is defined and wazuh_time_reconnect is defined %}
+ {{ wazuh_notify_time }}
+ {{ wazuh_time_reconnect }}
+ {% endif %}
@@ -25,8 +32,8 @@
yes
yes
-
- 43200
+
+ {{ wazuh_agent_config.rootcheck.frequency }}
/var/ossec/etc/shared/rootkit_files.txt
/var/ossec/etc/shared/rootkit_trojans.txt
@@ -40,26 +47,79 @@
-
- {{ wazuh_agent_config.frequency_check }}
- {{ wazuh_agent_config.syscheck_scan_on_start }}
+
+ {{ wazuh_agent_config.syscheck.frequency }}
+ {{ wazuh_agent_config.syscheck.scan_on_start }}
-
- {% for directory in wazuh_agent_config.directories %}
- {{ directory.dirs }}
+
+ {% if wazuh_agent_config.syscheck.directories is defined %}
+ {% for directory in wazuh_agent_config.syscheck.directories %}
+ {{ directory.dirs }}
{% endfor %}
+ {% endif %}
- {% for ignore_file in wazuh_agent_config.ignore_files %}
- {{ ignore_file }}
+ {% if wazuh_agent_config.syscheck.ignore is defined %}
+ {% for ignore in wazuh_agent_config.syscheck.ignore %}
+ {{ ignore }}
{% endfor %}
+ {% endif %}
- {% for no_diff in wazuh_agent_config.no_diff %}
+ {% for no_diff in wazuh_agent_config.syscheck.no_diff %}
{{ no_diff }}
{% endfor %}
+ {% if wazuh_agent_config.openscap.disable == 'no' %}
+
+ no
+ {{ wazuh_agent_config.openscap.timeout }}
+ {{ wazuh_agent_config.openscap.interval }}
+ {{ wazuh_agent_config.openscap.scan_on_start }}
+ {% if ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial' %}
+
+ xccdf_org.ssgproject.content_profile_common
+
+ {% elif ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie' %}
+ {% if openscap_version_valid.stdout == "0" %}
+
+ xccdf_org.ssgproject.content_profile_common
+
+ {% endif %}
+
+ {% elif ansible_distribution == 'CentOS' %}
+ {% if ansible_distribution_major_version == '7' %}
+
+ {% elif ansible_distribution_major_version == '6' %}
+
+ {% endif %}
+ xccdf_org.ssgproject.content_profile_pci-dss
+ xccdf_org.ssgproject.content_profile_common
+
+ {% elif ansible_distribution == 'RedHat' %}
+ {% if ansible_distribution_major_version == '7' %}
+
+ {% elif ansible_distribution_major_version == '6' %}
+
+ {% endif %}
+ xccdf_org.ssgproject.content_profile_pci-dss
+ xccdf_org.ssgproject.content_profile_common
+
+ {% if ansible_distribution_major_version == '7' %}
+
+ {% elif ansible_distribution_major_version == '6' %}
+
+ {% endif %}
+ {% elif ansible_distribution == 'Fedora' %}
+
+ xccdf_org.ssgproject.content_profile_pci-dss
+ xccdf_org.ssgproject.content_profile_common
+
+ {% endif %}
+
+ {% endif %}
+
{% for localfile in wazuh_agent_config.localfiles %}
@@ -73,58 +133,4 @@
{% endfor %}
- {% if ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial' %}
-
- 1800
- 1d
- yes
-
-
- xccdf_org.ssgproject.content_profile_common
-
-
- {% elif ansible_distribution == 'CentOS' %}
-
- 1800
- 1d
- yes
-
- {% if ansible_distribution_major_version == '7' %}
-
- {% elif ansible_distribution_major_version == '6' %}
-
- {% endif %}
- xccdf_org.ssgproject.content_profile_pci-dss
- xccdf_org.ssgproject.content_profile_common
-
-
- {% elif ansible_distribution == 'RedHat' %}
-
- 1800
- 1d
- yes
-
- {% if ansible_distribution_major_version == '7' %}
-
- {% elif ansible_distribution_major_version == '6' %}
-
- {% endif %}
- xccdf_org.ssgproject.content_profile_pci-dss
- xccdf_org.ssgproject.content_profile_common
-
-
- {% elif ansible_distribution == 'Fedora' %}
-
- yes
- 1800
- 1d
- yes
-
-
- xccdf_org.ssgproject.content_profile_pci-dss
- xccdf_org.ssgproject.content_profile_common
-
-
- {% endif %}
-