Last active
August 29, 2015 14:00
-
-
Save joshuaconner/11104630 to your computer and use it in GitHub Desktop.
docker_image hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Ensure an image has been built | |
hosts: main | |
vars: | |
image: joshuaconner/someimage | |
tag: sometag | |
tasks: | |
- name: Check if image has already been built using some fancy grep | |
shell: if [ -z "$(docker images | grep '{{ image }}[[:blank:]]*{{ tag }}')" ]; then echo image not built; else echo image built; fi | |
register: cmd_docker_images_grepped | |
changed_when: cmd_docker_images_grepped.stdout != 'image built' | |
- name: Ensure Docker image has been built | |
command: docker pull {{ image }}:{{ tag }} | |
when: cmd_docker_images_grepped.changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment