I am required to tunnel through IAP with service account credentials.
I have overridden my ssh binary, ‘ssh_executable=script.sh’, creating a ‘gcloud compute ssh xxxx —tunnel-through-iap’ wrapper, where I regex ssh arguments into the gcloud command.
For tunneling to work I must
1. Run my playbook with my instance IP in the hosts variable of my playbook
2. Hardcode my compute instance hostname for my ssh wrapper connection.
3. This always makes an initial connection but always fails to run the command. No matter my regex there is always extra “, ‘ or something.
4. Comment out my ‘ssh_execution’ wrapper overriding in ansible.cfg
5. Run my playbook again which runs successfully.
Running the playbook with the gcp plugin will only list available instances but will never ssh successfully without a previously opened gcloud session.