Open aedwa038 opened 4 years ago
I have the same issue here, even I add tasks in the playbook to wait for ssh it still fails. but when I re-run terraform apply
it succeed.
- name: Wait for port 22 to become open and contain "OpenSSH"
wait_for:
port: 22
host: '{{ (ansible_ssh_host|default(ansible_host)|default(inventory_hostname) }}'
search_regex: OpenSSH
delay: 15
connection: local
Steps to reproduce
Currently trying to use terraform-provisioner-ansible with GCP When creating vms in gcp using the provsioner would sometimes fail to ssh when a vm is not ready to be ssh'd into. Even if I try to set the connection attempts argument to a higher number. I still see ssh failures fairly quickly
It looks like ansible code based around this has changed a bit and its ignoring the argument ConnectionAttempts.
Upon further inspection ansible no longer takes the argument -o ConnectionAttempts=20 inside the ssh-extra-args
There is now seems to be something called retries https://github.com/ansible/ansible/blob/aa53eb0e7196c6c920e6326f5d11accfd077d151/lib/ansible/plugins/connection/ssh.py#L142
This can be worked around by setting the environment variable ANSIBLE_SSH_RETRIES before executing the ansible playbooks in terraform
Expected behavior
When setting Ansible SSH settings connection attempts I expect the provsioner/ansible to retry failed ssh connection attempts.
...
Actual behavior
When setting the connection attempts argument the terraform ansible provsioner is passing it in the ssh extra args as -o ConnectTimeout in the incorrect format. ...
Configuration
Terraform version:0.12.10
terraform-provisioner-ansible version/SHA:v2.3.3
Terraform file / provisioner configuration:
Terraform run log: