Hello all,
I have group tgt-cluster
includes 3 hosts. I have written down role to deploy container which is executing on tgt-cluster
group. I am controlling the number of containers to deploy with with_sequence
. My tasks looks like this.
- name: Deploy Container
docker_container:
name: "C{{ item }}"
image: "{{ image_name }}:{{ image_tag }}"
recreate: yes
detach: yes
tty: yes
interactive: yes
with_sequence: count="{{ number_of_container_to_deploy }}"
I
f I want to deploy one container, currently playbook is executing on all 3 hosts intgt-cluster
group and I end up with 3 containers. So How should I created nested loop in this case to control the task execution on hosts on round robin fashion.
Say if we want to deploy 4 container… 1st container should be deployed on 1st host in group, 2nd container should be deployed on 2nd host in group, 3rd should be deployed on 3rd hosts in group and 4th container should be deployed back to the 1st host in group.
Need your help on this,
Thanks,
Tejas