-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbmc.tf
52 lines (44 loc) · 1.19 KB
/
bmc.tf
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
resource "proxmox_lxc" "bmc" {
target_node = var.bmc_node
hostname = "bmc"
ostemplate = "${var.template_storage}:vztmpl/bmc_base.tar.gz"
password = var.bmc_password
unprivileged = true
start = true
// Terraform will crash without rootfs defined
rootfs {
storage = var.bmc_storage
size = var.bmc_storage_size
}
network {
name = "eth0"
bridge = var.bmc_bridge
ip = var.bmc_ip
tag = var.bmc_vlan_tag
gw = var.bmc_gw
}
ssh_public_keys = <<-EOT
${ tls_private_key.bmc.public_key_openssh }
EOT
depends_on = [
null_resource.bmc_template_enable_ssh
]
}
resource "tls_private_key" "bmc" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "local_file" "bmc_ssh_key" {
content = tls_private_key.bmc.private_key_openssh
filename = "ansible/bmc/ssh_key"
file_permission = 0600
}
resource "null_resource" "bmc_ansible_init" {
depends_on = [
local_file.ansible_inventory,
proxmox_lxc.bmc
]
provisioner "local-exec" {
command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u root -i ./ansible/inventory --private-key ./ansible/bmc/ssh_key ./ansible/bmc/init.yaml"
}
}