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

Added wazuh-filebeat template to Wazuh indexer #2712

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 7 additions & 3 deletions stack/indexer/base/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ set -x
# License (version 2) as published by the FSF - Free Software
# Foundation.

set -e
set -ex

architecture="$1"
revision="$2"
future="$3"
reference="$4"
filebeat_module_reference="$3"
future="$4"
reference="$5"
opensearch_version="2.10.0"
base_dir=/opt/wazuh-indexer-base

Expand Down Expand Up @@ -64,6 +65,7 @@ mkdir -p ./etc/wazuh-indexer/
cp -r ./config/* ./etc/wazuh-indexer/
rm -rf ./config
cp -r /root/stack/indexer/base/files/etc/wazuh-indexer/* ./etc/wazuh-indexer/
curl -so ./etc/wazuh-indexer/wazuh-template.json "https://github.com/wazuh/wazuh/blob/${filebeat_module_reference}/extensions/elasticsearch/7.x/wazuh-template.json"
cp -r /root/stack/indexer/base/files/etc/sysconfig ./etc/
cp -r /root/stack/indexer/base/files/etc/init.d ./etc/
cp -r /root/stack/indexer/base/files/usr ./
Expand All @@ -72,6 +74,8 @@ cp -r /root/stack/indexer/indexer-init.sh bin/
rm -rf ./plugins/opensearch-security/tools/install_demo_configuration.sh
cp /root/VERSION .



# -----------------------------------------------------------------------------

# Compile systemD module
Expand Down
29 changes: 22 additions & 7 deletions stack/indexer/base/generate_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ container_name="indexer_base_builder"
architecture="x64"
future="no"
revision="1"
filebeat_module_reference=""

# -----------------------------------------------------------------------------

Expand Down Expand Up @@ -48,11 +49,11 @@ build_base() {
# Build the RPM package with a Docker container
if [ "${reference}" ];then
docker run -t --rm -v ${outdir}/:/tmp/output:Z \
${container_name} ${architecture} ${revision} ${future} ${reference} || return 1
${container_name} ${architecture} ${revision} ${filebeat_module_reference} ${future} ${reference} || return 1
else
docker run -t --rm -v ${outdir}/:/tmp/output:Z \
-v ${current_path}/../../..:/root:Z \
${container_name} ${architecture} ${revision} ${future} || return 1
${container_name} ${architecture} ${revision} ${filebeat_module_reference} ${future} || return 1
fi

echo "Base file $(ls -Art ${outdir} | tail -n 1) added to ${outdir}."
Expand All @@ -66,11 +67,12 @@ help() {
echo
echo "Usage: $0 [OPTIONS]"
echo
echo " -s, --store <path> [Optional] Set the destination path of package. By default, an output folder will be created."
echo " --reference <ref> [Optional] wazuh-packages branch or tag"
echo " --future [Optional] Build test future package 99.99.0 Used for development purposes."
echo " -r, --revision <rev> [Optional] Package revision. By default ${revision}"
echo " -h, --help Show this help."
echo " -s, --store <path> [Optional] Set the destination path of package. By default, an output folder will be created."
echo " --reference <ref> [Optional] wazuh-packages branch or tag."
echo " -f, --filebeat-module-reference [Optional] wazuh/wazuh Filebeat template branch or tag."
echo " --future [Optional] Build test future package 99.99.0 Used for development purposes."
echo " -r, --revision <rev> [Optional] Package revision. By default ${revision}"
echo " -h, --help Show this help."
echo
exit "${1}"
}
Expand Down Expand Up @@ -100,6 +102,14 @@ main() {
help 1
fi
;;
"-f"|"--filebeat-module-reference")
if [ -n "${2}" ]; then
filebeat_module_reference="${2}"
shift 2
else
help 1
fi
;;
"--future")
future="yes"
shift 1
Expand All @@ -112,11 +122,16 @@ main() {
help 1
fi
;;

*)
help 1
esac
done

if [ -z "${filebeat_module_reference}" ]; then
filebeat_module_reference=$(cat ${current_path}/../../../VERSION)
fi

build_base || clean 1

clean 0
Expand Down
34 changes: 24 additions & 10 deletions stack/indexer/deb/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ deb_builder_dockerfile="${current_path}/docker"
future="no"
base_cmd=""
build_base="yes"
filebeat_module_reference=""

trap ctrl_c INT

Expand All @@ -40,7 +41,7 @@ build_deb() {

# Copy the necessary files
cp ${current_path}/builder.sh ${dockerfile_path}

if [ "${build_base}" == "yes" ];then
# Base generation
if [ "${future}" == "yes" ];then
Expand All @@ -49,7 +50,7 @@ build_deb() {
if [ "${reference}" ];then
base_cmd+="--reference ${reference}"
fi
../base/generate_base.sh -s ${outdir} -r ${revision} ${base_cmd}
../base/generate_base.sh -s ${outdir} -r ${revision} -f ${filebeat_module_reference} ${base_cmd}
else
if [ "${reference}" ];then
version=$(curl -sL https://raw.githubusercontent.com/wazuh/wazuh-packages/${reference}/VERSION | cat)
Expand Down Expand Up @@ -107,14 +108,15 @@ help() {
echo
echo "Usage: $0 [OPTIONS]"
echo
echo " -a, --architecture <arch> [Optional] Target architecture of the package [amd64]."
echo " -b, --build-base <yes/no> [Optional] Build a new base or use a existing one. By default, yes."
echo " -r, --revision <rev> [Optional] Package revision. By default: 1."
echo " -s, --store <path> [Optional] Set the destination path of package. By default, an output folder will be created."
echo " --reference <ref> [Optional] wazuh-packages branch to download SPECs, not used by default."
echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one."
echo " --future [Optional] Build test future package 99.99.0 Used for development purposes."
echo " -h, --help Show this help."
echo " -a, --architecture <arch> [Optional] Target architecture of the package [amd64]."
echo " -b, --build-base <yes/no> [Optional] Build a new base or use a existing one. By default, yes."
echo " -r, --revision <rev> [Optional] Package revision. By default: 1."
echo " -s, --store <path> [Optional] Set the destination path of package. By default, an output folder will be created."
echo " --reference <ref> [Optional] wazuh-packages branch to download SPECs, not used by default."
echo " -f, --filebeat-module-reference [Optional] wazuh/wazuh Filebeat template branch or tag."
echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one."
echo " --future [Optional] Build test future package 99.99.0 Used for development purposes."
echo " -h, --help Show this help."
echo
exit $1
}
Expand Down Expand Up @@ -159,6 +161,14 @@ main() {
help 1
fi
;;
"-f"|"--filebeat-module-reference")
if [ -n "${2}" ]; then
filebeat_module_reference="${2}"
shift 2
else
help 1
fi
;;
"--dont-build-docker")
build_docker="no"
shift 1
Expand All @@ -180,6 +190,10 @@ main() {
esac
done

if [ -z "${filebeat_module_reference}" ]; then
filebeat_module_reference=$(cat ${current_path}/../../../VERSION)
fi

build || clean 1

clean 0
Expand Down
1 change: 1 addition & 0 deletions stack/indexer/deb/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ override_dh_fixperms:
chmod 660 $(TARGET_DIR)$(CONFIG_DIR)/jvm.options
chmod 750 $(TARGET_DIR)$(INSTALLATION_DIR)/modules/aggs-matrix-stats
chmod 660 $(TARGET_DIR)$(CONFIG_DIR)/opensearch.yml
chmod 660 $(TARGET_DIR)$(CONFIG_DIR)/wazuh-template.json
chmod 640 $(TARGET_DIR)$(CONFIG_DIR)/opensearch-security/roles_mapping.yml
chmod 640 $(TARGET_DIR)$(CONFIG_DIR)/opensearch-security/internal_users.yml
chmod 640 $(TARGET_DIR)$(CONFIG_DIR)/opensearch-security/roles.yml
Expand Down
32 changes: 22 additions & 10 deletions stack/indexer/rpm/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rpm_builder_dockerfile="${current_path}/docker"
future="no"
base_cmd=""
build_base="yes"
filebeat_module_reference=""

trap ctrl_c INT

Expand Down Expand Up @@ -49,7 +50,7 @@ build_rpm() {
if [ "${reference}" ];then
base_cmd+="--reference ${reference}"
fi
../base/generate_base.sh -s ${outdir} -r ${revision} ${base_cmd}
../base/generate_base.sh -s ${outdir} -r ${revision} -f ${filebeat_module_reference} ${base_cmd}
else
if [ "${reference}" ];then
version=$(curl -sL https://raw.githubusercontent.com/wazuh/wazuh-packages/${reference}/VERSION | cat)
Expand Down Expand Up @@ -106,14 +107,15 @@ help() {
echo
echo "Usage: $0 [OPTIONS]"
echo
echo " -a, --architecture <arch> [Optional] Target architecture of the package [x86_64]."
echo " -b, --build-base <yes/no> [Optional] Build a new base or use a existing one. By default, yes."
echo " -r, --revision <rev> [Optional] Package revision. By default: 1."
echo " -s, --store <path> [Optional] Set the destination path of package. By default, an output folder will be created."
echo " --reference <ref> [Optional] wazuh-packages branch to download SPECs, not used by default."
echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one."
echo " --future [Optional] Build test future package 99.99.0 Used for development purposes."
echo " -h, --help Show this help."
echo " -a, --architecture <arch> [Optional] Target architecture of the package [x86_64]."
echo " -b, --build-base <yes/no> [Optional] Build a new base or use a existing one. By default, yes."
echo " -r, --revision <rev> [Optional] Package revision. By default: 1."
echo " -s, --store <path> [Optional] Set the destination path of package. By default, an output folder will be created."
echo " --reference <ref> [Optional] wazuh-packages branch to download SPECs, not used by default."
echo " -f, --filebeat-module-reference [Optional] wazuh/wazuh Filebeat template branch or tag."
echo " --dont-build-docker [Optional] Locally built docker image will be used instead of generating a new one."
echo " --future [Optional] Build test future package 99.99.0 Used for development purposes."
echo " -h, --help Show this help."
echo
exit $1
}
Expand Down Expand Up @@ -158,6 +160,14 @@ main() {
help 1
fi
;;
"-f"|"--filebeat-module-reference")
if [ -n "${2}" ]; then
filebeat_module_reference="${2}"
shift 2
else
help 1
fi
;;
"--dont-build-docker")
build_docker="no"
shift 1
Expand All @@ -179,7 +189,9 @@ main() {
esac
done

set -ex
if [ -z "${filebeat_module_reference}" ]; then
filebeat_module_reference=$(cat ${current_path}/../../../VERSION)
fi

build || clean 1

Expand Down
1 change: 1 addition & 0 deletions stack/indexer/rpm/wazuh-indexer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ rm -fr %{buildroot}
%attr(640, %{USER}, %{GROUP}) %{CONFIG_DIR}/opensearch-performance-analyzer/*.properties
%attr(640, %{USER}, %{GROUP}) %{CONFIG_DIR}/opensearch-performance-analyzer/plugin-stats-metadata
%attr(640, %{USER}, %{GROUP}) %{CONFIG_DIR}/opensearch-performance-analyzer/*.policy
%attr(660, %{USER}, %{GROUP}) %{CONFIG_DIR}/wazuh-template.json
%dir %attr(750, %{USER}, %{GROUP}) %{INSTALL_DIR}/performance-analyzer-rca/
%dir %attr(750, %{USER}, %{GROUP}) %{INSTALL_DIR}/performance-analyzer-rca/config/
%attr(640, %{USER}, %{GROUP}) %{INSTALL_DIR}/performance-analyzer-rca/config/agent-stats-metadata
Expand Down
Loading