Skip to content

Instantly share code, notes, and snippets.

@adamcstephens
Created November 11, 2016 01:59
Show Gist options
  • Save adamcstephens/7e56423ccceb3e1f3c0d808eb7cb8c59 to your computer and use it in GitHub Desktop.
Save adamcstephens/7e56423ccceb3e1f3c0d808eb7cb8c59 to your computer and use it in GitHub Desktop.
provider "libvirt" {
uri = "qemu:///system"
}
resource "libvirt_volume" "centos7" {
name = "centos-stable"
source = "http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2"
}
resource "libvirt_volume" "centos" {
name = "centos${count.index}"
base_volume_id = "${libvirt_volume.centos7.id}"
count = 4
}
resource "libvirt_cloudinit" "centos" {
name = "centos${count.index}.iso"
local_hostname = "centos${count.index}"
count = 4
ssh_authorized_key = "SNIP"
}
resource "libvirt_domain" "centos" {
name = "centos${count.index}"
disk {
volume_id = "${element(libvirt_volume.centos.*.id, count.index)}"
}
count = 4
serialconsole = "yes"
network_interface {
network_name = "default"
}
cloudinit = "${element(libvirt_cloudinit.centos.*.id, count.index)}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment