diff --git a/ansible-wazuh-agent/defaults/main.yml b/ansible-wazuh-agent/defaults/main.yml index bf9956ca..2b01c5e7 100644 --- a/ansible-wazuh-agent/defaults/main.yml +++ b/ansible-wazuh-agent/defaults/main.yml @@ -1,31 +1,38 @@ --- wazuh_manager_ip: 127.0.0.1 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: + 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..10d1be05 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,29 @@ 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 + with_items: + - libopenscap8 + - xsltproc + tags: + - init + +- name: Debian/Ubuntu | Get OpenScap installed version + shell: "dpkg-query --showformat='${Version}' --show libopenscap8" + register: openscap_version + 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 + changed_when: true + tags: + - config 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..1361a41e 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 @@ -25,8 +25,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 +40,77 @@ - - {{ 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 %} + + 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 %} + + {% for localfile in wazuh_agent_config.localfiles %} @@ -73,58 +124,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 %} -