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

plugin.(*GRPCProvider).ApplyResourceChange error #68

Closed DonBower closed 8 months ago

DonBower commented 8 months ago

I am running this on my macOS version 13.5.2 (22G91) MacBook Pro, Intel i9 processor.

Terraform version: Terraform v1.5.7 vSphere Provider: 2.4.2 Ansible Provider: 1.1.0

Anybody know what my issue might be?

I have this TF code:

resource "ansible_playbook" "playbook" {
  playbook   = "${path.module}/ansible/main.yaml"
  name       = "${module.rancherVM["rancher"].thisIP},"
  replayable = true

  extra_vars = {
    var_a = "Some variable"
    var_b = "Another variable"
  }
}

which produces this output:

ansible_playbook.playbook: Creating...
2023-10-29T16:40:05.590-0700 [INFO]  Starting apply for ansible_playbook.playbook
2023-10-29T16:40:05.590-0700 [DEBUG] ansible_playbook.playbook: applying the planned Create change
2023-10-29T16:40:05.591-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 [DEBUG] setting computed for "args" from ComputedKeys
2023-10-29T16:40:05.591-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 [ANSIBLE ARGS]:
2023-10-29T16:40:05.591-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 [-e hostname=192.168.2.30, -e var_b=Another variable -e var_a=Some variable ./ansible/main.yaml]
2023-10-29T16:40:05.591-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 LOG [ansible-playbook]: playbook = ./ansible/main.yaml
2023-10-29T16:40:05.591-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 Inventory /var/folders/x4/q8_y7x6x64n14n_c8k09m0hr0000gn/T/.inventory-292102469.ini was created
2023-10-29T16:40:05.591-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 Temp Inventory File: /var/folders/x4/q8_y7x6x64n14n_c8k09m0hr0000gn/T/.inventory-292102469.ini
2023-10-29T16:40:05.591-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 [TEMP DIR]: /var/folders/x4/q8_y7x6x64n14n_c8k09m0hr0000gn/T/
2023-10-29T16:40:05.594-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 [INVENTORIES]:
2023-10-29T16:40:05.594-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:05 [/var/folders/x4/q8_y7x6x64n14n_c8k09m0hr0000gn/T/.inventory-154869708.ini /var/folders/x4/q8_y7x6x64n14n_c8k09m0hr0000gn/T/.inventory-292102469.ini /var/folders/x4/q8_y7x6x64n14n_c8k09m0hr0000gn/T/.inventory-3342802723.ini]
2023-10-29T16:40:06.738-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/10/29 16:40:06 ERROR [ansible-playbook]: couldn't run ansible-playbook
2023-10-29T16:40:06.738-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: ./ansible/main.yaml! There may be an error within your playbook.
2023-10-29T16:40:06.738-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: exit status 4
2023-10-29T16:40:06.740-0700 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-10-29T16:40:06.740-0700 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/ansible/ansible/1.1.0/darwin_amd64/terraform-provider-ansible_v1.1.0 pid=33667 error="exit status 1"
2023-10-29T16:40:06.741-0700 [ERROR] plugin.(*GRPCProvider).ApplyResourceChange: error="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-10-29T16:40:06.768-0700 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2023-10-29T16:40:06.768-0700 [ERROR] vertex "ansible_playbook.playbook" error: Plugin did not respond
╷
│ Error: Plugin did not respond
│ 
│   with ansible_playbook.playbook,
│   on main.tf line 28, in resource "ansible_playbook" "playbook":
│   28: resource "ansible_playbook" "playbook" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more
│ details.
╵
2023-10-29T16:40:06.795-0700 [DEBUG] provider: plugin exited
lae commented 8 months ago
2023-10-29T16:40:06.738-0700 [DEBUG] provider.terraform-provider-ansible_v1.1.0: ./ansible/main.yaml! There may be an error within your playbook.

ansible-playbook failed to run.

39 all over again 🙃 (there are some tips there for getting run output but this really should have better UX)

DonBower commented 8 months ago

FYI: I ran the playbook externally, and it ran without error. I will try the steps outlined in #39

DonBower commented 8 months ago

While there was not an error with the playbook itself, the error was when I passed the ip, I added a comma after it, as you do when you run ansible-playbook -i 1.2.3.4, playbook-name.yaml. I removed the comma, and it worked.

This really is a bad error message.