hostvars is emply when run ./terraform.py
patsevanton opened this issue · 1 comments
patsevanton commented
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 commented
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.