OS Login should be enabled on Google Compute VM instances to centralize SSH access control via IAM and avoid unmanaged, long-lived SSH keys on individual instances. For Ansible-managed instances using the google.cloud.gcp_compute_instance or gcp_compute_instance modules, set the metadata.enable-oslogin property to true. Resources missing the enable-oslogin metadata key or with a value that does not evaluate to Ansible true are flagged.
Secure configuration example:
- name:create instance with OS Login enabledgoogle.cloud.gcp_compute_instance:name:my-instancezone:us-central1-ametadata:enable-oslogin:true