This commit is contained in:
2025-11-25 19:19:35 +01:00
parent b3e673b38f
commit 0e20b9696a
5 changed files with 101 additions and 14 deletions

View File

@@ -1 +1,2 @@
hetzner_example
hetzner_kristof1
hetzner_kristof2

View File

@@ -8,6 +8,8 @@ import time
import os
import incubaid.herolib.core.playcmds
name := 'kristof1'
user := os.environ()['HETZNER_USER'] or {
println('HETZNER_USER not set')
exit(1)
@@ -20,7 +22,7 @@ passwd := os.environ()['HETZNER_PASSWORD'] or {
hs := '
!!hetznermanager.configure
user:"${user}"
whitelist:"2111181, 2392178, 2545053, 2542166, 2550508, 2550378,2550253"
whitelist:"2521602,2555487"
password:"${passwd}"
sshkey:"kristof"
'
@@ -40,16 +42,15 @@ mut cl := hetznermanager.get()!
println(cl.servers_list()!)
// mut serverinfo := cl.server_info_get(name: 'kristof2')!
mut serverinfo := cl.server_info_get(name: 'kristof1')!
// println(serverinfo)
println(serverinfo)
// cl.server_reset(name:"kristof2",wait:true)!
// cl.server_reset(name: 'kristof2', wait: true)!
// don't forget to specify the keyname needed
// cl.server_rescue(name:"kristof2",wait:true, hero_install:true,sshkey_name:"kristof")!
// cl.server_rescue(name: 'kristof1', wait: true, hero_install: true)!
// mut ks:=cl.keys_get()!
// mut ks := cl.keys_get()!
// println(ks)
// console.print_header('SSH login')
@@ -57,12 +58,12 @@ println(cl.servers_list()!)
// mut n := b.node_new(ipaddr: serverinfo.server_ip)!
// this will put hero in debug mode on the system
// n.hero_install(compile:true)!
// n.hero_install(compile: true)!
// n.shell("")!
// n.shell('')!
// cl.ubuntu_install(name: 'kristof2', wait: true, hero_install: true)!
cl.ubuntu_install(name: name, wait: true, hero_install: true)!
// cl.ubuntu_install(name: 'kristof20', wait: true, hero_install: true)!
// cl.ubuntu_install(id:2550378, name: 'kristof21', wait: true, hero_install: true)!
// cl.ubuntu_install(id:2550508, name: 'kristof22', wait: true, hero_install: true)!
cl.ubuntu_install(id: 2550253, name: 'kristof23', wait: true, hero_install: true)!
// cl.ubuntu_install(id: 2550253, name: 'kristof23', wait: true, hero_install: true)!

View File

@@ -0,0 +1,69 @@
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import incubaid.herolib.virt.hetznermanager
import incubaid.herolib.ui.console
import incubaid.herolib.core.base
import incubaid.herolib.builder
import time
import os
import incubaid.herolib.core.playcmds
name := 'kristof2'
user := os.environ()['HETZNER_USER'] or {
println('HETZNER_USER not set')
exit(1)
}
passwd := os.environ()['HETZNER_PASSWORD'] or {
println('HETZNER_PASSWORD not set')
exit(1)
}
hs := '
!!hetznermanager.configure
user:"${user}"
whitelist:"2521602,2555487"
password:"${passwd}"
sshkey:"kristof"
'
println(hs)
playcmds.run(heroscript: hs)!
console.print_header('Hetzner Test.')
mut cl := hetznermanager.get()!
// println(cl)
// for i in 0 .. 5 {
// println('test cache, first time slow then fast')
// }
println(cl.servers_list()!)
mut serverinfo := cl.server_info_get(name: name)!
println(serverinfo)
// cl.server_reset(name: 'kristof2', wait: true)!
cl.server_rescue(name: name, wait: true, hero_install: true)!
mut ks := cl.keys_get()!
println(ks)
console.print_header('SSH login')
mut b := builder.new()!
mut n := b.node_new(ipaddr: serverinfo.server_ip)!
// this will put hero in debug mode on the system
// n.hero_install(compile: true)!
n.shell('')!
cl.ubuntu_install(name: name, wait: true, hero_install: true)!
// cl.ubuntu_install(name: 'kristof20', wait: true, hero_install: true)!
// cl.ubuntu_install(id:2550378, name: 'kristof21', wait: true, hero_install: true)!
// cl.ubuntu_install(id:2550508, name: 'kristof22', wait: true, hero_install: true)!
// cl.ubuntu_install(id: 2550253, name: 'kristof23', wait: true, hero_install: true)!

View File

@@ -1,4 +1,20 @@
## to get started
make sure you have hero_secrets loaded
```bash
hero git pull https://git.threefold.info/despiegk/hero_secrets
source ~/code/git.ourworld.tf/despiegk/hero_secrets/mysecrets.sh
```
## to e.g. install kristof 1
```
~/code/github/incubaid/herolib/examples/virt/hetzner/hetzner_kristof1.vsh
```
## hetzner info
get the login passwd from:

View File

@@ -53,7 +53,7 @@ pub fn (mut h HetznerManager) server_reset(args ServerRebootArgs) !ResetInfo {
console.print_debug('wait for server ${serverinfo.server_name} on ${serverinfo.server_ip} to go down.')
pingresult := osal.ping(address: serverinfo.server_ip)!
if !pingresult {
console.print_debug('server ${serverinfo.server_name} is now down, now waitig for reboot.')
console.print_debug('server ${serverinfo.server_name} is now down, now waiting for reboot.')
break
}
time.sleep(1000 * time.millisecond)