blob: ac599cd3a4cf875095548ad153ec3f1ca9d9ba0e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
# SPDX-License-Identifier: MIT
{ pkgs ? import <nixpkgs> {} }:
let
inherit (pkgs) lib;
ipxe = import ./ipxe.nix {};
in
pkgs.writeShellScript "spectrum-infra-run-vultr" ''
set -ue
script_id="$(jq -n '{
name: "spectrum-infra-boot",
type: "pxe",
script: $script | @base64,
}' --arg script ${lib.escapeShellArg ipxe} |
curl -fvL https://api.vultr.com/v2/startup-scripts \
-H "Authorization: Bearer $vultr_key" \
-H "Content-Type: application/json" \
--data-binary @- |
jq -r .startup_script.id)"
for region in fra ams cdg mad sto waw; do
jq -n '{
region: $region,
plan: "voc-g-16c-64gb-320s-amd",
os_id: 159,
script_id: $script_id,
user_data: $user_data | @base64,
enable_ipv6: true,
persistent_pxe: true,
}' \
--arg region "$region" \
--arg script_id "$script_id" \
--arg user_data "$(< user-data)" |
curl -fiL https://api.vultr.com/v2/instances \
-H "Authorization: Bearer $vultr_key" \
-H "Content-Type: application/json" \
--data-binary @- && break
done
''
|