I am trying to set up ansible for my gcp compute instances.
I want to know if there is some way to use gcp credentials for logging into compute instances.
I am aware of the ansible gcp_compute module but it only allows you to get your inventory list.
I don’t want to have to manually set up ssh keys and rotate them periodically for all instances.
Can anyone help regarding this?
I have already tried following the method listed in : https://xebia.com/blog/how-to-tell-ansible-to-use-gcp-iap-tunneling/#:~:text=First%20we%20tell%20Ansible%20that,commands%20for%20our%20remote%20connections. and Ansible GCP IAP tunnel but it doesn’t seem to work for me and it bugs out with the following error :
fatal: [host-1]: FAILED! => {“ansible_facts”: {}, “changed”: false, “failed_modules”: {“ansible.legacy.setup”: {“ansible_facts”: {“discovered_interpreter_python”: “/usr/bin/python”}, “failed”: true, “module_stderr”: “ERROR: (gcloud.compute.ssh) argument [USER@]INSTANCE: Must be specified.nUsage: gcloud compute ssh [USER@]INSTANCE [optional flags] [– SSH_ARGS …]n optional flags may be –command | –container | –dest-group | –dry-run |n –force-key-file-overwrite | –help | –internal-ip |n –network | –plain | –region | –ssh-flag |n –ssh-key-expiration | –ssh-key-expire-after |n –ssh-key-file | –strict-host-key-checking |n –troubleshoot | –tunnel-through-iap | –zonennFor detailed information on this command and its flags, run:n gcloud compute ssh –helpn”, “module_stdout”: “”, “msg”: “MODULE FAILUREnSee stdout/stderr for the exact error”, “rc”: 2, “warnings”: [“Platform unknown on host host-1 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.16/reference_appendices/interpreter_discovery.html for more information.”]}}, “msg”: “The following modules failed to execute: ansible.legacy.setupn”}