Skip to content

Can't read list of created hosts #140

@alijahnas

Description

@alijahnas

So I've used Terraform v.0.12.20 and the libvirt provider to create some hosts. But when I used terraform-inventory to generate an ansible inventory, I get an empty list of hosts:

[all]

[all:vars]
ip-master="192.168.122.5"

Can somebody please tell me what I did wrong? Thanks.

provider "libvirt" {
  uri = "qemu:///system"
}

resource "libvirt_volume" "ubuntu1804_cloud" {
  name = "ubuntu18.04.qcow2"
  pool = "default"
  source = "https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"
  format = "qcow2"
}

resource "libvirt_volume" "ubuntu1804_resized" {
  name           = "ubuntu-volume-${count.index}"
  base_volume_id = libvirt_volume.ubuntu1804_cloud.id
  pool           = "default"
  size           = 42949672960
  count          = 2
}

resource "libvirt_cloudinit_disk" "cloudinit_ubuntu" {
  name = "cloudinit_ubuntu_resized.iso"
  pool = "default"

  user_data = <<EOF                                                                                                
#cloud-config                                                                                                      
disable_root: 0                                                                                                    
ssh_pwauth: 1                                                                                                      
users:                                                                                                             
  - name: ubuntu                                                                                                   
    shell: /bin/bash                                                                                               
    ssh-authorized-keys:                                                                                           
      - ${file("~/.ssh/sol.key.pub")}                                                                              
growpart:                                                                                                          
  mode: auto                                                                                                       
  devices: ['/']                                                                                                   
EOF                                            

}

resource "libvirt_domain" "k8s-master" {
  name   = "k8s-master"
  memory = "4096"
  vcpu   = 2

  cloudinit = libvirt_cloudinit_disk.cloudinit_ubuntu.id

  network_interface {
    network_name = "default"
    wait_for_lease = true
  }

  disk {
    volume_id = libvirt_volume.ubuntu1804_resized[0].id
  }

  console {
    type = "pty"
    target_type = "serial"
    target_port = "0"
  }

  graphics {
    type = "spice"
    listen_type = "address"
    autoport = true
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions