diff options
| author | EnricoGuccii <partyka.003@proton.me> | 2026-06-01 00:56:16 +0200 |
|---|---|---|
| committer | EnricoGuccii <partyka.003@proton.me> | 2026-06-01 00:56:16 +0200 |
| commit | fd503278ae598006fae9687f7d9a695ab6996af2 (patch) | |
| tree | 49b57ce61fcbfede350c4a8c7bfab7b4f361fd46 /terraform/main.tf | |
| parent | 1b883498b31c06447e122430f5c7d2786dd8cedf (diff) | |
ansible and terraform integration
Diffstat (limited to 'terraform/main.tf')
| -rw-r--r-- | terraform/main.tf | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/terraform/main.tf b/terraform/main.tf index fc36c8b..9977fb4 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -27,10 +27,15 @@ resource "proxmox_virtual_environment_container" "lxc01" { started = true + wait_for_ip { + ipv4 = true + } + operating_system { template_file_id = "local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst" } + cpu { cores = var.lxc_cores } @@ -48,13 +53,37 @@ resource "proxmox_virtual_environment_container" "lxc01" { network_interface { name = "eth0" bridge = "vmbr0" + } initialization { hostname = var.lxc_name + ip_config { + ipv4 { + address = "dhcp" + } + } + user_account { - password = "Password123!" + keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHB4jD3PVsg1edlMwBW6Hb/NYLnzEI8dyJQRnQQap45q enrico@cachyos" + ] } } } + + +resource "local_file" "ansible_inventory" { + content = <<-EOT + [lxc] + ${try(proxmox_virtual_environment_container.lxc01.ipv4["eth0"], "Brak_IP")} ansible_user=root ansible_ssh_common_args='-o StrictHostKeyChecking=no' + EOT + + filename = "${path.module}/../ansible/inventory.ini" +} + +output "aktualne_ip_kontenera" { + description = "Adres IP pobrany przez Terraforma" + value = try(proxmox_virtual_environment_container.lxc01.ipv4["eth0"], "Proxmox jeszcze nie zaraportowaĆ IP!") +} |