update: enhance Vagrant setup with new scripts for node and workstation installation, and update provisioning to target specific VMs
This commit is contained in:
parent
5f448d7fc7
commit
aa912d55df
6 changed files with 79 additions and 23 deletions
17
README.md
17
README.md
|
|
@ -122,6 +122,8 @@ cp pipeline.json.example pipeline.json
|
||||||
|
|
||||||
# Run with pipeline file
|
# Run with pipeline file
|
||||||
./infctl-cli --deployment-file pipeline.json
|
./infctl-cli --deployment-file pipeline.json
|
||||||
|
# or using the short format
|
||||||
|
./infctl-cli -f pipeline.json--deployment-file
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
@ -178,6 +180,8 @@ Run the CLI by providing a path to your pipeline JSON file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./infctl-cli --deployment-file /path/to/pipeline.json
|
./infctl-cli --deployment-file /path/to/pipeline.json
|
||||||
|
# or using the short format
|
||||||
|
./infctl-cli -f /path/to/pipeline.json
|
||||||
```
|
```
|
||||||
|
|
||||||
The tool will automatically:
|
The tool will automatically:
|
||||||
|
|
@ -187,13 +191,20 @@ The tool will automatically:
|
||||||
3. Execute the deployment pipeline defined in your JSON file
|
3. Execute the deployment pipeline defined in your JSON file
|
||||||
4. Run scripts from the `scripts/` directory
|
4. Run scripts from the `scripts/` directory
|
||||||
5. Apply Kubernetes manifests using kustomize (for K8s deployments)
|
5. Apply Kubernetes manifests using kustomize (for K8s deployments)
|
||||||
|
--deployment-file
|
||||||
|
### Command Line Options
|
||||||
|
|
||||||
|
- `--deployment-file <path>` or `-f <path>`: Path to the pipeline JSON configuration file
|
||||||
|
- `--help`: Show help message and usage information
|
||||||
|
|
||||||
### Running from Source
|
### Running from Source
|
||||||
|
|
||||||
You can also run directly with Go:
|
You can also run directly with Go:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go run main.go -pipeline /path/to/pipeline.json
|
go run main.go --deployment-file /path/to/pipeline.json
|
||||||
|
# or using the short format
|
||||||
|
go run main.go -f /path/to/pipeline.json
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running Tests
|
### Running Tests
|
||||||
|
|
@ -317,14 +328,14 @@ The CLI uses structured JSON logging. Debug logs are enabled by default and incl
|
||||||
|
|
||||||
1. Place shell scripts / executables in the `scripts/` directory
|
1. Place shell scripts / executables in the `scripts/` directory
|
||||||
2. Add confiiguration as appropriate into `pipeline.json`
|
2. Add confiiguration as appropriate into `pipeline.json`
|
||||||
3. Re-run `cnfctl --deployment-file pipeline.json`
|
3. Re-run `infctl-cli --deployment-file pipeline.json` or `infctl-cli -f pipeline.json`
|
||||||
|
|
||||||
### Adding New Manifests
|
### Adding New Manifests
|
||||||
|
|
||||||
1. Create Kubernetes YAML files in the appropriate `k8s-manifests/` subdirectory
|
1. Create Kubernetes YAML files in the appropriate `k8s-manifests/` subdirectory
|
||||||
2. Include a `kustomization.yaml` file for kustomize processing
|
2. Include a `kustomization.yaml` file for kustomize processing
|
||||||
3. Add confiiguration as appropriate into `pipeline.json`
|
3. Add confiiguration as appropriate into `pipeline.json`
|
||||||
4. Re-run `cnfctl --deployment-file pipeline.json`
|
4. Re-run `infctl-cli --deployment-file pipeline.json` or `infctl-cli -f pipeline.json`
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,31 @@
|
||||||
[
|
[
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "pre-requisties",
|
"name": "Create Vagrant nodes",
|
||||||
"function": "RunCommand",
|
"function": "RunCommand",
|
||||||
"params": [
|
"params": [
|
||||||
"./scripts/vagrant_check_prerequisites.sh"
|
"./scripts/install_vagrant_nodes.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Configure Vagrant K3s",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./scripts/configure_vagrant_k3s.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Create Vagrant workstation",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./scripts/install_vagrant_workstation.sh"
|
||||||
],
|
],
|
||||||
"retryCount": 0,
|
"retryCount": 0,
|
||||||
"shouldAbort": true
|
"shouldAbort": true
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# This script checks for Vagrant and VirtualBox prerequisites, ensures Vagrant VMs are running, and gathers network and system information from the VMs.
|
# set -euo pipefail
|
||||||
|
|
||||||
|
# This script checks for Vagrant and VirtualBox prerequisites,
|
||||||
|
# ensures Vagrant VMs are running, and gathers network and
|
||||||
|
# system information from the VMs.
|
||||||
|
|
||||||
echo "Checking Vagrant prerequisites..."
|
echo "Checking Vagrant prerequisites..."
|
||||||
# Check if Vagrant is installed
|
# Check if Vagrant is installed
|
||||||
|
|
@ -20,8 +24,6 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
echo "Script directory: $SCRIPT_DIR"
|
echo "Script directory: $SCRIPT_DIR"
|
||||||
|
|
||||||
|
|
@ -39,8 +41,6 @@ if [ -z "$(vagrant status | grep 'running')" ]; then
|
||||||
vagrant up
|
vagrant up
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
network_info=()
|
network_info=()
|
||||||
vagrant_ports=()
|
vagrant_ports=()
|
||||||
|
|
||||||
|
|
@ -50,12 +50,11 @@ running_vms=$(vagrant status | grep "running" | awk '{print $1}')
|
||||||
for vm in $running_vms; do
|
for vm in $running_vms; do
|
||||||
|
|
||||||
# Check network interfaces and get specific IPs
|
# Check network interfaces and get specific IPs
|
||||||
vm_ips=$(vagrant ssh "$vm" -c "ip -j addr" | jq -r '.[] |
|
vm_ips=$(vagrant ssh "$vm" -c "ip -j addr | jq -r '.[] |
|
||||||
select(.addr_info != null) |
|
select(.ifname==\"enp0s8\") |
|
||||||
.addr_info[] |
|
.addr_info[] |
|
||||||
select(.family == "inet" and (.local | startswith("'${VAGRANT_NETWORK_PREFIX:-192.168.56}'."))) |
|
select(.family==\"inet\" and .scope==\"global\" and .prefixlen<32 and .local!=\"'${VAGRANT_NETWORK_PREFIX:-192.168.56.250}'\") |
|
||||||
.local')
|
.local'")
|
||||||
|
|
||||||
|
|
||||||
# Save the VM's IP to the array if it matches our pattern
|
# Save the VM's IP to the array if it matches our pattern
|
||||||
if [ ! -z "$vm_ips" ]; then
|
if [ ! -z "$vm_ips" ]; then
|
||||||
|
|
@ -74,11 +73,6 @@ done
|
||||||
|
|
||||||
echo "Network information gathered successfully."
|
echo "Network information gathered successfully."
|
||||||
|
|
||||||
|
|
||||||
# get vagrant ports
|
|
||||||
# echo "Gathering Vagrant port information..."
|
|
||||||
|
|
||||||
|
|
||||||
# Ensure unique ports are added to the vagrant_ports array
|
# Ensure unique ports are added to the vagrant_ports array
|
||||||
add_unique_port() {
|
add_unique_port() {
|
||||||
local port=$1
|
local port=$1
|
||||||
|
|
@ -97,13 +91,11 @@ while read -r line; do
|
||||||
done < <(vagrant ssh-config | grep Port)
|
done < <(vagrant ssh-config | grep Port)
|
||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
|
|
||||||
# Extract the port number
|
# Extract the port number
|
||||||
port=$(echo "$line" | awk '{print $2}')
|
port=$(echo "$line" | awk '{print $2}')
|
||||||
add_unique_port "$port"
|
add_unique_port "$port"
|
||||||
done < <(vagrant ssh-config | grep Port)
|
done < <(vagrant ssh-config | grep Port)
|
||||||
|
|
||||||
|
|
||||||
ips=()
|
ips=()
|
||||||
# Print network information
|
# Print network information
|
||||||
for info in "${network_info[@]}"; do
|
for info in "${network_info[@]}"; do
|
||||||
|
|
|
||||||
17
scripts/install_vagrant_nodes.sh
Executable file
17
scripts/install_vagrant_nodes.sh
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
VAGRANT_DIR="$SCRIPT_DIR/../vagrant/dev/ubuntu/"
|
||||||
|
|
||||||
|
echo "Script directory: $SCRIPT_DIR"
|
||||||
|
echo "Vagrant directory: $VAGRANT_DIR"
|
||||||
|
cd "$VAGRANT_DIR" || {
|
||||||
|
echo "Failed to change directory to Vagrant directory: $VAGRANT_DIR"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
vagrant up vm1 vm2 vm3
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to start Vagrant VMs. Please check your Vagrant setup."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
14
scripts/install_vagrant_workstation.sh
Executable file
14
scripts/install_vagrant_workstation.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
VAGRANT_DIR="$SCRIPT_DIR/../vagrant/dev/ubuntu/"
|
||||||
|
|
||||||
|
echo "Script directory: $SCRIPT_DIR"
|
||||||
|
echo "Vagrant directory: $VAGRANT_DIR"
|
||||||
|
cd "$VAGRANT_DIR" || {
|
||||||
|
echo "Failed to change directory to Vagrant directory: $VAGRANT_DIR"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vagrant up workstation
|
||||||
|
|
@ -103,7 +103,7 @@ else
|
||||||
echo "Provisioning block already present in $BASHRC"
|
echo "Provisioning block already present in $BASHRC"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ANSIBLE_HOST_KEY_CHECKING=False ansible --inventory-file /home/vagrant/ansible/ansible_inventory.ini -m ping all
|
ANSIBLE_HOST_KEY_CHECKING=False ansible --inventory-file /home/vagrant/ansible/ansible_inventory.ini -m ping vm1,vm2,vm3
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Ansible ping failed. Please check your Vagrant VMs and network configuration."
|
echo "Ansible ping failed. Please check your Vagrant VMs and network configuration."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue