Open jhalbrecht opened 1 year ago
The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
seems to be a fairly generic error that is emitted when the ansible-playbook
command terminates with an error.
In my case, one reason I saw it was because I'm using some wrapper scripts to enable connecting to Google Cloud instances using their Identity Aware Proxy (IAP). The script requires passing in an Ansible variable zone
to specify the GCP zone, and this Ansible provider wasn't passing that variable through to the generated inventory file, even though I'd specified it on the ansible_host
in Terraform. I was able to work around it by hard coding the zone
in the vars
section of the playbook.
Hi guys!
I'm with the same problem here. In my case I'm creating a GCP VM and trying to apply the playbook with the same errors. The ansible_host is working properly but not ansible_playbook.
https://github.com/ansible/terraform-provider-ansible/issues/37 Similar issue here, where the ansible_playbook resource is not using the ansible_user and ansible_host variables from ansible_host resource
Like @ashleyghooper stated earlier, the error given is effectively a generic error masking the real error.
Ana provided some steps in #39 (outputting the playbook output via Terraform outputs) that should make these issues easier to debug and fix in practice, I think?
Hello! The outputs.tf don't show anything useful to debug as stderr and stdout too
Hi.
I got this error too, the problem was my playbook file.
When your playbook file is failed you will get this error.
It seems that there is not any proper error handling for these errors.
You can get errors you are getting by setting ignore_playbook_failure
to true
for your ansible_playbook resource.
then the logs of Ansible will be shown on your debug so you can debug the Ansible playbook.
Without ignore_playbook_failure
you will get:
/tmp/.inventory-3619357673.ini /tmp/.inventory-3944771403.ini /tmp/.inventory-4016386583.ini]
2023-09-22T09:22:43.908+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/09/22 09:22:43 ERROR [ansible-playbook]: couldn't run ansible-playbook
2023-09-22T09:22:43.908+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: ./ansible/site.yml! There may be an error within your playbook.
2023-09-22T09:22:43.908+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: exit status 2
2023-09-22T09:22:43.909+0330 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/ansible/ansible/1.1.0/linux_amd64/terraform-provider-ansible_v1.1.0 pid=605284 error="exit status 1"
2023-09-22T09:22:43.909+0330 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-09-22T09:22:43.909+0330 [ERROR] plugin.(*GRPCProvider).ApplyResourceChange: error="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-09-22T09:22:43.935+0330 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2023-09-22T09:22:43.935+0330 [ERROR] vertex "module.dvh_cluster.ansible_playbook.kind_cluster" error: Plugin did not respond
╷
│ Error: Plugin did not respond
│
│ with module.dvh_cluster.ansible_playbook.kind_cluster,
│ on modules/kind-cluster/main.tf line 1, in resource "ansible_playbook" "kind_cluster":
│ 1: resource "ansible_playbook" "kind_cluster" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
but when you set ignore_playbook_failure
to true the debug logs become:
/tmp/.inventory-3619357673.ini /tmp/.inventory-3944771403.ini /tmp/.inventory-4016386583.ini /tmp/.inventory-722659454.ini]
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/09/22 09:30:26 ERROR [ansible-playbook]: couldn't run ansible-playbook
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: ./ansible/site.yml! There may be an error within your playbook.
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: exit status 2
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/09/22 09:30:26 LOG [ansible-playbook]:
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: PLAY [Install and create Kubernetes cluster] ***********************************
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0:
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: TASK [Include the kind-cluster role] *******************************************
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: /usr/lib/python3/dist-packages/paramiko/transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: "class": algorithms.Blowfish,
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0:
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: TASK [kind-cluster : include_tasks] ********************************************
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: included: /home/me0dira/Documents/projects/organizations/devopshobbies/dvh-cluster-provisioner/ansible/roles/kind-cluster/tasks/pre-install.yml for localhost
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0:
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: TASK [kind-cluster : Check Docker installation status] *************************
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: changed: [localhost]
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0:
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: TASK [kind-cluster : Fail if Docker is not installed] **************************
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: ok: [localhost] => {
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: "changed": false,
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: "msg": "All assertions passed"
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: }
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0:
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: TASK [kind-cluster : Add docker group to users {{ ansible_user }} groups] ******
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible_user' is undefined\n\nThe error appears to be in '/home/me0dira/Documents/projects/organizations/devopshobbies/dvh-cluster-provisioner/ansible/roles/kind-cluster/tasks/pre-install.yml': line 12, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Add docker group to users {{ ansible_user }} groups\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"}
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0:
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: PLAY RECAP *********************************************************************
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: localhost : ok=3 changed=1 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0:
2023-09-22T09:30:26.011+0330 [DEBUG] provider.terraform-provider-ansible_v1.1.0: 2023/09/22 09:30:26 LOG [ansible-playbook]: didn't wait for playbook to execute: exec: Wait was already called
module.dvh_cluster.ansible_playbook.kind_cluster: Creation complete after 1s [id=2023-09-22 09:30:24.875399233 +0330 +0330 m=+0.072935028]
2023-09-22T09:30:26.036+0330 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2023-09-22T09:30:26.037+0330 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-09-22T09:30:26.038+0330 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/ansible/ansible/1.1.0/linux_amd64/terraform-provider-ansible_v1.1.0 pid=613412
2023-09-22T09:30:26.038+0330 [DEBUG] provider: plugin exited
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
and as you can see there is more information about what wrong is going on so you can start debugging.
We have improved the logging in v1.2.0 of this provider. Can you confirm that this information is more easily available now?
On reddit I was asked to file an issue.
Problem
I tried to use the new ansible/ansible ansible_playbook resource in a simple .tf to create a vm on proxmox.
FWIW I experimented with changing the file name to a non existent play-book receiving the same error(s) either way. In the debugging it would be hady, for me, to have some indicaton of file exists.
[ERROR] vertex "ansible_playbook.playbook_initial" error: Plugin did not respond
Code
Log extract
Ignore this in the log, I ran it on a host with updated ansible with the same results.
terraform_data.ansible_inventory (local-exec): [WARNING]: Collection cloud.terraform does not support Ansible version 2.12.10