Hi All,
I’m trying to do the following:
- name: Git checkout
git:
accept_hostkey: yes
clone: yes
dest: "/opt/docker-images/{{ item.path }}"
force: yes
key_file: /tmp/gitkey
repo: "{{ item.repo }}"
version: "{{ item.branch if item.branch is defined else 'HEAD' }}"
with_items: dockers
register: gitcloned
- name: stop dockers
docker:
image: "{{ item.path }}-image"
name: "{{ item.path }}-container"
state: absent
with_items: dockers
when: gitcloned.changed
- name: remove images
docker_image:
name: "{{ item.path }}-image"
state: absent
with_items: dockers
when: gitcloned.changed
- name: Creeer de docker images
docker_image:
name: "{{ item.path }}-image"
path: "/opt/docker-images/{{ item.path }}"
with_items: dockers
- name: Start de docker images
docker:
image: "{{ item.path }}-image"
name: "{{ item.path }}-container"
env: "{{ item.env }}"
ports: "{{ item.port }}:{{ item.docker_port }}"
restart_policy: "{{item.restart}}"
with_items: dockers
So basicly: when git is changed and a new clone is performed. remove de
docker container, the image, and start to rebuild those things.
Works as advertised! Almost… you see, when only 1 of the git repo’s get’s
updates, it still means that ALL docker instances are stopped and ALL
images are removed, instead of just the one whose git repo got changed.
In other words, with_items is not logically linked with register: gitcloned
Am I goign the wrong way perhaps?
Thanks,
Mark
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/be04e46a-37b4-4be9-8eef-e2b40d065e26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.