diff --git a/surreal/README.md b/surreal/README.md new file mode 100644 index 0000000..85e6ff1 --- /dev/null +++ b/surreal/README.md @@ -0,0 +1 @@ +# WIP diff --git a/surreal/create_vms.sh b/surreal/create_vms.sh new file mode 100755 index 0000000..e4d140e --- /dev/null +++ b/surreal/create_vms.sh @@ -0,0 +1,22 @@ +#!/bin/bash +script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $script_dir +set -e +export FORMAT=YAML +mkdir -p tmp/vms + +for vm_config in vm_configs/*; do + vm_name=$(echo $vm_config | cut -d '/' -f2 | cut -d '.' -f1) + detee-cli vm deploy --from-yaml $vm_config > tmp/vms/${vm_name}_install.yaml && + echo "The VM $vm_name got created." & +done + +wait + +for vm_config in $(grep -r uuid: tmp/vms/ | awk '{ print $2}'); do + vm_id=$(echo $vm_config | cut -d '/' -f2 | cut -d '.' -f1) + detee-cli vm inspect $vm_id > tmp/vms/${vm_id}_inspect.yaml + vm_name=$(grep 'hostname: ' tmp/vms/${vm_id}_inspect.yaml | + awk '{ print $2 }') + mv tmp/vms/${vm_id}_inspect.yaml tmp/vms/${vm_name}_inspect.yaml +done diff --git a/surreal/deploy.sh b/surreal/deploy.sh new file mode 100755 index 0000000..bf2b342 --- /dev/null +++ b/surreal/deploy.sh @@ -0,0 +1,42 @@ +#!/bin/bash +script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $script_dir +set -e +export FORMAT=YAML + +vms=() + +vm_count=0 +new_vm() { + local vm_name="$1" + local vm_id="vm$vm_count" + (( vm_count++ )) || true + + local vm_install_data="tmp/vms/${vm_name}_install.yaml" + local vm_inspect_data="tmp/vms/${vm_name}_inspect.yaml" + + vm_node_ip=$(grep 'ip: ' $vm_install_data | awk '{ print $2 }') + vm_port=$(grep 'port: ' $vm_install_data | cut -d "'" -f2) + + declare -gA "$vm_id" + eval "$vm_id[id]=$1" + eval "$vm_id[name]=$vm_name" + eval "$vm_id[port]=$vm_port" + eval "$vm_id[node_ip]=$vm_node_ip" + eval "$vm_id[private_ip]=10.254.254.$vm_count" + + vms+=("$vm_id") +} + +for vm_install_file in tmp/vms/*_install.yaml; do + vm_name=$(echo $vm_install_file | cut -d '/' -f3 | cut -d '_' -f1) + new_vm $vm_name +done + +for vm_object in "${vms[@]}"; do + declare -n vm_ref="$vm_object" + printf 'id=%s name=%s port=%s node_ip=%s private_ip=%s\n' \ + "${vm_ref[id]}" "${vm_ref[name]}" "${vm_ref[port]}" \ + "${vm_ref[node_ip]}" "${vm_ref[private_ip]}" +done + diff --git a/surreal/vm_configs/brain-1.yaml b/surreal/vm_configs/brain-1.yaml new file mode 100644 index 0000000..db577eb --- /dev/null +++ b/surreal/vm_configs/brain-1.yaml @@ -0,0 +1,10 @@ +hostname: brain-1 +hours: 700 +price: 20000 +location: + country: "FR" +ipv4: !PublishPorts [ 1337 ] +public_ipv6: false +vcpus: 4 +memory_mb: 8000 +disk_size_gb: 60 diff --git a/surreal/vm_configs/brain-2.yaml b/surreal/vm_configs/brain-2.yaml new file mode 100644 index 0000000..5f6402d --- /dev/null +++ b/surreal/vm_configs/brain-2.yaml @@ -0,0 +1,10 @@ +hostname: brain-2 +hours: 700 +price: 20000 +location: + country: "GB" +ipv4: !PublishPorts [ 1337 ] +public_ipv6: false +vcpus: 4 +memory_mb: 8000 +disk_size_gb: 60 diff --git a/surreal/vm_configs/brain-3.yaml b/surreal/vm_configs/brain-3.yaml new file mode 100644 index 0000000..6c92e86 --- /dev/null +++ b/surreal/vm_configs/brain-3.yaml @@ -0,0 +1,10 @@ +hostname: brain-3 +hours: 700 +price: 20000 +location: + country: "US" +ipv4: !PublishPorts [ 1337 ] +public_ipv6: false +vcpus: 4 +memory_mb: 8000 +disk_size_gb: 60 diff --git a/surreal/vm_configs/brain-bastion.yaml b/surreal/vm_configs/brain-bastion.yaml new file mode 100644 index 0000000..bc2e74a --- /dev/null +++ b/surreal/vm_configs/brain-bastion.yaml @@ -0,0 +1,10 @@ +hostname: brain-bastion +hours: 700 +price: 20000 +location: + country: "FR" +ipv4: !PublishPorts [ 1337 ] +public_ipv6: false +vcpus: 4 +memory_mb: 8000 +disk_size_gb: 60 diff --git a/surreal/vm_configs/brain-mon.yaml b/surreal/vm_configs/brain-mon.yaml new file mode 100644 index 0000000..6c5bde4 --- /dev/null +++ b/surreal/vm_configs/brain-mon.yaml @@ -0,0 +1,10 @@ +hostname: brain-mon +hours: 700 +price: 20000 +location: + country: "US" +ipv4: !PublishPorts [ 1337 ] +public_ipv6: false +vcpus: 4 +memory_mb: 8000 +disk_size_gb: 60