Antoine
f70970f0e4
generate ansible inventory from terraform provisioned domain add make hazelcast to run and setup hazelcast onto domain
65 lines
1.5 KiB
HCL
65 lines
1.5 KiB
HCL
# https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r
|
|
|
|
terraform {
|
|
required_version = ">= 0.12"
|
|
|
|
required_providers {
|
|
null = {
|
|
source = "hashicorp/null"
|
|
version = "~> 2.1"
|
|
}
|
|
template = {
|
|
source = "hashicorp/template"
|
|
version = "~> 2.1"
|
|
}
|
|
libvirt = {
|
|
source = "dmacvicar/libvirt"
|
|
version = ">= 0.6.3"
|
|
}
|
|
}
|
|
|
|
backend "etcdv3" {
|
|
endpoints = ["https://100.64.0.19:2379"]
|
|
lock = true
|
|
prefix = "/terraform-state/stack/"
|
|
cacert_path = "/home/antoine/virtualization/kubernetes-the-hard-way/certs/ca.pem"
|
|
cert_path = "/home/antoine/virtualization/kubernetes-the-hard-way/certs/kubernetes.pem"
|
|
key_path = "/home/antoine/virtualization/kubernetes-the-hard-way/certs/kubernetes-key.pem"
|
|
}
|
|
|
|
}
|
|
|
|
provider "libvirt" {
|
|
uri = "qemu+tcp://dx30.localdomain/system"
|
|
}
|
|
|
|
resource "null_resource" "delay_10s" {
|
|
provisioner "local-exec" {
|
|
command = "sleep 120"
|
|
}
|
|
triggers = {
|
|
# trigger after last domain created
|
|
"after" = libvirt_domain.domains[var.number_domain - 1].id
|
|
}
|
|
}
|
|
|
|
# Output Server IP
|
|
output "ip" {
|
|
value = libvirt_domain.domains.*.network_interface
|
|
depends_on = [null_resource.delay_10s]
|
|
}
|
|
|
|
resource "local_file" "write_address" {
|
|
|
|
content = <<-EOT
|
|
[all]
|
|
%{ for idx, s in libvirt_domain.domains.*.network_interface.0.addresses.0 ~}
|
|
${s} index=${idx}
|
|
%{ endfor ~}
|
|
[all:vars]
|
|
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
|
|
EOT
|
|
|
|
filename = "../applications/stack_address.toml"
|
|
}
|