added k3s install
This commit is contained in:
parent
6eabd40021
commit
698e67d8c0
3 changed files with 142 additions and 56 deletions
|
|
@ -70,18 +70,17 @@ echo "Network information gathered successfully."
|
|||
|
||||
# get vagrant ports
|
||||
echo "Gathering Vagrant port information..."
|
||||
# vagrant ssh-config | grep Port | while read -r line; do
|
||||
# echo "Processing line: $line"
|
||||
|
||||
# # Processing line: Port 2222
|
||||
# # Processing line: Port 2200
|
||||
# # Processing line: Port 2201
|
||||
|
||||
|
||||
# port=$(echo "$line" | awk '{print $2}')
|
||||
# echo "Extracted port: $port"
|
||||
# vagrant_ports+=("$port")
|
||||
# done
|
||||
while read -r line; do
|
||||
echo "Processing line: $line"
|
||||
|
||||
# Extract the port number
|
||||
port=$(echo "$line" | awk '{print $2}')
|
||||
echo "Extracted port: $port"
|
||||
vagrant_ports+=("$port")
|
||||
done < <(vagrant ssh-config | grep Port)
|
||||
|
||||
|
||||
|
||||
while read -r line; do
|
||||
|
|
@ -108,21 +107,6 @@ for port in "${vagrant_ports[@]}"; do
|
|||
echo "Port: $port"
|
||||
done
|
||||
|
||||
# create an ansible inventory file
|
||||
# [all]
|
||||
# vm1 ansible_host=<vm1_ip> ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/vm1/virtualbox/private_key
|
||||
# vm2 ansible_host=<vm2_ip> ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/vm2/virtualbox/private_key
|
||||
# vm3 ansible_host=<vm3_ip> ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/vm3/virtualbox/private_key
|
||||
|
||||
# echo "Creating Ansible inventory file..."
|
||||
# inventory_file="$SCRIPT_DIR/ansible_inventory.ini"
|
||||
# echo "[all]" > "$inventory_file"
|
||||
# i=0
|
||||
# for vm in $running_vms; do
|
||||
# port="${vagrant_ports[$i]}"
|
||||
# echo "$vm ansible_host=127.0.0.1 ansible_port=$port ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/$vm/virtualbox/private_key" >> "$inventory_file"
|
||||
# ((i++))
|
||||
# done
|
||||
echo "Creating Ansible inventory file..."
|
||||
inventory_file="$SCRIPT_DIR/ansible_inventory.ini"
|
||||
echo "[all]" > "$inventory_file"
|
||||
|
|
@ -134,9 +118,6 @@ for vm in $running_vms; do
|
|||
done
|
||||
|
||||
echo "" >> "$inventory_file"
|
||||
# echo "[children]" >> "$inventory_file"
|
||||
# echo "vm_group" >> "$inventory_file"
|
||||
# echo "" >> "$inventory_file"
|
||||
echo "[vms]" >> "$inventory_file"
|
||||
for vm in $running_vms; do
|
||||
echo $vm >> "$inventory_file"
|
||||
|
|
@ -163,4 +144,18 @@ if [ $? -ne 0 ]; then
|
|||
fi
|
||||
|
||||
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook ../../../ansible/install_keepalived.yaml --inventory-file ../../../scripts/ansible_inventory.ini | cat
|
||||
# exit if error from playbook
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Ansible playbook failed. Please check your Vagrant VMs and network configuration."
|
||||
exit 1
|
||||
fi
|
||||
echo "Keepalived installation completed successfully."
|
||||
|
||||
|
||||
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook ../../../ansible/install_k3s_3node.yaml --inventory-file ../../../scripts/ansible_inventory.ini | cat
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Ansible playbook failed. Please check your Vagrant VMs and network configuration."
|
||||
exit 1
|
||||
fi
|
||||
echo "K3s installation completed successfully."
|
||||
Loading…
Add table
Add a link
Reference in a new issue