Let's say an ansible task performs docker-compose pull
, and reports the result like this:
changed_when: "'... pull complete' in result.stderr |default('')"
That works because stdout shows "... pull complete" only the first time - if the image exists then it does not.
Is there an similar way to deal with docker-compose build
?
- name: foo
shell: "docker-compose build"
args:
chdir: "{{FOO_PATH}}"
register: result
changed_when: "'???' in result.stderr |default('')" # <----------- ?
Whether I'm building an image for the first time, or it already exists, stdout always shows me:
Successfully built fbd38aa5b45a
Successfully tagged foo/bar:latest
I also checked "$?" which is always 0
. Is there a way to detect whether the build occurred or not?