ansible-collections / ansible-collections/google.cloud
GCP authentication : allow the usage of token instead of Json key and allow SA impersonation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 105
- Forks
- 144
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 4
Description
##### SUMMARY
We do not want to manage GCP json key of service account as it is a security issue, one have to renew them.
So, to achieve this, we use Hashicorp Vault to provide a Token (validity 1 hour).
##### ISSUE TYPE
- Feature Idea
##### COMPONENT NAME
##### ADDITIONAL INFORMATION
To authenticate ansible on GCP, we would like 2 new authentication ways :
- Provide a token instead of a json key
- Provide a token and a service account email to impersonate
In our use case, Vault gives a token of a SA which is only allowed to impersonate another SA which has the necessary roles to update the instances metadatas to setup a ssh key for Ansible
Thank you
MLD
```
- name: Create IP address with token but without impersonation
hosts: localhost
gather_facts: no
vars:
service_account_token: satoken
project: my-project
auth_kind: service-account-token
scopes:
- https://www.googleapis.com/auth/compute
tasks:
- name: Allocate an IP Address - with token only
gcp_compute_address:
state: present
name: 'test-address1'
region: 'us-west1'
project: "{{ project }}"
auth_kind: "{{ auth_kind }}"
service_account_token: "{{ service_account_token }}"
scopes: "{{ scopes }}"
- name: Create IP address with token and with impersonation
hosts: localhost
gather_facts: no
vars:
service_account_token: satoken
project: my-project
auth_kind: service-account-token-with-impersonation
service_account_email_to_impersonate:service_account_email
scopes:
- https://www.googleapis.com/auth/compute
tasks:
- name: Allocate an IP Address
gcp_compute_address:
state: present
name: 'test-address1'
region: 'us-west1'
project: "{{ project }}"
auth_kind: "{{ auth_kind }}"
service_account_token: "{{ service_account_token }}"
service_acount_to_impersonate:"{{service_acount_email_to_impersonate}}"
scopes: "{{ scopes }}"
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how gcp_compute_address currently handles auth_kind and service-account credentials, then inspect the collection's existing GCP authentication implementation. Implement and verify token-only authentication and token-based service-account impersonation using the two configurations shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, python
- Domain
- authentication, cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100