diff options
| author | jerome <jerome@xlinfo.fr> | 2025-01-27 17:58:42 +0100 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2025-01-27 17:58:42 +0100 |
| commit | 7d7637cb926d7c8f3469ce830a4b90e203bb4a1b (patch) | |
| tree | fdd42f3f547e2b997fb3fbe5a91a5a12c1b5d85a /container/main.tf | |
| parent | fbf6b72eb6c47df90ffb2509c2cdff49a2d4a7ad (diff) | |
| download | proxmox_lxc-7d7637cb926d7c8f3469ce830a4b90e203bb4a1b.tar.gz proxmox_lxc-7d7637cb926d7c8f3469ce830a4b90e203bb4a1b.zip | |
modules
Diffstat (limited to 'container/main.tf')
| -rw-r--r-- | container/main.tf | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/container/main.tf b/container/main.tf new file mode 100644 index 0000000..c185c4e --- /dev/null +++ b/container/main.tf @@ -0,0 +1,64 @@ +terraform { + required_providers { + proxmox = { + source = "telmate/proxmox" + #version = "3.0.1-rc6" + version = "2.9.14" + } + } +} + +provider "proxmox" { + # Configuration options + #pm_tls_insecure = true + pm_api_url = "https://pve.xlinfo.fr:8006/api2/json" + pm_user = "stagiaire@pve" + pm_password = "terraform" + #pm_api_token_id = "xxxxxxx@pve!xxxxxxxx" + #pm_api_token_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +} + +resource "proxmox_lxc" "stagiaire" { + target_node = "pve" + vmid = var.vmid + hostname = "${var.os}-${var.prenom}" + ostemplate = var.template + password = "secret" + unprivileged = true + start = true + ssh_public_keys = <<-EOT + ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCZJG/XcIIvW0JOJb6ftEpopS4szOo8dRehASGIOAswPRko6JFMT9QuAvl9YkmzgSorn0KpyQrqAxNTklADocMGPW2BJzKb/1fQyZYKY9bLXxyKaYZKbDZNaUJmW92ThDmUrIWPgjh5BhUxOTwRbDhTsRu/pvulnGw+8yOp7Tz8nUgAoJEZ/7fGkm7AaJPLmF/szQEhL/WSNqTtNdCHNYpQqgRIUZh5zqcb2jXa0pZ7GMnPmoSUMlz1OfAxMOIuziaP3i1J/KHVhXdxj4nrOtUjrUULfqk9vyfKkf7BLYKO3fO3BLR9H5HgeTlaB2aXNuDgRAQposNZ0FEK/VkWj+DQuqjuj9nYo57GbfMfhWr/dTKxTVj3xsbFdThDWtlp7sVI2jguqntwwlmhhexJp1fAYZn92KYkaxGHWLbR0bxLEWVjHXciVW2D12IUZfGWXh5wInoQN1gs1i6NUqgf1uDZhAax5H9G07YySR2fnM9TB5c5apyf7PFCg1kZAnqVHrE= jerome@parrot + EOT + + memory = 512 + swap = 512 + cores = 1 + rootfs { + storage = "local-lvm" + size = "8G" + } + network { + name = "eth0" + bridge = "vmbr0" + ip = "192.168.2.${var.vmid}/24" + gw = "192.168.2.254" + } + + provisioner "remote-exec" { + connection { + type = "ssh" + host = "192.168.2.${var.vmid}" + user = "root" + private_key = file("~/.ssh/id_rsa") + timeout = "5m" + } + inline = [ + "touch terraform_ok" + ] + } + + provisioner "local-exec" { + command = "./local_script 192.168.2.${var.vmid}" + } + +} |
