blob: 1f0933d725cfffa38f19e0dd82140900afa2922e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
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.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.10.${var.vmid}"
bastion_host = "pve.xlinfo.fr"
bastion_user = "stagiaire"
user = "root"
private_key = file("~/.ssh/id_rsa")
timeout = "5m"
}
inline = [
"touch terraform_ok"
]
}
}
|