Skip to content

Commit

Permalink
chore(ansible): Adding gcr support
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 a5e23bf commit b0ffdfe
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions ansible/docker_image_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,37 @@
hosts: local
become: yes
vars_files:
- ['{{inventory_dir}}/secrets.yml']
become: yes
- ["{{inventory_dir}}/secrets.yml"]
tasks:
- name: login to registry
docker_login:
registry: "{{ vault_docker_registry_url }}"
username: "{{ vault_docker_registry_user }}"
password: "{{ vault_docker_registry_password }}"
tags: docker-login
tags: azure
- block:
- name: Write GCR service account key to a temporary file
copy:
content: "{{ gcp_service_account }}"
dest: /tmp/gcr_service_account_key.json

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

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

- name: Push image to registry
docker_image:
name: "{{ hub_org }}/{{ image_name }}:{{ image_tag }}"
push: yes

- file:
path: "/root/.docker"
state: absent
- block:
- name: Push image to registry
docker_image:
name: "{{ hub_org }}/{{ image_name }}:{{ image_tag }}"
push: yes
- file:
path: "/root/.docker"
state: absent
tags: always

0 comments on commit b0ffdfe

Please sign in to comment.