Skip to content

Commit

Permalink
Update offline installation workflows and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Enaraque committed Dec 20, 2024
1 parent acddaaa commit 87acaeb
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 77 deletions.
32 changes: 7 additions & 25 deletions .github/actions/offline-installation/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,6 @@ function check_file() {

}

function check_shards() {

retries=0
until [ "$(curl -s -k -u admin:admin "https://127.0.0.1:9200/_template/wazuh?pretty&filter_path=wazuh.settings.index.number_of_shards" | grep "number_of_shards")" ] || [ "${retries}" -eq 5 ]; do
sleep 5
retries=$((retries+1))
done

if [ ${retries} -eq 5 ]; then
echo "ERROR: Could not get the number of shards."
exit 1
fi
curl -s -k -u admin:admin "https://127.0.0.1:9200/_template/wazuh?pretty&filter_path=wazuh.settings.index.number_of_shards"
echo "INFO: Number of shards detected."

}

function dashboard_installation() {

install_package "wazuh-dashboard"
Expand Down Expand Up @@ -98,17 +81,17 @@ function dashboard_installation() {
function download_resources() {

check_file "${ABSOLUTE_PATH}"/wazuh-install.sh
bash "${ABSOLUTE_PATH}"/wazuh-install.sh -dw "${sys_type}"
bash "${ABSOLUTE_PATH}"/wazuh-install.sh -dw "${sys_type}" -d "${1}"
echo "INFO: Downloading the resources..."

curl -sO https://packages.wazuh.com/4.11/config.yml
curl -sO https://packages-dev.wazuh.com/${2}/config.yml
check_file "config.yml"

sed -i -e '0,/<indexer-node-ip>/ s/<indexer-node-ip>/127.0.0.1/' config.yml
sed -i -e '0,/<wazuh-manager-ip>/ s/<wazuh-manager-ip>/127.0.0.1/' config.yml
sed -i -e '0,/<dashboard-node-ip>/ s/<dashboard-node-ip>/127.0.0.1/' config.yml

curl -sO https://packages.wazuh.com/4.11/wazuh-certs-tool.sh
curl -sO https://packages-dev.wazuh.com/${2}/wazuh-certs-tool.sh
check_file "wazuh-certs-tool.sh"
chmod 744 wazuh-certs-tool.sh
./wazuh-certs-tool.sh --all
Expand Down Expand Up @@ -175,7 +158,6 @@ function filebeat_installation() {
fi

sleep 10
check_shards
eval "filebeat test output"
if [ "${PIPESTATUS[0]}" != 0 ]; then
echo "ERROR: The Filebeat installation has failed."
Expand All @@ -185,9 +167,10 @@ function filebeat_installation() {
}

function indexer_initialize() {
/usr/share/wazuh-indexer/bin/indexer-security-init.sh

retries=0
until [ "$(cat /var/log/wazuh-indexer/wazuh-cluster.log | grep "Node started")" ] || [ "${retries}" -eq 5 ]; do
while ! grep -E "\[node-[0-9]+\] Node 'node-[0-9]+' initialized" /var/log/wazuh-indexer/wazuh-cluster.log && [ "${retries}" -lt 5 ]; do
sleep 5
retries=$((retries+1))
done
Expand All @@ -196,7 +179,6 @@ function indexer_initialize() {
echo "ERROR: The indexer node is not started."
exit 1
fi
/usr/share/wazuh-indexer/bin/indexer-security-init.sh

}

Expand Down Expand Up @@ -225,7 +207,7 @@ function indexer_installation() {

if [ "${sys_type}" == "rpm" ]; then
runuser "wazuh-indexer" --shell="/bin/bash" --command="OPENSEARCH_PATH_CONF=/etc/wazuh-indexer /usr/share/wazuh-indexer/bin/opensearch" > /dev/null 2>&1 &
sleep 5
sleep 20
elif [ "${sys_type}" == "deb" ]; then
enable_start_service "wazuh-indexer"
fi
Expand Down Expand Up @@ -314,4 +296,4 @@ function manager_installation() {
/var/ossec/bin/wazuh-control start
fi

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ABSOLUTE_PATH="$( cd $(dirname ${0}) ; pwd -P )"

check_system
install_dependencies
download_resources
download_resources $1 $2

indexer_installation
echo "INFO: Wazuh indexer installation completed."
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/ansible-playbooks/offline_installation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---

- hosts: all
become: true

vars:
script_path: "{{ tmp_path }}"
pkg_repository: "{{ pkg_repository }}"
wazuh_version: "{{ wazuh_version }}"
script_name: "wazuh-install.sh"
offline_installation_path: ".github/actions/offline-installation"
offline_installation_script: "offline-installation.sh"

tasks:
- name: Copy installation script to the offline installation directory
command: "cp {{ script_name }} {{ offline_installation_path }}"
args:
chdir: "{{ script_path }}"

- name: Test offline installation
command: "bash {{ offline_installation_script }} {{ pkg_repository }} {{ wazuh_version }}"
args:
chdir: "{{ script_path }}/{{ offline_installation_path }}"
register: install_results
async: 500
poll: 5
Loading

0 comments on commit 87acaeb

Please sign in to comment.