From 8d4c1feddd91dd1e15fc6d8de642ece548893ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 14 Feb 2024 10:22:31 +0000 Subject: [PATCH 1/3] feat: migrate filebeat url logic to inventory schema --- .../wazuh/ansible-filebeat-oss/tasks/main.yml | 16 ++-------------- .../roles/wazuh/wazuh_environment/schema.j2 | 12 +++++++++++- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml b/provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml index 843bbfd42d..e8203dc494 100644 --- a/provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml +++ b/provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml @@ -30,23 +30,11 @@ path: "{{ filebeat_module_folder }}" register: filebeat_module_folder -- name: Download pre-release Filebeat module package - get_url: - url: "{{ filebeat_module_pre_release_package_url }}/{{ filebeat_module_package_name }}" - dest: "{{ filebeat_module_package_path }}" - when: not filebeat_module_folder.stat.exists and repository == "pre-release" - -- name: Download staging Filebeat module package - get_url: - url: "{{ filebeat_module_staging_package_url }}/{{ filebeat_module_package_name }}" - dest: "{{ filebeat_module_package_path }}" - when: not filebeat_module_folder.stat.exists and repository == "staging" - -- name: Download production Filebeat module package +- name: Download Filebeat module package get_url: url: "{{ filebeat_module_package_url }}/{{ filebeat_module_package_name }}" dest: "{{ filebeat_module_package_path }}" - when: not filebeat_module_folder.stat.exists and repository == "live" + when: not filebeat_module_folder.stat.exists - name: Unpack Filebeat module package unarchive: diff --git a/provisioning/roles/wazuh/wazuh_environment/schema.j2 b/provisioning/roles/wazuh/wazuh_environment/schema.j2 index 94ac28d10a..bc8a72b07e 100644 --- a/provisioning/roles/wazuh/wazuh_environment/schema.j2 +++ b/provisioning/roles/wazuh/wazuh_environment/schema.j2 @@ -106,11 +106,21 @@ wazuh_custom_packages_installation_indexer_rpm_url: {{ role_parameters['wazuh_cu {% endif %} {% if role == 'filebeat' %} -{% if role_parameters['filebeat_repo'] is defined%} +{% if role_parameters['filebeat_repo'] is defined %} filebeat_module_package_url: {{ role_parameters['filebeat_repo'] }} +{% else %} +{% if repository == 'pre-release' %} +filebeat_module_package_url: https://packages-dev.wazuh.com/pre-release/filebeat +{% elif repository == 'live' %} +filebeat_module_package_url: https://packages.wazuh.com/4.x/filebeat +{% elif repository == 'staging' %} +filebeat_module_package_url: https://packages-dev.wazuh.com/staging/filebeat +{% endif %} {% endif %} {% endif %} + + {%- endmacro -%} {% if indexer is defined%} From 210cee70c6380d6a5985a77d3f2b81c3ac169195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 14 Feb 2024 10:36:15 +0000 Subject: [PATCH 2/3] fix: filebeat schema parameters --- provisioning/roles/wazuh/wazuh_environment/schema.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/provisioning/roles/wazuh/wazuh_environment/schema.j2 b/provisioning/roles/wazuh/wazuh_environment/schema.j2 index bc8a72b07e..fc14de0de4 100644 --- a/provisioning/roles/wazuh/wazuh_environment/schema.j2 +++ b/provisioning/roles/wazuh/wazuh_environment/schema.j2 @@ -109,11 +109,11 @@ wazuh_custom_packages_installation_indexer_rpm_url: {{ role_parameters['wazuh_cu {% if role_parameters['filebeat_repo'] is defined %} filebeat_module_package_url: {{ role_parameters['filebeat_repo'] }} {% else %} -{% if repository == 'pre-release' %} +{% if role_parameters['repository'] == 'pre-release' %} filebeat_module_package_url: https://packages-dev.wazuh.com/pre-release/filebeat -{% elif repository == 'live' %} +{% elif role_parameters['repository'] == 'live' %} filebeat_module_package_url: https://packages.wazuh.com/4.x/filebeat -{% elif repository == 'staging' %} +{% elif role_parameters['repository'] == 'staging' %} filebeat_module_package_url: https://packages-dev.wazuh.com/staging/filebeat {% endif %} {% endif %} From 242b1e724cb207ca8a53065df4100e88b1e5c6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 14 Feb 2024 12:22:41 +0000 Subject: [PATCH 3/3] refac: filebeat provisioning tasks --- .../roles/wazuh/ansible-filebeat-oss/defaults/main.yml | 4 +--- provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml | 2 +- provisioning/roles/wazuh/wazuh_environment/schema.j2 | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/provisioning/roles/wazuh/ansible-filebeat-oss/defaults/main.yml b/provisioning/roles/wazuh/ansible-filebeat-oss/defaults/main.yml index fb6b767387..4af68ae478 100644 --- a/provisioning/roles/wazuh/ansible-filebeat-oss/defaults/main.yml +++ b/provisioning/roles/wazuh/ansible-filebeat-oss/defaults/main.yml @@ -9,8 +9,6 @@ filebeat_output_indexer_hosts: - "localhost:9200" filebeat_module_package_url: https://packages.wazuh.com/4.x/filebeat -filebeat_module_pre_release_package_url: https://packages-dev.wazuh.com/pre-release/filebeat -filebeat_module_staging_package_url: https://packages-dev.wazuh.com/staging/filebeat filebeat_module_package_name: wazuh-filebeat-0.4.tar.gz filebeat_module_package_path: /tmp/ filebeat_module_destination: /usr/share/filebeat/module @@ -28,4 +26,4 @@ filebeatrepo: apt: 'deb https://packages.wazuh.com/4.x/apt/ stable main' yum: 'https://packages.wazuh.com/4.x/yum/' gpg: 'https://packages.wazuh.com/key/GPG-KEY-WAZUH' - key_id: '0DCFCA5547B19D2A6099506096B3EE5F29111145' \ No newline at end of file + key_id: '0DCFCA5547B19D2A6099506096B3EE5F29111145' diff --git a/provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml b/provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml index e8203dc494..f86de14bfc 100644 --- a/provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml +++ b/provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml @@ -34,7 +34,7 @@ get_url: url: "{{ filebeat_module_package_url }}/{{ filebeat_module_package_name }}" dest: "{{ filebeat_module_package_path }}" - when: not filebeat_module_folder.stat.exists + when: not filebeat_module_folder.stat.exists - name: Unpack Filebeat module package unarchive: diff --git a/provisioning/roles/wazuh/wazuh_environment/schema.j2 b/provisioning/roles/wazuh/wazuh_environment/schema.j2 index fc14de0de4..5558bfbcc6 100644 --- a/provisioning/roles/wazuh/wazuh_environment/schema.j2 +++ b/provisioning/roles/wazuh/wazuh_environment/schema.j2 @@ -119,8 +119,6 @@ filebeat_module_package_url: https://packages-dev.wazuh.com/staging/filebeat {% endif %} {% endif %} - - {%- endmacro -%} {% if indexer is defined%}