ansible / terraform-provider-ansible

community terraform provider for ansible
https://registry.terraform.io/providers/ansible/ansible/latest
GNU General Public License v3.0
183 stars 42 forks source link

remove line 473, 474 fix the case which gather previous ansible inven… #51

Closed sukengine closed 11 months ago

sukengine commented 12 months ago

Problem: ansible_playbook resource gather all inventories include the previous inventory files.

Fix: remove function call to "providerutils.GetAllInventories(inventoryFileNamePrefix)" on provider/resource_playbook.go, line 473-474

sukengine commented 11 months ago

How to reproduce:

terraform.tf

terraform { required_providers { ansible = { version = "~> 1.1.0"

version = "1.0.0"

  source  = "ansible/ansible"
}

} }

resource "ansible_playbook" "playbook" { playbook = "playbook.yml" name = "192.168.100.11" replayable = true

}

output "ansible_output" { value = ansible_playbook.playbook.ansible_playbook_stdout }

for the playbook.yml, use any simple playbook.

Then, run terraform apply, will apply playbook to the target host name "192.168.100.11"

Under terraform.tf, ansible_playbook.playbook, change value of "name" from "192.168.100.11" to "192.168.100.12"

terraform apply, see the output also include the previous host name, 192.168.100.11. Because provider/resource_playbook.go line 474 call to providerutils.GetAllInventories which gathers all .ini files. remove line 473-434 of provider/resource_playbook.go can fix this.

sukengine commented 11 months ago

Duplicated