# Ansible GCP Zone

**URL:** <https://forum.ansible.com/t/ansible-gcp-zone/36398>\
**Category:** Ansible Project\
**Tags:** gcp\
**Created:** [March 3, 2022, 5:47pm UTC](https://forum.ansible.com/t/ansible-gcp-zone/36398 "2022-03-03T17:47:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Barnett](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/adam_barnett/32/4509_2.png) [@Adam\_Barnett](https://forum.ansible.com/u/Adam_Barnett)\
**Post date:** [March 3, 2022, 5:47pm UTC](https://forum.ansible.com/t/ansible-gcp-zone/36398/1 "2022-03-03T17:47:04Z")

</div>

Hi,

We are using GCP with ansible which has been working great up now, we are setting all the flags in ~/.ansible.cfg for ssh

i.e

ssh\_args = -t -i ~/.ssh/google\_compute\_engine -o CheckHostIP=no -o ControlMaster=auto -o ControlPersist=600s -o IdentitiesOnly=yes -o UserKnownHostsFile=~/.ssh/google\_compute\_known\_hosts -o ProxyCommand=“/usr/bin/python3 -S /usr/lib64/google-cloud-sdk/lib/gcloud.py beta compute start-iap-tunnel %h %p --listen-on-stdin --project=studio-00056 --zone=europe-west1-b --verbosity=warning” -o ProxyUseFdpass=no

This has been fine, till we now have to use another zone, meaning that i need to switch the args

I tired replacing the ssh\_executable with my own wrapper

#!/bin/bash  
set -x

host=“${@: -2: 1}”  
cmd=“${@: -1: 1}”

# ControlMaster=auto & ControlPath=… speedup Ansible execution 2 times.

socket=“/tmp/ansible-ssh-${host}-22-iap”

zone=$(gcloud compute instances list --filter=“name:${host}” --format=‘value(zone)’)  
gcloud\_args="  
–tunnel-through-iap  
–zone=$zone  
–quiet  
–no-user-output-enabled
