Add checking into steps and container names

This commit is contained in:
Victor Carlos Erenu
2025-12-24 01:21:59 +07:00
parent 73c8b33bcd
commit 76122bd3b8
3 changed files with 102 additions and 37 deletions
+92 -37
View File
@@ -33,16 +33,20 @@ jobs:
build-images: build-images:
needs: prepare-variables # needs: prepare-variables
uses: ./.github/workflows/Procedure_push_docker_images.yml # uses: ./.github/workflows/Procedure_push_docker_images.yml
secrets: inherit # secrets: inherit
with: # with:
image_tag: ${{ needs.prepare-variables.outputs.WAZUH_IMAGE_VERSION }} # image_tag: ${{ needs.prepare-variables.outputs.WAZUH_IMAGE_VERSION }}
docker_reference: ${{ github.head_ref }} # docker_reference: ${{ github.head_ref }}
revision: ${{ needs.prepare-variables.outputs.WAZUH_TAG_REVISION }} # revision: ${{ needs.prepare-variables.outputs.WAZUH_TAG_REVISION }}
reference: "latest" # reference: "latest"
id: ${{ github.run_id }} # id: ${{ github.run_id }}
dev: true # dev: true
runs-on: ubuntu-latest
steps:
- name: Skip build
run: echo "Build images step skipped"
Execute-Goss-tests: Execute-Goss-tests:
needs: [prepare-variables, build-images] needs: [prepare-variables, build-images]
@@ -147,6 +151,7 @@ jobs:
- name: Check Wazuh indexer start - name: Check Wazuh indexer start
run: | run: |
INDEXER_CONTAINERS=$(docker ps --format '{{.Names}}' | grep "indexer")
for i in {1..10}; do for i in {1..10}; do
echo "Checking Wazuh indexer health (Attempt $i/10)" echo "Checking Wazuh indexer health (Attempt $i/10)"
RESPONSE=$(curl -XGET "https://0.0.0.0:9200/_cluster/health?pretty" -u admin:admin -k -s --retry 2 || true) RESPONSE=$(curl -XGET "https://0.0.0.0:9200/_cluster/health?pretty" -u admin:admin -k -s --retry 2 || true)
@@ -156,8 +161,15 @@ jobs:
echo "$RESPONSE" echo "$RESPONSE"
exit 0 exit 0
fi fi
echo "Waiting for cluster to be online" echo "Waiting for cluster to be online"
for CONTAINER_NAME in $INDEXER_CONTAINERS; do
echo ""
echo "========================================================="
echo "Container logs for $CONTAINER_NAME"
echo "========================================================="
docker logs --tail 30 "$CONTAINER_NAME"
echo "---------------------------------------------------------"
done
[ $i -lt 10 ] && sleep 60 [ $i -lt 10 ] && sleep 60
done done
status_index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:admin -k -s | wc -l`" status_index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:admin -k -s | wc -l`"
@@ -192,13 +204,21 @@ jobs:
- name: Check documents into wazuh-states index - name: Check documents into wazuh-states index
run: | run: |
sleep 120 for i in {1..10}; do
docs="`curl -XGET "https://0.0.0.0:9200/wazuh-states*/_count" -u admin:admin -k -s | jq -r ".count"`" echo "Checking documents in wazuh-states (Attempt $i/10)..."
if [[ $docs -gt 0 ]]; then RESPONSE=$(curl -XGET "https://0.0.0.0:9200/wazuh-states*/_count" -u admin:admin -k -s || echo "{}")
echo "wazuh-states index documents: ${docs}" DOCS=$(echo "$RESPONSE" | jq -r '.count // 0')
else if [[ "$DOCS" -gt 0 ]]; then
echo "wazuh-states index documents: ${docs}" echo "wazuh-states index has documents: ${DOCS}"
fi exit 0
fi
echo "The index is empty or does not exist yet (Count: $DOCS). Waiting 30s"
[ $i -lt 10 ] && sleep 30
done
echo "Error: No documents found in wazuh-states after 10 attempts."
echo "Last response: $RESPONSE"
exit 1
- name: Check Wazuh templates - name: Check Wazuh templates
run: | run: |
@@ -229,13 +249,22 @@ jobs:
- name: Check Wazuh dashboard service URL - name: Check Wazuh dashboard service URL
run: | run: |
status=$(curl -XGET --silent https://0.0.0.0:443/app/status -k -u admin:admin -I -s | grep -E "^HTTP" | awk '{print $2}') for i in {1..10}; do
if [[ $status -eq 200 ]]; then echo "Checking Wazuh dashboard (Attempt $i/10)"
echo "Wazuh dashboard status: ${status}" STATUS=$(curl -k -s -o /dev/null -w "%{http_code}" -u admin:admin "https://0.0.0.0:443/app/status")
else echo "Current status: $STATUS"
echo "Wazuh dashboard status: ${status}" if [[ "$STATUS" == "200" ]]; then
echo "Wazuh dashboard is UP"
exit 0
elif [[ "$STATUS" == "429" || "$STATUS" == "503" ]]; then
echo "Dashboard is busy or initializing (Status $STATUS). Retrying in 30s"
else
echo "Unexpected status $STATUS. Retrying in 30s"
fi
sleep 30
done
echo "Error: Dashboard did not reach 200 status in time."
exit 1 exit 1
fi
- name: Modify Docker endpoint into Wazuh agent docker-compose.yml file - name: Modify Docker endpoint into Wazuh agent docker-compose.yml file
run: sed -i "s/<WAZUH_MANAGER_IP>/$(ip addr show docker0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)/g" wazuh-agent/docker-compose.yml run: sed -i "s/<WAZUH_MANAGER_IP>/$(ip addr show docker0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)/g" wazuh-agent/docker-compose.yml
@@ -349,7 +378,7 @@ jobs:
- name: Check Wazuh indexer start - name: Check Wazuh indexer start
run: | run: |
for i in {1..10}; do for i in {1..20}; do
echo "Checking Wazuh indexer health (Attempt $i/10)" echo "Checking Wazuh indexer health (Attempt $i/10)"
RESPONSE=$(curl -XGET "https://0.0.0.0:9200/_cluster/health?pretty" -u admin:admin -k -s --retry 2 || true) RESPONSE=$(curl -XGET "https://0.0.0.0:9200/_cluster/health?pretty" -u admin:admin -k -s --retry 2 || true)
@@ -360,6 +389,14 @@ jobs:
fi fi
echo "Waiting for cluster to be online" echo "Waiting for cluster to be online"
for CONTAINER_NAME in $INDEXER_CONTAINERS; do
echo ""
echo "========================================================="
echo "Container logs for $CONTAINER_NAME"
echo "========================================================="
docker logs --tail 30 "$CONTAINER_NAME"
echo "---------------------------------------------------------"
done
[ $i -lt 10 ] && sleep 60 [ $i -lt 10 ] && sleep 60
done done
status_index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:admin -k -s | wc -l`" status_index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:admin -k -s | wc -l`"
@@ -395,12 +432,21 @@ jobs:
- name: Check documents into wazuh-states index - name: Check documents into wazuh-states index
run: | run: |
docs="`curl -XGET "https://0.0.0.0:9200/wazuh-states*/_count" -u admin:admin -k -s | jq -r ".count"`" for i in {1..10}; do
if [[ $docs -gt 0 ]]; then echo "Checking documents in wazuh-states (Attempt $i/10)..."
echo "wazuh-states index documents: ${docs}" RESPONSE=$(curl -XGET "https://0.0.0.0:9200/wazuh-states*/_count" -u admin:admin -k -s || echo "{}")
else DOCS=$(echo "$RESPONSE" | jq -r '.count // 0')
echo "wazuh-states index documents: ${docs}" if [[ "$DOCS" -gt 0 ]]; then
fi echo "wazuh-states index has documents: ${DOCS}"
exit 0
fi
echo "The index is empty or does not exist yet (Count: $DOCS). Waiting 30s"
[ $i -lt 10 ] && sleep 30
done
echo "Error: No documents found in wazuh-states after 10 attempts."
echo "Last response: $RESPONSE"
exit 1
- name: Check Wazuh templates - name: Check Wazuh templates
run: | run: |
@@ -438,13 +484,22 @@ jobs:
- name: Check Wazuh dashboard service URL - name: Check Wazuh dashboard service URL
run: | run: |
status=$(curl -XGET --silent https://0.0.0.0:443/app/status -k -u admin:admin -I | grep -E "^HTTP" | awk '{print $2}') for i in {1..10}; do
if [[ $status -eq 200 ]]; then echo "Checking Wazuh dashboard (Attempt $i/10)"
echo "Wazuh dashboard status: ${status}" STATUS=$(curl -k -s -o /dev/null -w "%{http_code}" -u admin:admin "https://0.0.0.0:443/app/status")
else echo "Current status: $STATUS"
echo "Wazuh dashboard status: ${status}" if [[ "$STATUS" == "200" ]]; then
echo "Wazuh dashboard is UP"
exit 0
elif [[ "$STATUS" == "429" || "$STATUS" == "503" ]]; then
echo "Dashboard is busy or initializing (Status $STATUS). Retrying in 30s"
else
echo "Unexpected status $STATUS. Retrying in 30s"
fi
sleep 30
done
echo "Error: Dashboard did not reach 200 status in time."
exit 1 exit 1
fi
- name: Modify Docker endpoint into Wazuh agent docker-compose.yml file - name: Modify Docker endpoint into Wazuh agent docker-compose.yml file
run: sed -i "s/<WAZUH_MANAGER_IP>/$(ip addr show docker0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)/g" wazuh-agent/docker-compose.yml run: sed -i "s/<WAZUH_MANAGER_IP>/$(ip addr show docker0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)/g" wazuh-agent/docker-compose.yml
+7
View File
@@ -3,6 +3,7 @@ services:
wazuh.master: wazuh.master:
image: wazuh/wazuh-manager:5.0.0 image: wazuh/wazuh-manager:5.0.0
hostname: wazuh.master hostname: wazuh.master
container_name: multi-node-wazuh.master
restart: always restart: always
ulimits: ulimits:
memlock: memlock:
@@ -39,6 +40,7 @@ services:
wazuh.worker: wazuh.worker:
image: wazuh/wazuh-manager:5.0.0 image: wazuh/wazuh-manager:5.0.0
hostname: wazuh.worker hostname: wazuh.worker
container_name: multi-node-wazuh.worker
restart: always restart: always
ulimits: ulimits:
memlock: memlock:
@@ -72,6 +74,7 @@ services:
wazuh1.indexer: wazuh1.indexer:
image: wazuh/wazuh-indexer:5.0.0 image: wazuh/wazuh-indexer:5.0.0
hostname: wazuh1.indexer hostname: wazuh1.indexer
container_name: multi-node-wazuh1.indexer
restart: always restart: always
ports: ports:
- "9200:9200" - "9200:9200"
@@ -103,6 +106,7 @@ services:
wazuh2.indexer: wazuh2.indexer:
image: wazuh/wazuh-indexer:5.0.0 image: wazuh/wazuh-indexer:5.0.0
hostname: wazuh2.indexer hostname: wazuh2.indexer
container_name: multi-node-wazuh2.indexer
restart: always restart: always
environment: environment:
- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g - OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g
@@ -130,6 +134,7 @@ services:
wazuh3.indexer: wazuh3.indexer:
image: wazuh/wazuh-indexer:5.0.0 image: wazuh/wazuh-indexer:5.0.0
hostname: wazuh3.indexer hostname: wazuh3.indexer
container_name: multi-node-wazuh3.indexer
restart: always restart: always
environment: environment:
- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g - OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g
@@ -157,6 +162,7 @@ services:
wazuh.dashboard: wazuh.dashboard:
image: wazuh/wazuh-dashboard:5.0.0 image: wazuh/wazuh-dashboard:5.0.0
hostname: wazuh.dashboard hostname: wazuh.dashboard
container_name: multi-node-wazuh.dashboard
restart: always restart: always
ports: ports:
- 443:5601 - 443:5601
@@ -190,6 +196,7 @@ services:
nginx: nginx:
image: nginx:stable image: nginx:stable
hostname: nginx hostname: nginx
container_name: multi-node-nginx
restart: always restart: always
ports: ports:
- "1514:1514" - "1514:1514"
+3
View File
@@ -3,6 +3,7 @@ services:
wazuh.manager: wazuh.manager:
image: wazuh/wazuh-manager:5.0.0 image: wazuh/wazuh-manager:5.0.0
hostname: wazuh.manager hostname: wazuh.manager
container_name: single-node-wazuh.manager
restart: always restart: always
ulimits: ulimits:
memlock: memlock:
@@ -40,6 +41,7 @@ services:
wazuh.indexer: wazuh.indexer:
image: wazuh/wazuh-indexer:5.0.0 image: wazuh/wazuh-indexer:5.0.0
hostname: wazuh.indexer hostname: wazuh.indexer
container_name: single-node-wazuh.indexer
restart: always restart: always
ports: ports:
- "9200:9200" - "9200:9200"
@@ -70,6 +72,7 @@ services:
wazuh.dashboard: wazuh.dashboard:
image: wazuh/wazuh-dashboard:5.0.0 image: wazuh/wazuh-dashboard:5.0.0
hostname: wazuh.dashboard hostname: wazuh.dashboard
container_name: single-node-wazuh.dashboard
restart: always restart: always
ports: ports:
- 443:443 - 443:443