-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutputs.tf
More file actions
29 lines (25 loc) · 1014 Bytes
/
Copy pathoutputs.tf
File metadata and controls
29 lines (25 loc) · 1014 Bytes
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
# Generate Ansible inventory file with floating IP
resource "local_file" "ansible_inventory" {
content = templatefile("${path.module}/inventory.tpl", {
floating_ip = ibm_is_floating_ip.ilab_fip.address
ssh_key = var.existing_ssh_key != "" ? var.existing_ssh_key : "${local.prefix}.pem"
})
filename = "${path.module}/inventory.ini"
depends_on = [
ibm_is_floating_ip.ilab_fip,
null_resource.create_private_key
]
}
# Output the floating IP for reference
output "floating_ip" {
description = "The floating IP address of the ilab instance"
value = ibm_is_floating_ip.ilab_fip.address
}
output "ssh_command" {
description = "SSH command to connect to the instance"
value = "ssh -i ${var.existing_ssh_key != "" ? "~/.ssh/${var.existing_ssh_key}" : "./${local.prefix}.pem"} ilab@${ibm_is_floating_ip.ilab_fip.address}"
}
output "ansible_command" {
description = "Command to run the Ansible playbook"
value = "ansible-playbook -i inventory.ini playbook.yml"
}