-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbootstrap-linode-infra.py
executable file
·48 lines (42 loc) · 1.14 KB
/
bootstrap-linode-infra.py
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
45
46
47
48
#!/bin/python3
"""
Load linode API key from dotenv file
"""
import os
from os.path import join, dirname
from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), '../.env')
load_dotenv(dotenv_path)
LINODE_API_KEY = os.environ.get("LINODE_API_KEY")
"""
Instantiate linode API client with key
"""
from linode_api4 import LinodeClient
client = LinodeClient(LINODE_API_KEY)
"""
Print available linode types, regions, and images
"""
# ltypes = client.linode.types()
# regions = client.regions()
# images = client.images()
# for ltype in ltypes:
# print(ltype)
# for region in regions:
# print(region)
# for image in images:
# print(image)
"""
Create new nameservers
This fails if the nameservers are already created.
"""
for linode_label, linode_region in [
("ns1", "us-west"), # Fremont
("ns2", "eu-west"), # Frankfurt
]:
new_linode, _password = client.linode.instance_create(
"g6-nanode-1",
linode_region,
label=linode_label,
image="linode/centos8",
authorized_keys="~/.ssh/id_ed25519.pub")
print(f"Created {linode_label} with at {new_linode.ips.ipv4.public[0]}")