diff options
| author | jerome <jerome@xlinfo.fr> | 2025-03-25 12:31:24 +0100 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2025-03-25 12:31:24 +0100 |
| commit | 74bdaf49a5b05666d2199138a294bbc95e348c02 (patch) | |
| tree | 3cc992b220e2a69f2b45dfb426c9ec14b02018f3 | |
| parent | 99ca6914e93b47d46c7a30ce4605c3c8acaba3da (diff) | |
| download | proxmox_lxc-74bdaf49a5b05666d2199138a294bbc95e348c02.tar.gz proxmox_lxc-74bdaf49a5b05666d2199138a294bbc95e348c02.zip | |
bastion SSH
| -rw-r--r-- | container/main.tf | 19 | ||||
| -rwxr-xr-x | local_script | 4 |
2 files changed, 13 insertions, 10 deletions
diff --git a/container/main.tf b/container/main.tf index f20d671..1f0933d 100644 --- a/container/main.tf +++ b/container/main.tf @@ -40,18 +40,26 @@ resource "proxmox_lxc" "stagiaire" { network { name = "eth0" bridge = "vmbr0" - ip = "192.168.2.${var.vmid}/24" - gw = "192.168.2.254" + ip = "192.168.10.${var.vmid}/24" + tag = "10" + gw = "192.168.10.1" } + nameserver = "8.8.8.8" features { nesting = true } + provisioner "local-exec" { + command = "./local_script 192.168.10.${var.vmid}" + } + provisioner "remote-exec" { connection { type = "ssh" - host = "192.168.2.${var.vmid}" + host = "192.168.10.${var.vmid}" + bastion_host = "pve.xlinfo.fr" + bastion_user = "stagiaire" user = "root" private_key = file("~/.ssh/id_rsa") timeout = "5m" @@ -60,9 +68,4 @@ resource "proxmox_lxc" "stagiaire" { "touch terraform_ok" ] } - - provisioner "local-exec" { - command = "./local_script 192.168.2.${var.vmid}" - } - } diff --git a/local_script b/local_script index 3994e4f..e48ed99 100755 --- a/local_script +++ b/local_script @@ -1,3 +1,3 @@ #!/bin/bash -ssh-keygen -f ~/.ssh/known_hosts -R $1 -ssh-keyscan -H $1 >> ~/.ssh/known_hosts +ssh-keygen -f ~/.ssh/known_hosts -R $1 || true +ssh-keyscan -H $1 >> ~/.ssh/known_hosts || true |
