Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/data/libvirt/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ resource "libvirt_domain" "master" {
}

data "libvirt_network_dns_host_template" "bootstrap" {
count = "${var.bootstrap_dns ? 1 : 0}"
ip = "${var.tectonic_libvirt_bootstrap_ip}"
hostname = "${var.tectonic_cluster_name}-api"
}
Expand Down
5 changes: 5 additions & 0 deletions data/data/libvirt/variables-libvirt.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "bootstrap_dns" {
default = true
description = "Whether to include DNS entries for the bootstrap node or not."
}

variable "tectonic_libvirt_uri" {
type = "string"
description = "libvirt connection URI"
Expand Down
24 changes: 22 additions & 2 deletions pkg/destroy/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,43 @@ func Destroy(dir string) (err error) {
return errors.New("no platform configured in metadata")
}

copyNames := []string{terraform.StateFileName, cluster.TfVarsFileName}

if platform == "libvirt" {
err = ioutil.WriteFile(filepath.Join(dir, "disable-bootstrap.auto.tfvars"), []byte(`{
"bootstrap_dns": false
}
`), 0666)
if err != nil {
return err
}
copyNames = append(copyNames, "disable-bootstrap.auto.tfvars")
}

tempDir, err := ioutil.TempDir("", "openshift-install-")
if err != nil {
return errors.Wrap(err, "failed to create temporary directory for Terraform execution")
}
defer os.RemoveAll(tempDir)

for _, filename := range []string{terraform.StateFileName, cluster.TfVarsFileName} {
for _, filename := range copyNames {
err = copy(filepath.Join(dir, filename), filepath.Join(tempDir, filename))
if err != nil {
return errors.Wrapf(err, "failed to copy %s to the temporary directory", filename)
}
}

logrus.Infof("Using Terraform to destroy bootstrap resources...")
if platform == "libvirt" {
_, err = terraform.Apply(tempDir, platform)
if err != nil {
return errors.Wrap(err, "Terraform apply")
}
}

err = terraform.Destroy(tempDir, platform, "-target=module.bootstrap")
if err != nil {
return errors.Wrap(err, "failed to run terraform")
return errors.Wrap(err, "Terraform destroy")
}

tempStateFilePath := filepath.Join(dir, terraform.StateFileName+".new")
Expand Down