Skip to content

Commit

Permalink
fix(ansible): gcr registry login
Browse files Browse the repository at this point in the history
Signed-off-by: rr <[email protected]>
  • Loading branch information
lazylua committed May 30, 2024
1 parent b0ffdfe commit c665fb8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ansible/docker_image_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
- name: "Push docker images to any docker registry"
hosts: local
become: yes
vars:
service_account_local_path: /tmp/gcr_service_account_key.json
vars_files:
- ["{{inventory_dir}}/secrets.yml"]
tasks:
Expand All @@ -15,16 +17,16 @@
- name: Write GCR service account key to a temporary file
copy:
content: "{{ gcp_service_account }}"
dest: /tmp/gcr_service_account_key.json
dest: "{{ service_account_local_path }}"

- name: Authenticate Docker to GCR
command: >
docker login -u _json_key -p "{{ lookup('file', '/tmp/gcr_service_account_key.json') }}" https://gcr.io
shell: >
cat "{{ service_account_local_path }}" | docker login -u _json_key --password-stdin {{ vault_docker_registry_url }}
no_log: true

- name: Remove temporary GCR service account key file
file:
path: /tmp/gcr_service_account_key.json
path: "{{ service_account_local_path}}"
state: absent
tags: gcp

Expand Down

0 comments on commit c665fb8

Please sign in to comment.