diff --git a/roles/wazuh/ansible-filebeat-oss/tasks/main.yml b/roles/wazuh/ansible-filebeat-oss/tasks/main.yml index cb1f87a6..55b9ed5e 100644 --- a/roles/wazuh/ansible-filebeat-oss/tasks/main.yml +++ b/roles/wazuh/ansible-filebeat-oss/tasks/main.yml @@ -11,10 +11,10 @@ when: packages_repository == 'staging' - include_tasks: RedHat.yml - when: ansible_os_family == 'RedHat' + when: ansible_facts.os_family == 'RedHat' - include_tasks: Debian.yml - when: ansible_os_family == 'Debian' + when: ansible_facts.os_family == 'Debian' - name: Install Filebeat | Redhat yum: @@ -25,7 +25,7 @@ tags: - install - init - when: ansible_os_family == 'RedHat' + when: ansible_facts.os_family == 'RedHat' - name: Install Filebeat | Debian apt: @@ -38,7 +38,7 @@ until: "install is not failed" retries: 10 delay: 10 - when: ansible_os_family == 'Debian' + when: ansible_facts.os_family == 'Debian' - name: Checking if Filebeat Module folder file exists stat: @@ -87,7 +87,7 @@ enabled: true - include_tasks: "RMRedHat.yml" - when: ansible_os_family == "RedHat" + when: ansible_facts.os_family == "RedHat" - include_tasks: "RMDebian.yml" - when: ansible_os_family == "Debian" + when: ansible_facts.os_family == "Debian" diff --git a/roles/wazuh/ansible-wazuh-agent/defaults/main.yml b/roles/wazuh/ansible-wazuh-agent/defaults/main.yml index 81543716..a9643f73 100644 --- a/roles/wazuh/ansible-wazuh-agent/defaults/main.yml +++ b/roles/wazuh/ansible-wazuh-agent/defaults/main.yml @@ -50,7 +50,7 @@ wazuh_agent_config_overlay: yes # This is a middle ground between breaking existing uses of wazuh_agent_nat # and allow working with agents having several network interfaces -wazuh_agent_address: '{{ "any" if wazuh_agent_nat else ansible_default_ipv4.address }}' +wazuh_agent_address: '{{ "any" if wazuh_agent_nat else ansible_facts.default_ipv4.address }}' # List of managers. The first one with register variable declared *and* set to true # is the one used to register the agent. Otherwise, the first one in the list will be used. diff --git a/roles/wazuh/ansible-wazuh-agent/tasks/Debian.yml b/roles/wazuh/ansible-wazuh-agent/tasks/Debian.yml index 043ad9ae..a67dd50e 100644 --- a/roles/wazuh/ansible-wazuh-agent/tasks/Debian.yml +++ b/roles/wazuh/ansible-wazuh-agent/tasks/Debian.yml @@ -22,7 +22,7 @@ state: present register: wazuh_agent_ca_package_install until: wazuh_agent_ca_package_install is succeeded - when: not (ansible_distribution == "Debian" and ansible_distribution_major_version in ['11']) + when: not (ansible_facts.distribution == "Debian" and ansible_facts.distribution_major_version in ['11']) - name: Debian/Ubuntu | Installing Wazuh repository key (Ubuntu 14) become: true @@ -34,8 +34,8 @@ executable: /bin/bash changed_when: false when: - - ansible_distribution == "Ubuntu" - - ansible_distribution_major_version | int == 14 + - ansible_facts.distribution == "Ubuntu" + - ansible_facts.distribution_major_version | int == 14 - not wazuh_custom_packages_installation_agent_enabled - name: Debian/Ubuntu | Download Wazuh repository key @@ -43,13 +43,13 @@ url: "{{ wazuh_agent_config.repo.gpg }}" dest: "{{ wazuh_agent_config.repo.path }}" when: - - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) + - not (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version | int == 14) - not wazuh_custom_packages_installation_agent_enabled - name: Debian/Ubuntu | Import Wazuh GPG key command: "gpg --no-default-keyring --keyring gnupg-ring:{{ wazuh_agent_config.repo.keyring_path }} --import {{ wazuh_agent_config.repo.path }}" when: - - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) + - not (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version | int == 14) - not wazuh_custom_packages_installation_agent_enabled args: creates: "{{ wazuh_agent_config.repo.keyring_path }}" @@ -59,7 +59,7 @@ path: "{{ wazuh_agent_config.repo.keyring_path }}" mode: '0644' when: - - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) + - not (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version | int == 14) - not wazuh_custom_packages_installation_agent_enabled - name: Debian/Ubuntu | Add Wazuh repositories @@ -74,7 +74,7 @@ - name: Debian/Ubuntu | Set Distribution CIS filename for debian set_fact: cis_distribution_filename: cis_debian_linux_rcl.txt - when: ansible_os_family == "Debian" + when: ansible_facts.os_family == "Debian" - name: Debian/Ubuntu | Install OpenJDK-8 repo apt_repository: @@ -82,7 +82,7 @@ state: present update_cache: true when: - - (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) + - (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version | int == 14) - when: - wazuh_agent_config.cis_cat.disable == 'no' diff --git a/roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml b/roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml index 64ac3400..b267dd4e 100644 --- a/roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml +++ b/roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml @@ -1,9 +1,9 @@ --- - include_tasks: "RedHat.yml" - when: ansible_os_family == "RedHat" + when: ansible_facts.os_family == "RedHat" - include_tasks: "Debian.yml" - when: ansible_os_family == "Debian" + when: ansible_facts.os_family == "Debian" - include_tasks: "installation_from_custom_packages.yml" when: @@ -15,7 +15,7 @@ state: present lock_timeout: '{{ wazuh_agent_yum_lock_timeout }}' when: - - ansible_os_family|lower == "redhat" + - ansible_facts.os_family|lower == "redhat" - not wazuh_custom_packages_installation_agent_enabled tags: - init @@ -26,7 +26,7 @@ state: present cache_valid_time: 3600 when: - - ansible_os_family|lower != "redhat" + - ansible_facts.os_family|lower != "redhat" - not wazuh_custom_packages_installation_agent_enabled - not ansible_check_mode tags: @@ -88,7 +88,7 @@ register: agent_auth_output notify: restart wazuh-agent vars: - agent_name: "{% if single_agent_name is defined %}{{ single_agent_name }}{% else %}{{ ansible_hostname }}{% endif %}" + agent_name: "{% if single_agent_name is defined %}{{ single_agent_name }}{% else %}{{ ansible_facts.hostname }}{% endif %}" when: - not client_keys_file.stat.exists or client_keys_file.stat.size == 0 - wazuh_agent_authd.registration_address is not none @@ -155,7 +155,7 @@ changed_when: api_agent_post.json.error == 0 register: api_agent_post vars: - agent_name: '{{ target_manager.agent_name | default(ansible_hostname) }}' + agent_name: '{{ target_manager.agent_name | default(ansible_facts.hostname) }}' jwt_token: '{{ api_jwt_result.json.data.token }}' tags: - config @@ -197,7 +197,7 @@ OSSEC_ACTION_CONFIRMED: y register: manage_agents_output vars: - agent_name: '{{ target_manager.agent_name | default(ansible_hostname) }}' + agent_name: '{{ target_manager.agent_name | default(ansible_facts.hostname) }}' notify: restart wazuh-agent when: - not ( wazuh_agent_authd.enable | bool ) @@ -264,8 +264,8 @@ - include_tasks: "RMRedHat.yml" when: - - ansible_os_family == "RedHat" + - ansible_facts.os_family == "RedHat" - include_tasks: "RMDebian.yml" when: - - ansible_os_family == "Debian" + - ansible_facts.os_family == "Debian" diff --git a/roles/wazuh/ansible-wazuh-agent/tasks/RedHat.yml b/roles/wazuh/ansible-wazuh-agent/tasks/RedHat.yml index 5c053542..fbe48b09 100644 --- a/roles/wazuh/ansible-wazuh-agent/tasks/RedHat.yml +++ b/roles/wazuh/ansible-wazuh-agent/tasks/RedHat.yml @@ -8,8 +8,8 @@ gpgcheck: true changed_when: false when: - - (ansible_facts['os_family']|lower == 'redhat') and (ansible_distribution|lower != 'amazon') - - (ansible_distribution_major_version|int <= 5) + - (ansible_facts.os_family|lower == 'redhat') and (ansible_facts.distribution|lower != 'amazon') + - (ansible_facts.distribution_major_version|int <= 5) - not wazuh_custom_packages_installation_agent_enabled register: repo_v5_installed @@ -36,26 +36,26 @@ - name: Set Distribution CIS filename for RHEL5 set_fact: cis_distribution_filename: cis_rhel5_linux_rcl.txt - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "5" + when: ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version == "5" - name: Set Distribution CIS filename for RHEL6 set_fact: cis_distribution_filename: cis_rhel6_linux_rcl.txt - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == "6" + when: ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version == "6" - name: Set Distribution CIS filename for RHEL7 set_fact: cis_distribution_filename: cis_rhel7_linux_rcl.txt when: - - ansible_os_family == "RedHat" - - ansible_distribution_major_version == "7" + - ansible_facts.os_family == "RedHat" + - ansible_facts.distribution_major_version == "7" - name: Set Distribution CIS filename for RHEL7 (Amazon) set_fact: cis_distribution_filename: cis_rhel7_linux_rcl.txt when: - - ansible_distribution == "Amazon" - - ansible_distribution_major_version == "NA" + - ansible_facts.distribution == "Amazon" + - ansible_facts.distribution_major_version == "NA" - name: RedHat/CentOS/RedHat | Install openscap package: name=openscap-scanner state=present diff --git a/roles/wazuh/ansible-wazuh-agent/tasks/installation_from_custom_packages.yml b/roles/wazuh/ansible-wazuh-agent/tasks/installation_from_custom_packages.yml index 99103f29..17811bfe 100644 --- a/roles/wazuh/ansible-wazuh-agent/tasks/installation_from_custom_packages.yml +++ b/roles/wazuh/ansible-wazuh-agent/tasks/installation_from_custom_packages.yml @@ -4,7 +4,7 @@ deb: "{{ wazuh_custom_packages_installation_agent_deb_url }}" state: present when: - - ansible_os_family|lower == "debian" + - ansible_facts.os_family|lower == "debian" - wazuh_custom_packages_installation_agent_enabled - name: Install Wazuh Agent from .rpm packages | yum @@ -13,17 +13,17 @@ state: present lock_timeout: 200 when: - - ansible_os_family|lower == "redhat" + - ansible_facts.os_family|lower == "redhat" - wazuh_custom_packages_installation_agent_enabled - - not (ansible_distribution|lower == "centos" and ansible_distribution_major_version >= "8") - - not (ansible_distribution|lower == "redhat" and ansible_distribution_major_version >= "8") + - not (ansible_facts.distribution|lower == "centos" and ansible_facts.distribution_major_version >= "8") + - not (ansible_facts.distribution|lower == "redhat" and ansible_facts.distribution_major_version >= "8") - name: Install Wazuh Agent from .rpm packages | dnf dnf: name: "{{ wazuh_custom_packages_installation_agent_rpm_url }}" state: present when: - - ansible_os_family|lower == "redhat" + - ansible_facts.os_family|lower == "redhat" - wazuh_custom_packages_installation_agent_enabled - - (ansible_distribution|lower == "centos" and ansible_distribution_major_version >= "8") or - (ansible_distribution|lower == "redhat" and ansible_distribution_major_version >= "8") \ No newline at end of file + - (ansible_facts.distribution|lower == "centos" and ansible_facts.distribution_major_version >= "8") or + (ansible_facts.distribution|lower == "redhat" and ansible_facts.distribution_major_version >= "8") \ No newline at end of file diff --git a/roles/wazuh/ansible-wazuh-agent/tasks/macOS.yml b/roles/wazuh/ansible-wazuh-agent/tasks/macOS.yml index 9c1f6ce7..cc83b407 100644 --- a/roles/wazuh/ansible-wazuh-agent/tasks/macOS.yml +++ b/roles/wazuh/ansible-wazuh-agent/tasks/macOS.yml @@ -60,7 +60,7 @@ register: agent_auth_output notify: macOS | Restart Wazuh Agent vars: - agent_name: "{% if single_agent_name is defined %}{{ single_agent_name }}{% else %}{{ ansible_hostname }}{% endif %}" + agent_name: "{% if single_agent_name is defined %}{{ single_agent_name }}{% else %}{{ ansible_facts.hostname }}{% endif %}" when: - not client_keys_file.stat.exists or client_keys_file.stat.size == 0 - wazuh_agent_authd.registration_address is not none @@ -125,7 +125,7 @@ changed_when: api_agent_post.json.error == 0 register: api_agent_post vars: - agent_name: '{{ target_manager.agent_name | default(ansible_hostname) }}' + agent_name: '{{ target_manager.agent_name | default(ansible_facts.hostname) }}' jwt_token: '{{ api_jwt_result.json.data.token }}' tags: - config @@ -167,7 +167,7 @@ OSSEC_ACTION_CONFIRMED: y register: manage_agents_output vars: - agent_name: '{{ target_manager.agent_name | default(ansible_hostname) }}' + agent_name: '{{ target_manager.agent_name | default(ansible_facts.hostname) }}' notify: macOS | Restart Wazuh Agent when: - not ( wazuh_agent_authd.enable | bool ) diff --git a/roles/wazuh/ansible-wazuh-agent/tasks/main.yml b/roles/wazuh/ansible-wazuh-agent/tasks/main.yml index 26c27817..a82c672b 100644 --- a/roles/wazuh/ansible-wazuh-agent/tasks/main.yml +++ b/roles/wazuh/ansible-wazuh-agent/tasks/main.yml @@ -19,10 +19,10 @@ when: wazuh_agent_config_overlay | bool - include_tasks: "Windows.yml" - when: ansible_os_family == "Windows" + when: ansible_facts.os_family == "Windows" - include_tasks: "Linux.yml" - when: ansible_system == "Linux" + when: ansible_facts.system == "Linux" - include_tasks: "macOS.yml" - when: ansible_system == "Darwin" \ No newline at end of file + when: ansible_facts.system == "Darwin" \ No newline at end of file diff --git a/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 b/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 index bcf68e9d..b9fd7b40 100644 --- a/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 +++ b/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 @@ -24,13 +24,13 @@ {% endfor %} {% if wazuh_profile_centos is not none or wazuh_profile_ubuntu is not none %} - {% if ansible_distribution == 'CentOS' %} + {% if ansible_facts.distribution == 'CentOS' %} {{ wazuh_profile_centos }} - {% elif ansible_distribution == "Ubuntu" %} + {% elif ansible_facts.distribution == "Ubuntu" %} {{ wazuh_profile_ubuntu }} {% endif %} {% endif %} - {% if ansible_system == "Darwin" %} + {% if ansible_facts.system == "Darwin" %} {{ wazuh_profile_macos }} {% endif %} {% if wazuh_notify_time is not none and wazuh_time_reconnect is not none %} @@ -67,7 +67,7 @@ {% if wazuh_agent_config.enrollment.agent_key_path | length > 0 %} {{ wazuh_agent_config.enrollment.agent_key_path }} {% endif %} - {% if wazuh_agent_config.enrollment.authorization_pass_path | length > 0 and ansible_system != "Darwin" %} + {% if wazuh_agent_config.enrollment.authorization_pass_path | length > 0 and ansible_facts.system != "Darwin" %} {{ wazuh_agent_config.enrollment.authorization_pass_path }} {% else %} {{ wazuh_agent_config.enrollment.authorization_pass_path_macos }} @@ -96,7 +96,7 @@ {% if wazuh_agent_config.rootcheck is defined %} no - {% if ansible_system == "Linux" or ansible_system == "Darwin" %} + {% if ansible_facts.system == "Linux" or ansible_facts.system == "Darwin" %} yes yes yes @@ -108,7 +108,7 @@ {{ wazuh_agent_config.rootcheck.frequency }} - {% if ansible_system == "Darwin" %} + {% if ansible_facts.system == "Darwin" %} etc/shared/rootkit_files.txt etc/shared/rootkit_trojans.txt {% else %} @@ -117,7 +117,7 @@ {% endif %} yes {% endif %} - {% if ansible_os_family == "Windows" %} + {% if ansible_facts.os_family == "Windows" %} ./shared/win_applications_rcl.txt ./shared/win_malware_rcl.txt {% endif %} @@ -127,61 +127,61 @@ {% endif %} - {% if ansible_system == "Linux" and wazuh_agent_config.openscap.disable == 'no' %} + {% if ansible_facts.system == "Linux" and wazuh_agent_config.openscap.disable == 'no' %} {{ wazuh_agent_config.openscap.disable }} {{ 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' %} + {% if ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_release == 'xenial' %} xccdf_org.ssgproject.content_profile_common - {% elif ansible_distribution == 'Debian' %} - {% if ansible_distribution_release == 'jessie' %} + {% elif ansible_facts.distribution == 'Debian' %} + {% if ansible_facts.distribution_release == 'jessie' %} {% if openscap_version_valid.stdout == "0" %} xccdf_org.ssgproject.content_profile_common {% endif %} - {% elif ansible_distribution_release == 'stretch' %} + {% elif ansible_facts.distribution_release == 'stretch' %} {% endif %} - {% elif ansible_distribution == 'CentOS' %} - {% if ansible_distribution_major_version == '8' %} + {% elif ansible_facts.distribution == 'CentOS' %} + {% if ansible_facts.distribution_major_version == '8' %} {# Policy not available #} - {% elif ansible_distribution_major_version == '7' %} + {% elif ansible_facts.distribution_major_version == '7' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common - {% elif ansible_distribution_major_version == '6' %} + {% elif ansible_facts.distribution_major_version == '6' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common {% endif %} - {% elif ansible_distribution == 'RedHat' %} - {% if ansible_distribution_major_version == '8' %} + {% elif ansible_facts.distribution == 'RedHat' %} + {% if ansible_facts.distribution_major_version == '8' %} {# Policy not available #} - {% elif ansible_distribution_major_version == '7' %} + {% elif ansible_facts.distribution_major_version == '7' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common - {% elif ansible_distribution_major_version == '6' %} + {% elif ansible_facts.distribution_major_version == '6' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common {% endif %} - {% if ansible_distribution_major_version == '7' %} + {% if ansible_facts.distribution_major_version == '7' %} - {% elif ansible_distribution_major_version == '6' %} + {% elif ansible_facts.distribution_major_version == '6' %} {% endif %} - {% elif ansible_distribution == 'Fedora' %} + {% elif ansible_facts.distribution == 'Fedora' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common @@ -190,20 +190,20 @@ {% endif %} - {% if ansible_system != "Darwin" %} + {% if ansible_facts.system != "Darwin" %} {{ wazuh_agent_config.cis_cat.disable }} {{ wazuh_agent_config.cis_cat.timeout }} {{ wazuh_agent_config.cis_cat.interval }} {{ wazuh_agent_config.cis_cat.scan_on_start }} - {% if wazuh_agent_config.cis_cat.install_java == 'yes' and ansible_system == "Linux" %} + {% if wazuh_agent_config.cis_cat.install_java == 'yes' and ansible_facts.system == "Linux" %} /usr/bin - {% elif ansible_os_family == "Windows" %} + {% elif ansible_facts.os_family == "Windows" %} {{ wazuh_agent_config.cis_cat.java_path_win }} {% else %} {{ wazuh_agent_config.cis_cat.java_path }} {% endif %} - {% if ansible_os_family == "Windows" %}{{ wazuh_agent_config.cis_cat.ciscat_path_win }}{% else %}{{ wazuh_agent_config.cis_cat.ciscat_path }}{% endif %} + {% if ansible_facts.os_family == "Windows" %}{{ wazuh_agent_config.cis_cat.ciscat_path_win }}{% else %}{{ wazuh_agent_config.cis_cat.ciscat_path }}{% endif %} {% endif %} @@ -211,11 +211,11 @@ {{ wazuh_agent_config.osquery.disable }} {{ wazuh_agent_config.osquery.run_daemon }} - {% if ansible_os_family == "Windows" %} + {% if ansible_facts.os_family == "Windows" %} {{ wazuh_agent_config.osquery.bin_path_win }} {% endif %} - {% if ansible_os_family == "Windows" %}{{ wazuh_agent_config.osquery.log_path_win }}{% else %}{{ wazuh_agent_config.osquery.log_path }}{% endif %} - {% if ansible_os_family == "Windows" %}{{ wazuh_agent_config.osquery.config_path_win }}{% else %}{{ wazuh_agent_config.osquery.config_path }}{% endif %} + {% if ansible_facts.os_family == "Windows" %}{{ wazuh_agent_config.osquery.log_path_win }}{% else %}{{ wazuh_agent_config.osquery.log_path }}{% endif %} + {% if ansible_facts.os_family == "Windows" %}{{ wazuh_agent_config.osquery.config_path_win }}{% else %}{{ wazuh_agent_config.osquery.config_path }}{% endif %} {{ wazuh_agent_config.osquery.add_labels }} @@ -262,14 +262,14 @@ no {{ wazuh_agent_config.syscheck.frequency }} - {% if ansible_system == "Linux" or ansible_system == "Darwin" %} + {% if ansible_facts.system == "Linux" or ansible_facts.system == "Darwin" %} {{ wazuh_agent_config.syscheck.scan_on_start }} - {% if wazuh_agent_config.syscheck.directories is defined and ansible_system == "Linux" %} + {% if wazuh_agent_config.syscheck.directories is defined and ansible_facts.system == "Linux" %} {% for directory in wazuh_agent_config.syscheck.directories %} {{ directory.dirs }} {% endfor %} - {% elif ansible_system == "Darwin" %} + {% elif ansible_facts.system == "Darwin" %} {% for directory in wazuh_agent_config.syscheck.macos_directories %} {{ directory.dirs }} {% endfor %} @@ -277,14 +277,14 @@ {% endif %} - {% if wazuh_agent_config.syscheck.win_directories is defined and ansible_os_family == "Windows" %} + {% if wazuh_agent_config.syscheck.win_directories is defined and ansible_facts.os_family == "Windows" %} {% for directory in wazuh_agent_config.syscheck.win_directories %} {{ directory.dirs }} {% endfor %} {% endif %} - {% if wazuh_agent_config.syscheck.ignore is defined and (ansible_system == "Linux" or ansible_system == "Darwin") %} + {% if wazuh_agent_config.syscheck.ignore is defined and (ansible_facts.system == "Linux" or ansible_facts.system == "Darwin") %} {% for ignore in wazuh_agent_config.syscheck.ignore %} {{ ignore }} {% endfor %} @@ -297,13 +297,13 @@ {% endfor %} {% endif %} - {% if wazuh_agent_config.syscheck.ignore is defined and ansible_os_family == "Windows" %} + {% if wazuh_agent_config.syscheck.ignore is defined and ansible_facts.os_family == "Windows" %} {% for ignore in wazuh_agent_config.syscheck.ignore_win %} {{ ignore }} {% endfor %} {% endif %} - {% if ansible_system == "Linux" or ansible_system == "Darwin" %} + {% if ansible_facts.system == "Linux" or ansible_facts.system == "Darwin" %} {% for no_diff in wazuh_agent_config.syscheck.no_diff %} {{ no_diff }} @@ -315,7 +315,7 @@ {{ wazuh_agent_config.syscheck.skip_sys }} {% endif %} - {% if ansible_os_family == "Windows" %} + {% if ansible_facts.os_family == "Windows" %} {% for registry_key in wazuh_agent_config.syscheck.windows_registry %} {% if registry_key.arch is defined %} {{ registry_key.key }} @@ -325,7 +325,7 @@ {% endfor %} {% endif %} - {% if ansible_os_family == "Windows" %} + {% if ansible_facts.os_family == "Windows" %} {% for registry_key in wazuh_agent_config.syscheck.windows_registry_ignore %} {% if registry_key.type is defined %} {{ registry_key.key }} @@ -335,7 +335,7 @@ {% endfor %} {% endif %} - {% if ansible_os_family == "Windows" %} + {% if ansible_facts.os_family == "Windows" %} {{ wazuh_agent_config.syscheck.win_audit_interval }} {% endif %} @@ -357,7 +357,7 @@ {% endif %} - {% if ansible_system == "Linux" %} + {% if ansible_facts.system == "Linux" %} {% for localfile in wazuh_agent_config.localfiles.linux %} @@ -384,7 +384,7 @@ {% endif %} - {% if ansible_system == "Darwin" %} + {% if ansible_facts.system == "Darwin" %} {% for localfile in wazuh_agent_config.localfiles.macos %} @@ -405,7 +405,7 @@ {% endfor %} {% endif %} - {% if ansible_os_family == "Debian" %} + {% if ansible_facts.os_family == "Debian" %} {% for localfile in wazuh_agent_config.localfiles.debian %} @@ -428,7 +428,7 @@ {% endfor %} {% endif %} - {% if ansible_os_family == "RedHat" %} + {% if ansible_facts.os_family == "RedHat" %} {% for localfile in wazuh_agent_config.localfiles.centos %} @@ -451,7 +451,7 @@ {% endfor %} {% endif %} - {% if ansible_os_family == "Windows" %} + {% if ansible_facts.os_family == "Windows" %} {% for localfile in wazuh_agent_config.localfiles.windows %} @@ -481,7 +481,7 @@ {{ wazuh_agent_config.active_response.ar_disabled|default('no') }} - {% if ansible_os_family == "Windows" %}{{ wazuh_agent_config.active_response.ca_store_win }}{% elif ansible_system == "Darwin" %}{{ wazuh_agent_config.active_response.ca_store_macos }}{% else %}{{ wazuh_agent_config.active_response.ca_store }}{% endif %} + {% if ansible_facts.os_family == "Windows" %}{{ wazuh_agent_config.active_response.ca_store_win }}{% elif ansible_facts.system == "Darwin" %}{{ wazuh_agent_config.active_response.ca_store_macos }}{% else %}{{ wazuh_agent_config.active_response.ca_store }}{% endif %} {{ wazuh_agent_config.active_response.ca_verification }} diff --git a/roles/wazuh/ansible-wazuh-manager/tasks/Debian.yml b/roles/wazuh/ansible-wazuh-manager/tasks/Debian.yml index fdbfddee..148327db 100644 --- a/roles/wazuh/ansible-wazuh-manager/tasks/Debian.yml +++ b/roles/wazuh/ansible-wazuh-manager/tasks/Debian.yml @@ -22,8 +22,8 @@ executable: /bin/bash changed_when: false when: - - ansible_distribution == "Ubuntu" - - ansible_distribution_major_version | int == 14 + - ansible_facts.distribution == "Ubuntu" + - ansible_facts.distribution_major_version | int == 14 - not wazuh_custom_packages_installation_manager_enabled - name: Debian/Ubuntu | Download Wazuh repository key @@ -31,13 +31,13 @@ url: "{{ wazuh_manager_config.repo.gpg }}" dest: "{{ wazuh_manager_config.repo.path }}" when: - - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) + - not (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version | int == 14) - not wazuh_custom_packages_installation_manager_enabled - name: Debian/Ubuntu | Import Wazuh GPG key command: "gpg --no-default-keyring --keyring gnupg-ring:{{ wazuh_manager_config.repo.keyring_path }} --import {{ wazuh_manager_config.repo.path }}" when: - - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) + - not (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version | int == 14) - not wazuh_custom_packages_installation_manager_enabled args: creates: "{{ wazuh_manager_config.repo.keyring_path }}" @@ -47,7 +47,7 @@ path: "{{ wazuh_manager_config.repo.keyring_path }}" mode: '0644' when: - - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) + - not (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version | int == 14) - not wazuh_custom_packages_installation_manager_enabled - name: Debian/Ubuntu | Add Wazuh repositories @@ -70,7 +70,7 @@ state: present update_cache: true when: - - (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) + - (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version | int == 14) - when: - wazuh_manager_config.cis_cat.disable == 'no' diff --git a/roles/wazuh/ansible-wazuh-manager/tasks/RedHat.yml b/roles/wazuh/ansible-wazuh-manager/tasks/RedHat.yml index eb50c4e1..48742b3a 100644 --- a/roles/wazuh/ansible-wazuh-manager/tasks/RedHat.yml +++ b/roles/wazuh/ansible-wazuh-manager/tasks/RedHat.yml @@ -8,8 +8,8 @@ gpgcheck: true changed_when: false when: - - (ansible_os_family|lower == 'redhat') and (ansible_distribution|lower != 'amazon') - - (ansible_distribution_major_version|int <= 5) + - (ansible_facts.os_family|lower == 'redhat') and (ansible_facts.distribution|lower != 'amazon') + - (ansible_facts.distribution_major_version|int <= 5) - not wazuh_custom_packages_installation_manager_enabled register: repo_v5_manager_installed @@ -33,15 +33,15 @@ until: wazuh_manager_openscp_packages_installed is succeeded tags: - init - when: not (ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA") and - not (ansible_distribution == "CentOS" and ansible_distribution_major_version == "8") + when: not (ansible_facts.distribution == "Amazon" and ansible_facts.distribution_major_version == "NA") and + not (ansible_facts.distribution == "CentOS" and ansible_facts.distribution_major_version == "8") - name: CentOS 6 | Install Software Collections (SCL) Repository package: name=centos-release-scl state=present register: wazuh_manager_scl_packages_installed until: wazuh_manager_scl_packages_installed is succeeded when: - - ansible_distribution == 'CentOS' and ansible_distribution_major_version == '6' + - ansible_facts.distribution == 'CentOS' and ansible_facts.distribution_major_version == '6' - wazuh_manager_config.cluster.disable != 'yes' - name: RedHat 6 | Enabling Red Hat Software Collections (RHSCL) @@ -50,7 +50,7 @@ - rhui-REGION-rhel-server-rhscl - rhel-server-rhscl-6-rpms when: - - ansible_distribution == 'RedHat' and ansible_distribution_major_version == '6' + - ansible_facts.distribution == 'RedHat' and ansible_facts.distribution_major_version == '6' - wazuh_manager_config.cluster.disable != 'yes' - name: CentOS/RedHat 6 | Install Python 2.7 @@ -58,7 +58,7 @@ register: wazuh_manager_python_package_installed until: wazuh_manager_python_package_installed is succeeded when: - - ( ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat' ) and ansible_distribution_major_version == '6' + - ( ansible_facts.distribution == 'CentOS' or ansible_facts.distribution == 'RedHat' ) and ansible_facts.distribution_major_version == '6' - wazuh_manager_config.cluster.disable != 'yes' - name: RedHat/CentOS/Fedora | Install OpenJDK 1.8 @@ -75,24 +75,24 @@ - name: Set Distribution CIS filename for RHEL5/CentOS-5 set_fact: cis_distribution_filename: cis_rhel5_linux_rcl.txt - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == '5' + when: ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version == '5' - name: Set Distribution CIS filename for RHEL6/CentOS-6 set_fact: cis_distribution_filename: cis_rhel6_linux_rcl.txt - when: ansible_os_family == "RedHat" and ansible_distribution_major_version == '6' + when: ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version == '6' - name: Set Distribution CIS filename for RHEL7/CentOS-7 set_fact: cis_distribution_filename: cis_rhel7_linux_rcl.txt when: - - ansible_os_family == "RedHat" and ansible_distribution_major_version == '7' + - ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version == '7' - name: Set Distribution CIS filename for RHEL7/CentOS-7 (Amazon) set_fact: cis_distribution_filename: cis_rhel7_linux_rcl.txt when: - - ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA" + - ansible_facts.distribution == "Amazon" and ansible_facts.distribution_major_version == "NA" - name: CentOS/RedHat/Amazon | Install wazuh-manager package: @@ -101,7 +101,7 @@ register: wazuh_manager_main_packages_installed until: wazuh_manager_main_packages_installed is succeeded when: - - ansible_os_family|lower == "redhat" + - ansible_facts.os_family|lower == "redhat" - not wazuh_custom_packages_installation_manager_enabled tags: - init @@ -116,7 +116,7 @@ regexp: 'echo -n "Starting Wazuh-manager: "' replace: "echo -n \"Starting Wazuh-manager (EL6): \"; source /opt/rh/python27/enable; export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{{ wazuh_dir }}/framework/lib" when: - - ansible_distribution in ['CentOS', 'RedHat', 'Amazon'] and ansible_distribution_major_version|int == 6 + - ansible_facts.distribution in ['CentOS', 'RedHat', 'Amazon'] and ansible_facts.distribution_major_version|int == 6 - wazuh_manager_config.cluster.disable != 'yes' - name: Install expect (EL5) @@ -128,7 +128,7 @@ register: wazuh_manager_main_packages_installed until: wazuh_manager_main_packages_installed is succeeded when: - - ansible_os_family|lower == "RedHat" - - ansible_distribution_major_version|int < 6 + - ansible_facts.os_family|lower == "RedHat" + - ansible_facts.distribution_major_version|int < 6 tags: - init diff --git a/roles/wazuh/ansible-wazuh-manager/tasks/installation_from_custom_packages.yml b/roles/wazuh/ansible-wazuh-manager/tasks/installation_from_custom_packages.yml index e52d1e8a..2634b3d5 100644 --- a/roles/wazuh/ansible-wazuh-manager/tasks/installation_from_custom_packages.yml +++ b/roles/wazuh/ansible-wazuh-manager/tasks/installation_from_custom_packages.yml @@ -7,7 +7,7 @@ when: - wazuh_custom_packages_installation_manager_enabled when: - - ansible_os_family|lower == "debian" + - ansible_facts.os_family|lower == "debian" - block: - name: Install Wazuh Manager from .rpm packages | yum @@ -17,8 +17,8 @@ lock_timeout: 200 when: - wazuh_custom_packages_installation_manager_enabled - - not (ansible_distribution|lower == "centos" and ansible_distribution_major_version >= "8") - - not (ansible_distribution|lower == "redhat" and ansible_distribution_major_version >= "8") + - not (ansible_facts.distribution|lower == "centos" and ansible_facts.distribution_major_version >= "8") + - not (ansible_facts.distribution|lower == "redhat" and ansible_facts.distribution_major_version >= "8") - name: Install Wazuh Manager from .rpm packages | dnf dnf: @@ -26,7 +26,7 @@ state: present when: - wazuh_custom_packages_installation_manager_enabled - - (ansible_distribution|lower == "centos" and ansible_distribution_major_version >= "8") or - (ansible_distribution|lower == "redhat" and ansible_distribution_major_version >= "8") + - (ansible_facts.distribution|lower == "centos" and ansible_facts.distribution_major_version >= "8") or + (ansible_facts.distribution|lower == "redhat" and ansible_facts.distribution_major_version >= "8") when: - - ansible_os_family|lower == "redhat" \ No newline at end of file + - ansible_facts.os_family|lower == "redhat" \ No newline at end of file diff --git a/roles/wazuh/ansible-wazuh-manager/tasks/main.yml b/roles/wazuh/ansible-wazuh-manager/tasks/main.yml index 6bbd5b33..2fde8c27 100644 --- a/roles/wazuh/ansible-wazuh-manager/tasks/main.yml +++ b/roles/wazuh/ansible-wazuh-manager/tasks/main.yml @@ -18,7 +18,7 @@ package: name: curl state: present - when: ansible_distribution != "Amazon" and ansible_distribution_version != "2023" + when: ansible_facts.distribution != "Amazon" and ansible_facts.distribution_version != "2023" register: package_status until: "package_status is not failed" retries: 10 @@ -28,7 +28,7 @@ package: name: curl-minimal state: present - when: ansible_distribution == "Amazon" and ansible_distribution_version == "2023" + when: ansible_facts.distribution == "Amazon" and ansible_facts.distribution_version == "2023" register: package_status until: "package_status is not failed" retries: 10 @@ -53,10 +53,10 @@ when: wazuh_manager_config_overlay | bool - include_tasks: "RedHat.yml" - when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int > 5) or (ansible_os_family == "RedHat" and ansible_distribution == "Amazon") + when: (ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version|int > 5) or (ansible_facts.os_family == "RedHat" and ansible_facts.distribution == "Amazon") - include_tasks: "Debian.yml" - when: ansible_os_family == "Debian" + when: ansible_facts.os_family == "Debian" - name: Generate the wazuh-keystore (username) shell: > @@ -79,8 +79,8 @@ name: expect state: "{{ wazuh_manager_package_state }}" when: - - not (ansible_os_family|lower == "redhat" and ansible_distribution_major_version|int < 6) and - not (ansible_distribution|lower == "centos" and ansible_distribution_major_version|int == 8) + - not (ansible_facts.os_family|lower == "redhat" and ansible_facts.distribution_major_version|int < 6) and + not (ansible_facts.distribution|lower == "centos" and ansible_facts.distribution_major_version|int == 8) tags: init - name: Generate SSL files for authd diff --git a/roles/wazuh/ansible-wazuh-manager/tasks/uninstall.yml b/roles/wazuh/ansible-wazuh-manager/tasks/uninstall.yml index 824e6926..e28e8585 100644 --- a/roles/wazuh/ansible-wazuh-manager/tasks/uninstall.yml +++ b/roles/wazuh/ansible-wazuh-manager/tasks/uninstall.yml @@ -5,11 +5,11 @@ repo: "{{ wazuh_manager_config.repo.apt }}" state: absent changed_when: false - when: ansible_os_family == "Debian" + when: ansible_facts.os_family == "Debian" - name: RedHat/CentOS/Fedora | Remove Wazuh repository (and clean up left-over metadata) yum_repository: name: wazuh_repo state: absent changed_when: false - when: ansible_os_family == "RedHat" or ansible_os_family == "Amazon" + when: ansible_facts.os_family == "RedHat" or ansible_facts.distribution == "Amazon" diff --git a/roles/wazuh/ansible-wazuh-manager/templates/var-ossec-etc-ossec-server.conf.j2 b/roles/wazuh/ansible-wazuh-manager/templates/var-ossec-etc-ossec-server.conf.j2 index f2cff4ca..b08ecb2c 100644 --- a/roles/wazuh/ansible-wazuh-manager/templates/var-ossec-etc-ossec-server.conf.j2 +++ b/roles/wazuh/ansible-wazuh-manager/templates/var-ossec-etc-ossec-server.conf.j2 @@ -136,61 +136,61 @@ yes - {% if ansible_system == "Linux" and wazuh_manager_config.openscap.disable == 'no' %} + {% if ansible_facts.system == "Linux" and wazuh_manager_config.openscap.disable == 'no' %} no {{ wazuh_manager_config.openscap.timeout }} {{ wazuh_manager_config.openscap.interval }} {{ wazuh_manager_config.openscap.scan_on_start }} - {% if ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial' %} + {% if ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_release == 'xenial' %} xccdf_org.ssgproject.content_profile_common - {% elif ansible_distribution == 'Debian' %} - {% if ansible_distribution_release == 'jessie' %} + {% elif ansible_facts.distribution == 'Debian' %} + {% if ansible_facts.distribution_release == 'jessie' %} {% if openscap_version_valid.stdout == "0" %} xccdf_org.ssgproject.content_profile_common {% endif %} - {% elif ansible_distribution_release == 'stretch' %} + {% elif ansible_facts.distribution_release == 'stretch' %} {% endif %} - {% elif ansible_distribution == 'CentOS' %} - {% if ansible_distribution_major_version == '8' %} + {% elif ansible_facts.distribution == 'CentOS' %} + {% if ansible_facts.distribution_major_version == '8' %} {# Policy not available #} - {% elif ansible_distribution_major_version == '7' %} + {% elif ansible_facts.distribution_major_version == '7' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common - {% elif ansible_distribution_major_version == '6' %} + {% elif ansible_facts.distribution_major_version == '6' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common {% endif %} - {% elif ansible_distribution == 'RedHat' %} - {% if ansible_distribution_major_version == '8' %} + {% elif ansible_facts.distribution == 'RedHat' %} + {% if ansible_facts.distribution_major_version == '8' %} {# Policy not available #} - {% elif ansible_distribution_major_version == '7' %} + {% elif ansible_facts.distribution_major_version == '7' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common - {% elif ansible_distribution_major_version == '6' %} + {% elif ansible_facts.distribution_major_version == '6' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common {% endif %} - {% if ansible_distribution_major_version == '7' %} + {% if ansible_facts.distribution_major_version == '7' %} - {% elif ansible_distribution_major_version == '6' %} + {% elif ansible_facts.distribution_major_version == '6' %} {% endif %} - {% elif ansible_distribution == 'Fedora' %} + {% elif ansible_facts.distribution == 'Fedora' %} xccdf_org.ssgproject.content_profile_pci-dss xccdf_org.ssgproject.content_profile_common @@ -431,7 +431,7 @@ {% endfor %} -{% if ansible_os_family == "Debian" %} +{% if ansible_facts.os_family == "Debian" %} {% for localfile in wazuh_manager_config.localfiles.debian %} @@ -470,7 +470,7 @@ {% endfor %} {% endif -%} -{% if ansible_os_family == "RedHat" %} +{% if ansible_facts.os_family == "RedHat" %} {% for localfile in wazuh_manager_config.localfiles.centos %} diff --git a/roles/wazuh/wazuh-dashboard/tasks/main.yml b/roles/wazuh/wazuh-dashboard/tasks/main.yml index 3f3fa665..3e5b6018 100755 --- a/roles/wazuh/wazuh-dashboard/tasks/main.yml +++ b/roles/wazuh/wazuh-dashboard/tasks/main.yml @@ -11,10 +11,10 @@ when: packages_repository == 'staging' - import_tasks: RedHat.yml - when: ansible_os_family == 'RedHat' + when: ansible_facts.os_family == 'RedHat' - import_tasks: Debian.yml - when: ansible_os_family == 'Debian' + when: ansible_facts.os_family == 'Debian' - name: Remove Dashboard configuration file file: @@ -96,4 +96,4 @@ state: started - import_tasks: RMRedHat.yml - when: ansible_os_family == 'RedHat' + when: ansible_facts.os_family == 'RedHat' diff --git a/roles/wazuh/wazuh-indexer/tasks/RedHat.yml b/roles/wazuh/wazuh-indexer/tasks/RedHat.yml index c2a9c54d..458a0c26 100644 --- a/roles/wazuh/wazuh-indexer/tasks/RedHat.yml +++ b/roles/wazuh/wazuh-indexer/tasks/RedHat.yml @@ -20,8 +20,8 @@ state: present lock_timeout: 200 when: - - ansible_distribution == 'Amazon' - - ansible_distribution_major_version == '2' + - ansible_facts.distribution == 'Amazon' + - ansible_facts.distribution_major_version == '2' - name: Configure vm.max_map_count lineinfile: @@ -36,7 +36,7 @@ become: yes when: - - ansible_distribution == 'Amazon' + - ansible_facts.distribution == 'Amazon' - name: RedHat/CentOS/Fedora | Install Indexer dependencies yum: diff --git a/roles/wazuh/wazuh-indexer/tasks/main.yml b/roles/wazuh/wazuh-indexer/tasks/main.yml index 24a2291f..da3cf6dc 100644 --- a/roles/wazuh/wazuh-indexer/tasks/main.yml +++ b/roles/wazuh/wazuh-indexer/tasks/main.yml @@ -16,10 +16,10 @@ - block: - import_tasks: RedHat.yml - when: ansible_os_family == 'RedHat' + when: ansible_facts.os_family == 'RedHat' - import_tasks: Debian.yml - when: ansible_os_family == 'Debian' + when: ansible_facts.os_family == 'Debian' - name: Remove performance analyzer plugin from Wazuh indexer become: true @@ -132,7 +132,7 @@ (hostvars[inventory_hostname]['private_ip'] | length) > 0 - import_tasks: "RMRedHat.yml" - when: ansible_os_family == "RedHat" + when: ansible_facts.os_family == "RedHat" - name: Reload systemd configuration systemd: diff --git a/roles/wazuh/wazuh-indexer/templates/jvm.options.j2 b/roles/wazuh/wazuh-indexer/templates/jvm.options.j2 index 74c01054..bf5ba93a 100644 --- a/roles/wazuh/wazuh-indexer/templates/jvm.options.j2 +++ b/roles/wazuh/wazuh-indexer/templates/jvm.options.j2 @@ -28,9 +28,9 @@ -Xmx32000m {% endif %} {% else %} --Xms{% if ansible_memtotal_mb < 64000 %}{{ ((ansible_memtotal_mb|int)/2)|int }}m{% else %}32000m{% endif %} +-Xms{% if ansible_facts.memtotal_mb < 64000 %}{{ ((ansible_facts.memtotal_mb|int)/2)|int }}m{% else %}32000m{% endif %} --Xmx{% if ansible_memtotal_mb < 64000 %}{{ ((ansible_memtotal_mb|int)/2)|int }}m{% else %}32000m{% endif %} +-Xmx{% if ansible_facts.memtotal_mb < 64000 %}{{ ((ansible_facts.memtotal_mb|int)/2)|int }}m{% else %}32000m{% endif %} {% endif %}