post install zabbix tasks
This commit is contained in:
parent
dacc21aa26
commit
8788c25fa7
37
bolt/vm_automation/alpine/tasks/post_install_zabbix.sh
Normal file
37
bolt/vm_automation/alpine/tasks/post_install_zabbix.sh
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Task to Install Zabbix on an Alpine VM (alpine::post_install_zabbix)
|
||||||
|
|
||||||
|
# Install zabbix-agent2
|
||||||
|
sudo apk add zabbix-agent2 || {
|
||||||
|
echo '{"status": "failure", "message": "Failed to install zabbix-agent2", "output": "'"$(sudo apk add zabbix-agent2 2>&1)"'"}'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure zabbix-agent2
|
||||||
|
sudo sed -i -e 's/^Server=127\.0\.0\.1/# Server=127.0.0.1/' -e 's/^ServerActive=127\.0\.0\.1/ServerActive=10.44.0.5,zabbix.moeny.ai/' /etc/zabbix/zabbix_agent2.conf || {
|
||||||
|
echo '{"status": "failure", "message": "Failed to configure zabbix-agent2", "output": "Configuration failed"}'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add zabbix-agent2 to default runlevel
|
||||||
|
sudo rc-update add zabbix-agent2 default || {
|
||||||
|
echo '{"status": "failure", "message": "Failed to add zabbix-agent2 to default runlevel", "output": "'"$(sudo rc-update add zabbix-agent2 default 2>&1)"'"}'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start zabbix-agent2 with debug output
|
||||||
|
service_start=$(sudo rc-service zabbix-agent2 start 2>&1)
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo '{"status": "failure", "message": "Failed to start zabbix-agent2", "output": "'"$service_start"'"}'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify installation with more detailed status check
|
||||||
|
status_output=$(sudo rc-service zabbix-agent2 status 2>&1)
|
||||||
|
if echo "$status_output" | grep -q "status: started"; then
|
||||||
|
echo '{"status": "success", "message": "Zabbix agent installed and running", "output": "'"$status_output"'"}'
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo '{"status": "failure", "message": "Zabbix agent status check failed", "output": "'"$status_output"'"}'
|
||||||
|
exit 1
|
||||||
|
fi
|
32
bolt/vm_automation/ubuntu/tasks/post_install_zabbix.sh
Normal file
32
bolt/vm_automation/ubuntu/tasks/post_install_zabbix.sh
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Task to Install Zabbix on Ubuntu (ubuntu::post_install_zabbix)
|
||||||
|
|
||||||
|
# Download the Zabbix release package
|
||||||
|
sudo wget -O /tmp/zabbix-release.deb https://repo.zabbix.com/zabbix/7.2/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.2+ubuntu22.04_all.deb
|
||||||
|
|
||||||
|
# install the zabbix release package
|
||||||
|
sudo dpkg -i /tmp/zabbix-release.deb
|
||||||
|
|
||||||
|
# Update the package list
|
||||||
|
sudo apt update
|
||||||
|
|
||||||
|
# Install the Zabbix agent
|
||||||
|
sudo apt install -y zabbix-agent2
|
||||||
|
|
||||||
|
# Configure the Zabbix agent
|
||||||
|
sudo sed -i -e 's/^Server=127\.0\.0\.1/# Server=127.0.0.1/' -e 's/^ServerActive=127\.0\.0\.1/ServerActive=10.44.0.5,zabbix.moeny.ai/' -e 's/^LogFileSize=0/LogFileSize=1/' -e 's/^Hostname=Zabbix server/# Hostname=Zabbix server/' -e 's/^# HostnameItem=system\.hostname/HostnameItem=system.hostname/' /etc/zabbix/zabbix_agent2.conf
|
||||||
|
|
||||||
|
# Enable the Zabbix agent
|
||||||
|
sudo systemctl enable zabbix-agent2
|
||||||
|
|
||||||
|
# Start the Zabbix agent
|
||||||
|
sudo systemctl start zabbix-agent2
|
||||||
|
|
||||||
|
# Verify installation
|
||||||
|
if sudo systemctl is-active --quiet zabbix-agent2; then
|
||||||
|
echo "Zabbix agent installed and running successfully"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Zabbix agent installation failed or service is not running"
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user