- hosts: localhost tasks: - name: Get current domain name shell: hostname -d register: domainname - name: Create docker sandbox containers command: docker run -dh "dock{{ item }}.{{ domainname.stdout }}" \ --name "docksand{{ item }}" \ --net=docksandnet \ --volume=/shared:/shared \ "{{ docker_registry }}/{{ sandbox_image }}" with_sequence: start="{{ docksand_start }}" end="{{ docksand_end }}"