---
- name: appen stacks
  hosts: supermaster
  become: yes
  tasks:
    - name: create stack template
      template:
        src: template/stack-block.j2
        dest: /tmp/new-stack-block.{{item.service_name}}.yml
      with_items:
        - service_name: tetris
          registry: registry.vnfco.ir/ig/game/tetris:latest
          target_port: 80
          source_port: 6005
          stack_lvl: 6

    
    - name: append /tmp/new-stack-block.conf to specific stack file
      shell: |
        cat /tmp/new-stack-block.{{item.service_name}}.yml >> /home/dockerman/stacks/lvl{{item.stack_lvl}}/stack.yml
        rm -rf /tmp/new-stack-block.{{item.service_name}}.yml
      with_items:
        - service_name: tetris
          registry: registry.vnfco.ir/ig/game/tetris:latest
          target_port: 80
          source_port: 6005
          stack_lvl: 6 

    




    