Add volume
This commit is contained in:
parent
abae99ebd5
commit
d5a7592258
9
clean.py
9
clean.py
@ -13,3 +13,12 @@ for s in servers:
|
||||
if s.data_model.name.startswith(PREFIX):
|
||||
action = client.servers.delete(s)
|
||||
print(f"Usuwanie serwera {s.data_model.name} ({s.data_model.public_net.ipv4.ip}): {action.data_model.status}")
|
||||
|
||||
volumes = client.volumes.get_all()
|
||||
print(f"Usuwanie {len(volumes)} wolumenów")
|
||||
for v in volumes:
|
||||
if s.data_model.name.startswith(PREFIX):
|
||||
action = client.volumes.detach(v)
|
||||
action.wait_until_finished()
|
||||
action = client.volumes.delete(v)
|
||||
print(f"\tUsuwanie wolumenu {v.name}: {action}")
|
@ -33,6 +33,12 @@ if not vnet:
|
||||
)
|
||||
print(f"Utworzono sieć wirtualną {vnet.data_model.name} ({vnet.data_model.ip_range})")
|
||||
|
||||
volume_name = f"{PREFIX}-volume"
|
||||
volume = client.volumes.create(
|
||||
name=volume_name, size=10, format="ext4", location=Location("hel1")
|
||||
)
|
||||
print("successfully CREATED")
|
||||
|
||||
cloud_init_db=r'''
|
||||
#cloud-config
|
||||
# lista podstawowych pakietów, które należy zainstalować
|
||||
@ -140,7 +146,17 @@ runcmd:
|
||||
- chmod +x /usr/local/bin/docker-compose
|
||||
- systemctl start docker
|
||||
- systemctl enable docker
|
||||
- cd /root/ && docker-compose up -d
|
||||
- cd /root/
|
||||
- IP=$(hostname -I | cut -d ' ' -f 1)
|
||||
- echo "DOMAIN=$IP" >> .env
|
||||
- sudo mkfs.ext4 -F /dev/disk/by-id/scsi-0HC_Volume_{volume.volume.id}
|
||||
- mkdir /mnt/{volume_name}
|
||||
- mount -o discard,defaults /dev/disk/by-id/scsi-0HC_Volume_{volume.volume.id} /mnt/{volume_name}
|
||||
- echo "/dev/disk/by-id/scsi-0HC_Volume_{volume.volume.id} /mnt/{volume_name} ext4 discard,nofail,defaults 0 0" >> /etc/fstab
|
||||
- mkdir /mnt/{volume_name}/data
|
||||
- mkdir /mnt/{volume_name}/config
|
||||
- sudo chown 1000:1000 /mnt/{volume_name}/config/ /mnt/{volume_name}/data
|
||||
- docker-compose up -d
|
||||
'''
|
||||
|
||||
gitea_server = client.servers.create(
|
||||
@ -149,6 +165,8 @@ gitea_server = client.servers.create(
|
||||
image=Image(name="ubuntu-20.04"),
|
||||
ssh_keys=[ssh_key],
|
||||
networks=[vnet],
|
||||
volumes=[volume.volume],
|
||||
automount=True,
|
||||
location=Location("hel1"),
|
||||
user_data=cloud_init_gitea
|
||||
)
|
||||
@ -157,4 +175,4 @@ gitea_server.action.wait_until_finished()
|
||||
print(f"Tworzenie serwera gitea: {gitea_server.action.complete}")
|
||||
|
||||
gitea_server = client.servers.get_by_name(f"{PREFIX}-gitea")
|
||||
print(f"Serwer: {gitea_server.data_model.name}\n\tpubliczne IP: {gitea_server.data_model.public_net.ipv4.ip}\n\tprywatne IP: {gitea_server.data_model.private_net[0].ip}")
|
||||
print(f"Serwer: {gitea_server.data_model.name}\n\tpubliczne IP: {gitea_server.data_model.public_net.ipv4.ip}")
|
Loading…
Reference in New Issue
Block a user