volume congifuration
This commit is contained in:
parent
8d0c4e9d30
commit
0d88cb7db4
10
clean.py
10
clean.py
@ -12,4 +12,12 @@ print(f"Usuwanie {len(servers)} serwerów")
|
||||
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}")
|
||||
print(f"Usuwanie serwera {s.data_model.name} ({s.data_model.public_net.ipv4.ip}): {action.data_model.status}")
|
||||
|
||||
volume = client.volumes.get_by_name(f"{PREFIX}-pzc-test-volume") or None
|
||||
if volume:
|
||||
print("Usuwanie wolumenu...")
|
||||
action = client.volumes.detach(volume)
|
||||
action.wait_until_finished()
|
||||
action = client.volumes.delete(volume)
|
||||
print("Usunięto wolumen")
|
@ -34,6 +34,12 @@ if not vnet:
|
||||
)
|
||||
print(f"Utworzono sieć wirtualną {vnet.data_model.name} ({vnet.data_model.ip_range})")
|
||||
|
||||
volume_name = f"{PREFIX}-pzc-test-volume"
|
||||
volume = client.volumes.get_by_name(volume_name) or None
|
||||
if not volume:
|
||||
volume = client.volumes.create(size=10, name=volume_name, location=Location("hel1"), format="ext4")
|
||||
print(f"Utworzono zasób dyskowy")
|
||||
|
||||
cloud_init_db=r'''
|
||||
#cloud-config
|
||||
# lista podstawowych pakietów, które należy zainstalować
|
||||
@ -142,7 +148,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(
|
||||
@ -150,7 +166,9 @@ gitea_server = client.servers.create(
|
||||
server_type=ServerType("cx11"),
|
||||
image=Image(name="ubuntu-20.04"),
|
||||
ssh_keys=[ssh_key],
|
||||
networks=[vnet],
|
||||
networks=[vnet],
|
||||
volumes=[volume.volume],
|
||||
automount=True,
|
||||
location=Location("hel1"),
|
||||
user_data=cloud_init_gitea
|
||||
)
|
||||
@ -159,7 +177,7 @@ 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}\n")
|
||||
print(f"http://{gitea_server.data_model.public_net.ipv4.ip}:3000")
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user