Added zabbix-agent2 installs - WIP: Similarity to runlines switches
This commit is contained in:
parent
9a72f07ec7
commit
ac8d294a09
16
README.md
16
README.md
@ -124,8 +124,8 @@ cd bolt_vm_automation
|
||||
bolt plan run bolt_vm_automation::create_ubuntu \
|
||||
target=vortex \
|
||||
vm_name=moeny-bank01 \
|
||||
ip_with_cidr=100.40.223.189/24 \
|
||||
hostname=moeny-bank01
|
||||
ip_with_cidr=100.40.223.189/24 \
|
||||
```
|
||||
|
||||
## Alpine VMs
|
||||
@ -137,8 +137,8 @@ Below is a sample command to run the Alpine bolt plan.
|
||||
```bash
|
||||
bolt plan run bolt_vm_automation::create_alpine \
|
||||
vm_name=moeny-service \
|
||||
ip_with_cidr=100.40.223.189/24 \
|
||||
hostname=moeny-service \
|
||||
ip_with_cidr=100.40.223.189/24 \
|
||||
add_a_record_bool=true \
|
||||
dns_hostname=service
|
||||
```
|
||||
@ -181,12 +181,12 @@ In order to spin up VMs on an internal network, you will need to generate an Alp
|
||||
```bash
|
||||
bolt plan run bolt_vm_automation::create_alpine \
|
||||
vm_name=moeny-service-alpine \
|
||||
ip_with_cidr=10.44.0.20/24 \
|
||||
hostname=moeny-service-alpine \
|
||||
network=internal-moeny \
|
||||
staging_ip=10.44.0.250 \
|
||||
ip_with_cidr=10.44.0.20/24 \
|
||||
gateway_ip=10.44.0.1 \
|
||||
iso_path=/mnt/nfs/kvm-isos/iso-build/alpine-autoinstall-internal_moeny.iso -v
|
||||
iso_path=/mnt/nfs/kvm-isos/iso-build/alpine-autoinstall-internal_moeny.iso \
|
||||
staging_ip=10.44.0.250 -v
|
||||
```
|
||||
|
||||
Similarly, a new Ubuntu iso will need to be generated that is compatible with the internal IPs. This can be done by simply updating the `user-data` file from Step 6 to have the proper network configuration, as in [`user-data-internal`](user-data-internal.yaml). Here is a sample command to run the Ubuntu bolt plan.
|
||||
@ -194,10 +194,10 @@ Similarly, a new Ubuntu iso will need to be generated that is compatible with th
|
||||
```bash
|
||||
bolt plan run bolt_vm_automation::create_ubuntu \
|
||||
vm_name=moeny-service-ubuntu \
|
||||
ip_with_cidr=10.44.0.20/24 \
|
||||
hostname=moeny-service-ubuntu \
|
||||
network=internal-moeny \
|
||||
gateway=10.44.0.1 \
|
||||
ip_with_cidr=10.44.0.20/24 \
|
||||
gateway_ip=10.44.0.1 \
|
||||
iso_path=/mnt/nfs/kvm-isos/iso-build/ubuntu-22.04-autoinstall-internal_moeny.iso \
|
||||
vm_target=vm-template-internal -v
|
||||
staging_ip=10.44.0.250 -v
|
||||
```
|
@ -19,11 +19,11 @@ groups:
|
||||
private-key: ~/.ssh/DMMF-20211104
|
||||
host-key-check: false
|
||||
targets:
|
||||
- name: vm-template-public
|
||||
- name: public
|
||||
config:
|
||||
ssh:
|
||||
host: 100.40.223.190
|
||||
- name: vm-template-internal
|
||||
- name: internal
|
||||
config:
|
||||
ssh:
|
||||
host: 10.44.0.250
|
||||
|
@ -1,9 +1,13 @@
|
||||
---
|
||||
parameters:
|
||||
target:
|
||||
target_host:
|
||||
type: String
|
||||
description: "Target host to create the VM on"
|
||||
default: "vortex"
|
||||
target_vm:
|
||||
type: String
|
||||
description: "Target VM for post-installation tasks"
|
||||
default: $vm_name
|
||||
iso_path:
|
||||
type: String
|
||||
description: "Path to the ISO file"
|
||||
@ -88,7 +92,7 @@ parameters:
|
||||
steps:
|
||||
- name: create_vm
|
||||
task: bolt_vm_automation::create_alpine
|
||||
targets: $target
|
||||
targets: $target_host
|
||||
parameters:
|
||||
iso_path: $iso_path
|
||||
vm_name: $vm_name
|
||||
@ -116,6 +120,13 @@ steps:
|
||||
parameters:
|
||||
staging_ip: $staging_ip
|
||||
|
||||
- name: install_zabbix
|
||||
description: Install Zabbix on the VM
|
||||
task: bolt_vm_automation::install_zabbix_alpine
|
||||
targets: localhost
|
||||
parameters:
|
||||
staging_ip: $staging_ip
|
||||
|
||||
- name: install_docker
|
||||
description: Install Docker on the VM
|
||||
task: bolt_vm_automation::install_docker_alpine
|
||||
|
@ -1,13 +1,13 @@
|
||||
---
|
||||
parameters:
|
||||
target:
|
||||
target_host:
|
||||
type: String
|
||||
description: "Target host to create the VM on"
|
||||
default: "vortex"
|
||||
vm_target:
|
||||
staging_ip:
|
||||
type: String
|
||||
description: "Target VM for post-installation tasks"
|
||||
default: "vm-template-public"
|
||||
description: "IP address of the target VM for post-installation tasks"
|
||||
default: "public"
|
||||
iso_path:
|
||||
type: String
|
||||
description: "Path to the ISO file"
|
||||
@ -52,9 +52,9 @@ parameters:
|
||||
type: Boolean
|
||||
description: "Enable DHCP on the VM"
|
||||
default: false
|
||||
gateway:
|
||||
gateway_ip:
|
||||
type: String
|
||||
description: "Gateway for the VM"
|
||||
description: "Gateway IP for the VM"
|
||||
default: "100.40.223.1"
|
||||
nameserver1:
|
||||
type: String
|
||||
@ -79,7 +79,7 @@ steps:
|
||||
|
||||
- name: create_vm
|
||||
task: bolt_vm_automation::create_ubuntu
|
||||
targets: $target
|
||||
targets: $target_host
|
||||
parameters:
|
||||
iso_path: $iso_path
|
||||
vm_name: $vm_name
|
||||
@ -90,19 +90,24 @@ steps:
|
||||
network: $network
|
||||
os_variant: $os_variant
|
||||
|
||||
- name: install_zabbix
|
||||
description: Install Zabbix on the VM
|
||||
task: bolt_vm_automation::install_zabbix_ubuntu
|
||||
targets: $staging_ip
|
||||
|
||||
- name: install_docker
|
||||
description: Install Docker on the VM
|
||||
task: bolt_vm_automation::install_docker_ubuntu
|
||||
targets: $vm_target
|
||||
targets: $staging_ip
|
||||
|
||||
- name: system_setup
|
||||
task: bolt_vm_automation::system_setup_ubuntu
|
||||
targets: $vm_target
|
||||
targets: $staging_ip
|
||||
parameters:
|
||||
ip_with_cidr: $ip_with_cidr
|
||||
hostname: $hostname
|
||||
dhcp: $dhcp
|
||||
gateway: $gateway
|
||||
gateway_ip: $gateway_ip
|
||||
nameserver1: $nameserver1
|
||||
nameserver2: $nameserver2
|
||||
nameserver3: $nameserver3
|
||||
|
26
bolt_vm_automation/tasks/install_zabbix_alpine.sh
Normal file
26
bolt_vm_automation/tasks/install_zabbix_alpine.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Input Variables
|
||||
STAGING_IP="${PT_staging_ip}"
|
||||
|
||||
# Install zabbix-agent2
|
||||
ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "apk add zabbix-agent2"
|
||||
|
||||
# Configure zabbix-agent2
|
||||
ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "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"
|
||||
|
||||
# Add zabbix-agent2 to default runlevel
|
||||
ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "rc-update add zabbix-agent2 default"
|
||||
|
||||
# Start zabbix-agent2
|
||||
ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "rc-service zabbix-agent2 start"
|
||||
|
||||
# Verify installation
|
||||
status_output=$(ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "rc-service zabbix-agent2 status")
|
||||
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 installation failed", "output": "'"$status_output"'"}'
|
||||
exit 1
|
||||
fi
|
31
bolt_vm_automation/tasks/install_zabbix_ubuntu.sh
Normal file
31
bolt_vm_automation/tasks/install_zabbix_ubuntu.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 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
|
@ -21,7 +21,6 @@ ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "apk add --no-cache iptables"
|
||||
|
||||
# Configure iptables rules
|
||||
ssh -o StrictHostKeyChecking=no root@${STAGING_IP} "iptables -A INPUT -p tcp --dport 22 -s 100.40.223.128/26 -j ACCEPT && \
|
||||
iptables -A INPUT -p tcp --dport 22 -s 173.62.109.73/32 -j ACCEPT && \
|
||||
iptables -A INPUT -p tcp --dport 22 -s 10.0.0.0/8 -j ACCEPT && \
|
||||
iptables -A INPUT -p tcp --dport 22 -j DROP"
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"description": "Whether to use DHCP for network configuration",
|
||||
"default": false
|
||||
},
|
||||
"gateway": {
|
||||
"gateway_ip": {
|
||||
"type": "String",
|
||||
"description": "Gateway IP address",
|
||||
"default": "100.40.223.1"
|
||||
|
@ -4,7 +4,7 @@
|
||||
IP="${PT_ip_with_cidr}"
|
||||
HOSTNAME="${PT_hostname}"
|
||||
DHCP="${PT_dhcp}"
|
||||
GATEWAY="${PT_gateway}"
|
||||
GATEWAY="${PT_gateway_ip}"
|
||||
NAMESERVER1="${PT_nameserver1}"
|
||||
NAMESERVER2="${PT_nameserver2}"
|
||||
NAMESERVER3="${PT_nameserver3}"
|
||||
|
Loading…
Reference in New Issue
Block a user