diff --git a/README.md b/README.md index cecf0bd..c6dde3a 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ EOF Apply the terraform plan. ```sh +export GANDI_KEY="123...456" terraform apply ``` diff --git a/post-install.tf b/post-install.tf index c201202..b594317 100644 --- a/post-install.tf +++ b/post-install.tf @@ -15,3 +15,30 @@ resource "local_file" "dns_config" { filename = "${var.cluster_name}/dns.env" file_permission = "0644" } + +resource "null_resource" "dnsmasq_config" { + triggers = { + network_id = libvirt_network.ocp_net.id + } + + connection { + type = "ssh" + host = local.libvirt_server + user = local.libvirt_username + } + + provisioner "remote-exec" { + inline = [ + "echo 'server=/${local.network_domain}/${cidrhost(var.network_ip_range, 1)}' | sudo tee /etc/NetworkManager/dnsmasq.d/libvirt-ocp-${var.cluster_name}.conf", + "sudo pkill -f '[d]nsmasq.*--enable-dbus=org.freedesktop.NetworkManager.dnsmasq'" + ] + } + + provisioner "remote-exec" { + when = destroy + inline = [ + "sudo rm -f /etc/NetworkManager/dnsmasq.d/libvirt-ocp-${var.cluster_name}.conf", + "sudo pkill -f '[d]nsmasq.*--enable-dbus=org.freedesktop.NetworkManager.dnsmasq'" + ] + } +} diff --git a/provider.tf b/provider.tf index 75f2caa..cf18d56 100644 --- a/provider.tf +++ b/provider.tf @@ -6,3 +6,9 @@ provider "gandi" { # key = "" # sharing_id = "" } + +locals { + # See post-install.tf + libvirt_server = "hp-ml350.itix.fr" + libvirt_username = "nicolas" +}