Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't read list of created hosts #140

Open
alijahnas opened this issue Feb 14, 2020 · 0 comments
Open

Can't read list of created hosts #140

alijahnas opened this issue Feb 14, 2020 · 0 comments

Comments

@alijahnas
Copy link

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
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant