mirror of
https://github.com/FAUSheppy/athq-vm-management
synced 2025-12-06 13:51:35 +01:00
feat: auto add ssh forward ports
This commit is contained in:
2
main.py
2
main.py
@@ -43,6 +43,8 @@ if __name__ == "__main__":
|
||||
with open("/etc/nginx/stream_include.conf", "w") as f:
|
||||
for vmo in vmList:
|
||||
[ f.write(c) for c in vmo.dumpStreamComponents()]
|
||||
for vmo in set(vmList):
|
||||
[ f.write(c) for c in vmo.dumpSshFowardsNginx()]
|
||||
|
||||
with open("/etc/nginx/http_include.conf", "w") as f:
|
||||
for vmo in vmList:
|
||||
|
||||
16
vm.py
16
vm.py
@@ -16,6 +16,7 @@ class VM:
|
||||
self.isExternal = args.get("external")
|
||||
self.noTerminateACME = args.get("no-terminate-acme")
|
||||
self.ansible = not args.get("noansible")
|
||||
self.sshOutsidePort = None
|
||||
|
||||
if self.isExternal:
|
||||
self.lease = None
|
||||
@@ -74,6 +75,21 @@ class VM:
|
||||
|
||||
return components
|
||||
|
||||
def dumpSshFowardsNginx(self):
|
||||
|
||||
components = []
|
||||
template = self.environment.get_template("nginx_stream_block.conf.j2")
|
||||
if not self.isExternal:
|
||||
self.sshOutsidePort = 7000 + int(self.ip.split(".")[-1])
|
||||
component = template.render(targetip=self.ip, udp=False,
|
||||
portstring=self.sshOutsidePort,
|
||||
targetportoverwrite=7000,
|
||||
transparent=False, proxy_timeout="24h",
|
||||
comment="ssh-{}".format(self.hostname))
|
||||
components.append(component)
|
||||
|
||||
return components
|
||||
|
||||
def dumpIptables(self, remove=False):
|
||||
|
||||
entries = []
|
||||
|
||||
Reference in New Issue
Block a user