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

hostvars is emply when run ./terraform.py #22

Open
patsevanton opened this issue Nov 2, 2020 · 1 comment
Open

hostvars is emply when run ./terraform.py #22

patsevanton opened this issue Nov 2, 2020 · 1 comment

Comments

@patsevanton
Copy link

Hello. Thanks for terraform-inventory.

terraform -version
Terraform v0.11.14

apply terraform from repo https://github.com/yandex-cloud/examples/tree/master/active-directory

Run terraform.py

./terraform.py
{
  "_meta": {
    "hostvars": {}
  }

terraform -version
Terraform v0.12.29

Simple terraform main.tf:


  resources {
    cores  = 2
    memory = 4
  }

  boot_disk {
    initialize_params {
      image_id = "fd87va5cc00gaq2f5qfb"
    }
  }

  network_interface {
    subnet_id = yandex_vpc_subnet.subnet-1.id
    nat       = true
  }

  metadata = {
    ssh-keys = "ubuntu:${file("~/.ssh/id_rsa.pub")}"
  }
}

resource "yandex_vpc_network" "network-1" {
  name = "network1"
}

resource "yandex_vpc_subnet" "subnet-1" {
  name           = "subnet1"
  zone           = "ru-central1-a"
  network_id     = yandex_vpc_network.network-1.id
  v4_cidr_blocks = ["192.168.10.0/24"]
}

output "internal_ip_address_vm_1" {
  value = yandex_compute_instance.vm-1.network_interface.0.ip_address
}

output "internal_ip_address_vm_2" {
  value = yandex_compute_instance.vm-2.network_interface.0.ip_address
}


output "external_ip_address_vm_1" {
  value = yandex_compute_instance.vm-1.network_interface.0.nat_ip_address
}

output "external_ip_address_vm_2" {
  value = yandex_compute_instance.vm-2.network_interface.0.nat_ip_address
}

Run terraform.py

 ./terraform.py
{
  "_meta": {
    "hostvars": {}
  }
@nbering
Copy link
Owner

nbering commented Nov 2, 2020

The documentation with some simple samples can guide you through setting up your Terraform configuration for use with this inventory script. You need the Terraform resources so that what you're bringing over to Ansible is explicitly defined. My introductory blog post may also serve as a good primer for how the components work together. The provider is also available in the terraform registry. I haven't yet updated the docs to cover that.

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

2 participants