Skip to content

Commit

Permalink
security: hide content of the service account contents from the logs …
Browse files Browse the repository at this point in the history
…for GCE

When instance is waited for SSH, loop label contains all server data,
returned by the driver. One of them is service_account_contents
which contains a private key to  a GCE service account, used to create
VMs in GCE, if GCP_SERVICE_ACCOUNT_CONTENTS environment variable was
used.
  • Loading branch information
amarao committed Feb 22, 2025
1 parent 980db38 commit 29b8908
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@
- "Dump instance config"

- name: Wait for SSH
no_log: "{{ molecule_no_log }}" # GCE modules leaks GCP_SERVICE_ACCOUNT_CONTENTS value in returned values from module, which contains private key
ansible.builtin.wait_for:
port: 22
host: "{{ item.networkInterfaces.0.accessConfigs.0.natIP if molecule_yml.driver.external_access else item.networkInterfaces.0.networkIP }}"
search_regex: SSH
delay: 10
loop: "{{ server.results }}"
loop_control:
label: "{{ item.name }}"
register: waitfor
until: waitfor.failed == false
retries: 6
Expand Down
2 changes: 2 additions & 0 deletions test/gce/scenarios/linux/tasks/create_linux_instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@
- Dump instance config

- name: Wait for SSH
no_log: "{{ molecule_no_log }}"
ansible.builtin.wait_for:
port: 22
host: "{{ item.networkInterfaces.0.accessConfigs.0.natIP if molecule_yml.driver.external_access else item.networkInterfaces.0.networkIP }}"
search_regex: SSH
delay: 10
loop: "{{ server.results }}"

0 comments on commit 29b8908

Please sign in to comment.